http://www.perlmonks.org?node_id=11107426

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, I was golfing around with ways to make perl print its own source and came up with something odd. I would expect the following program to print the first line of itself but it prints the entire file. Why does it do that?
#!/usr/bin/perl use strict; use warnings; print do{@ARGV=$0;<>};
My path thru this course:
print do{local(@ARGV,$/)=$0;<>}; # the usual idiom print do{@ARGV=$0;local$/;<>}; print do{@ARGV=$0;$/='';<>}; # bad print do{open$_,"<$0";<$_>}; print do{@ARGV=$0;*/;<>}; # wtf print do{@ARGV=$0;<>}; # wow