Not 100% sure this is your issue but if you use anything in the indirect object / filehandle argument "slot" to print other than a simple scalar variable (edit: or a plain bareword, of course) you're going to need to wrap it in a block like print { $ads{ $this_ad} } "blah blah";. I'm surprised that it's even parsing and not throwing a syntax error the way you've got it now (samples w/5.32.0 on OS X).
$ perl -MO=Deparse,-p,-q -E 'print $ads{$this_ad} "$line\n";' String found where operator expected at -e line 1, near "} "$line\n"" (Missing operator before "$line\n"?) syntax error at -e line 1, near "} "$line\n"" -e had compilation errors. $ perl -MO=Deparse,-p,-q -E 'print { $ads{$this_ad} } "$line\n";' use feature 'current_sub', 'bitwise', 'evalbytes', 'fc', 'postderef_qq +', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval'; print({$ads{$this_ad};} ($line . "\n")); -e syntax OK
Afterthought: you also could call the print method on your handle as an alternative: $ads{$this_ad}->print( "blah" )
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re: Dereference a reference to a file handle created with IO::File
by Fletch
in thread Dereference a reference to a file handle created with IO::File
by dgdriscoll
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |