in reply to Re: Working with a unkown number of arrays
in thread Working with a unkown number of arrays
Maybe you meant to put a dot "." instead of a comma ","?$files{3} = $input_directory,"3";
Another thing that I don't understand from this fragment is if %files holds filenames or directory names. The use of open() and close() seems to point to "filenames", but in this case the readdir(DATA) should be simply <DATA>.
Regarding the open(), at the price of backward compatibility with 5.6, I use lexical filehandles instead of barewords:
Moreover, I usually stick to the three argument version of open(), not because this is requested by this particular application (I actually don't know), but more for sake of a mental habit (yes, I'm mental :) :open my $data, ...
I find it better not only because it avoids nasty problems when the filename comes from the "untrusted external" (which could lead to embarassing security holes), but also because it visually marks that this open is for read instead of write.open my $data, '<', $files{$_} ...
Last, even if the plain die does the work (especially in pseudocode!), it could be helpful to provide a more sensible feedback message, either directly:
or withopen my $data, '<', $files{$_} or die "open('$files{$_}'): $!";
in the script's preamble.use Fatal qw( open );
Forgive me for jumping on your shoulders this way, but the OP seems to have some bias towards blind cut-and-paste, you know, so it could be useful for her|him to think about these issues ;)
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Working with a unkown number of arrays
by ikegami (Patriarch) on Feb 06, 2007 at 05:36 UTC | |
|
Re^3: Working with a unkown number of arrays
by wojtyk (Friar) on Feb 05, 2007 at 22:35 UTC |