On 22 September 2011 09:54, Maggs <maggiechimbwa...@googlemail.com> wrote:
> am trying to open a file but the problem is on the third line > (open...) > > sub open_file { > local $/ = undef; > ($filevar, $filemode, $filename) = @_; > open ($filevar, $filemode . $filename) || die ("Can't open > $filename"); > } Are you ok installing/using the Path::Class module? - https://metacpan.org/module/Path::Class use Path::Class qw(file); my $file = file($filename); my $file_handle = $file->openw(); $file_handle->print("hi"); $file_handle->close(); # or to read my $file_handle = $file->openr(); # or to get the contents my $contents = $file->slurp(); print "Contents of " . $file->stringify . " are: \n"; print $contents; Sorry if that's not actually answering exactly what you asked, but maybe it'll help. Leo