To use FILEHANDLE alone to print the content of $_ to it, you must use a bareword filehandle like FH, not an indirect one like $fh
I saw some websites saying that BAREWORDS to refer file handles are dangerous because they are global. But now here I see they "prohibiting" it when you like a syntax sugar. Just don't get it...
Is there any other context where automatic use of $_ can't be applyed?
I mean, if I want to print the current $_ to another file handle (not STD{OUT,ERR, etc.) I can't omit $_:
while(<>){ print $fh; #doesn't work print $fh $_; #work }
In reply to Where automatic variable $_ doesn't work? by guiwp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |