#!/usr/bin/perl print ; print "\n----\n"; seek(DATA,0,0); print ; __END__ 1 2 3 #### 1 2 3 ---- #!/usr/bin/perl print ; print "\n----\n"; seek(DATA,0,0); print ; __END__ 1 2 3 #### #!/usr/bin/perl seek(DATA,0,0); print map{$. . $_}; __END__ #### 5#!/usr/bin/perl 5 5seek(DATA,0,0); 5print map{$. . $_}; 5__END__ #### #!/usr/bin/perl -w seek(DATA,0,0); *a=*.; print map{$a-=1;$..$_}; __END__ #### C:\>perl test4.pl 5#!/usr/bin/perl -w 4 3seek(DATA,0,0); 2*a=*.; 1print map{$a-=1; $. . $_}; 0__END__ #### #!/usr/bin/perl -w use strict; #Just #Another #Perl #Hacker seek(DATA,0,0); *a=*.; print map{$a-=chomp;s/.//; "$.\t$_\n" }; __END__ #### 12 !/usr/bin/perl -w 11 10 se strict; 9 8 Just 7 Another 6 Perl 5 Hacker 4 3 eek(DATA,0,0); 2 a=*.; 1 rint map{$a-=chomp;s/.//; "$.\t$_\n" }; 0 _END__ #### #!/usr/bin/perl -w use strict; #Just # our data #Another #Perl #Hacker seek(DATA,0,0); # seek the begining of the file *a=*.; # glob assignment warn # same effect as print but includes the line num map{ $a-=chomp # chomp return num chars chomped (1) thus $a -= 1 , # comma op could be ; without changing result s # substitute <.> # first char on line ;q<''>; # with an expression that evals to null eieio # the /ee makes second part eval to null # the /i (ignore case) does not matter. # and the /o compiles once # put them together and you have: # Old Macdonald Had A JAPH E I E I O ; # yeah well if you need this explained.... $.<8&&$.>2?"$_ ":''# this is ($. < 8 and $. > 2) ? "$_ " : "", # we actually only need lines 5-8 (see above) } # close map ; # map data array (whole file) __END__