in reply to Re^5: Naming file handles with variables?
in thread Naming file handles with variables?
Interesting technique. Are there any advantages to $foo[@foo] = 'var' over push @foo, 'var'
?Anyone foolish enough to change the starting index of their arrays with "$[" will find that $foo[@foo] = 'var' breaks. But then they deserve what they get. However, push and map will function even in the dire weirdness imposed by defining arrays to start at index 23.
For completeness sake, here's the map implementation, even though you know perfectly well how to do it.
my @fileHandles = map { open my $fh, '<', $_ or die "Can't open $filename $!"; $fh; } @fileNames;
Update: fixed dumb typos, thanks to GrandFather.
TGI says moo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Naming file handles with variables?
by GrandFather (Saint) on May 03, 2009 at 21:19 UTC | |
|
Re^7: Naming file handles with variables?
by QM (Parson) on May 04, 2009 at 20:44 UTC |