in reply to Return the contents of a file
Two things:
1) that while loop should read:
Note the all-important ".=" instead of "=" (probably just a mistype on your part. :)while (<FS>) { $OP .= $_ }
2) your opens should always check for error messages, and you should get faster results slurping the whole file in as one string, like so:
sub readfile { my $OP; open FS, $_[0] or die "Can't open $_[0]: $!"; { local $/ = undef; $OP = <FS>; } close FS or die "Can't close $_[0]: $!"; return $OP; }
In Section
Cool Uses for Perl