in reply to Re: Interpolation of file handles in print
in thread Interpolation of file handles in print
This will work but not with use strict :
In perldoc -f print it says :#~ use strict ; use warnings ; my @marctags; my @tagdata ; $marctags[0]='FOO' ; $marctags[1]='BAR' ; open $marctags[0], ">foo.txt" or die "Failed"; open $marctags[1] , ">bar.txt" or die "Failed" ; $tagdata[0]="foo foo foo"; $tagdata[1]="bar bar bar"; for my $x (0..1) { print { $marctags[$x] } $tagdata[$x] ; }
print { $files[$i] } "stuff\n"; print { $OK ? STDOUT : STDERR } "stuff\n";
use strict will raise a : Can't use string ("FOO") as a symbol ref while "strict refs" error that i don't know how to avoid here... So use FileHandle may be better :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Interpolation of file handles in print
by jhourcle (Prior) on May 17, 2005 at 11:36 UTC |