in reply to Reading Data from a file
1 Use lexical variables as file handles:
open my $handle, '<', $filename or die "Can't open '$filename' for reading: $!"; while (<$handle>){ ... } close $handle
This will avoid trouble if you forget to close a filehandle, or call functions recursively while a handle is still open
2 If you want to dump the output of an array, set a backslash in front of it:
my @list = qw(foo bar baz); print Dumper \@list; __END__ VAR1 = [ 'foo', 'bar', 'baz' ];
This makes it clearer that it's one variable, and you can easily see where it ends.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reading Data from a file
by Anonymous Monk on Apr 03, 2008 at 13:36 UTC | |
by Corion (Patriarch) on Apr 03, 2008 at 13:49 UTC |