in reply to peeling the top 10 lines from a file
Setting aside all the other matters already addressed by other posters, AFAIK while's magic with angular parentheses holds only for thewhile( (<>) && counter <10){
construct (or the equivalent one including an explicit filehandle).while(<>) { # ...
Update: (to better explain myself) hence your script, even if corrected from the obvious error, would give you a "Use of uninitialized value in print" warning.
Also, unless you chomp it shouldn't be necessary to include "\n" in your output string. Unless you really want double spacing. In any case I'd probably locally set $\ suitably instead.
Hence all in all I'd simply do:
while (<>) { print; last if $. == 10; }
|
|---|