sub getfile
{
 # Get the name of the file, and which mode we want:
 my ($file,$mode) = @_; 
 
	# Now continue as follows:
 
	# 1. Try and open the requested file, or die with an error if we can't.
	# 2. Call the lockfile() function for a shared lock (for read).
	# 3. Read the file contents into an array (@lines) then close the file.
 
 open (FILE, "<$file") || die "Unable to open $file: $!";
 lockfile(1);
 my @lines = <FILE>;
 close(FILE);
 
	# If the requested mode was 1 (scalar context), return @lines joined into a single string.
	# If the requested mode was anything else, we just return @lines as an array.
 
 if ($mode == 1){
  return join('',@lines);
 }else{
  return @lines;
 }
}
1;