in reply to Fatal + <FILE> = only once warning
$ perl -MO=Deparse -wl -MFatal=open -e 'open A, "date|"; print scalar +<A>' Name "main::A" used only once: possible typo at -e line 1. # .. # lots of imported stuff from Fatal # .. &open('A', 'date|'); print scalar <A>; -e syntax OK
As you can see the A in the open call has become a string. I guess the builtin's prototype cannot be exactly duplicated by Fatal, leading to the filehandle being passed it by symbolic reference rather than globname. Of course perl can't know that that string is a symref to the handle at compile time.
The simplest fix is also a good habit: use lexical variables to hold your filehandles.
This also makes Perl automatically clean up filehandles that go out of scope behind you, and you don't have to be careful not to step on anyone's toes with the chosen filehandle name either.$ perl -wl -MFatal=open -e 'open my $pipe, "date|"; print scalar <$pip +e>' Tue Mar 25 02:37:32 CET 2003
Makeshifts last the longest.
|
|---|