in reply to handling multiple file handles for code generation
The whole point of $_ is that of being the topicalizer: you either wantforeach (keys %fhs) { my $fh = $fhs{$_}; if ($_ =~ /\.h\.new$/) { print $fh "#endif\n"; }
orfor my $file (keys %fhs) { # ... print $fh whatever if $file =~ /\.\.new$/; }
but your mixed form doesn't add to code readability, although -of course- it is not illegal. (I also took the liberty of rewriting the if condition as a statement modifier, as IMHO it is clearer that way.)for (keys %fhs) { # ... print $fh whatever if /\.\.new$/; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: handling multiple file handles for code generation
by danmcb (Monk) on Sep 05, 2005 at 12:16 UTC | |
by blazar (Canon) on Sep 05, 2005 at 13:12 UTC |