in reply to Bareword "SEEK_END" not allowed while "strict subs" in use
open( FH , "+<" , $file ) or die "Unable to open '".$file."' - $!\n";
Btw. you really should use lexical variables instead of barewords for your filehandles. Especially if you use something obvious like 'FH'.
(and with slightly improved style)open( my $fh , "+<" , $file ) or die "Unable to open '".$file."' - $!\n";
open my $fh, '+<', $file or die "Unable to open '$file': $!\n";
Using bareword symbols to refer to file handles is particularly evil because they are global, and you have no idea if that symbol already points to some other file handle. You can mitigate some of that risk by localizing the symbol first, but that's pretty ugly. Since Perl 5.6, you can use an undefined scalar variable as a lexical reference to an anonymous filehandle. Alternatively, see the IO::Handle or IO::File or FileHandle modules for an object-oriented approach.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Bareword "SEEK_END" not allowed while "strict subs" in use (FH)
by tye (Sage) on May 13, 2014 at 14:00 UTC | |
by Monk::Thomas (Friar) on May 13, 2014 at 15:16 UTC | |
by tye (Sage) on May 13, 2014 at 15:21 UTC | |
by Monk::Thomas (Friar) on May 13, 2014 at 16:36 UTC | |
by ikegami (Patriarch) on May 14, 2014 at 15:07 UTC |