On Tue, 5 Dec 2000 12:25:58 -0500, someone going by the name of Matthew Fischer <mfischer@fishmancom.com> communicated: >I have a script that reads a file into an array, then prints out >each line of the array, then does some other stuff with the array. I >need to change it so it only prints out the first 8 lines of the >array. How would I change this to do that? > > > foreach $line (@whole) { > $line =~ s/\n//g; > print "$line\n"; > > > } Or, it's very similar to something else I just did, in one line... print join("\n",@whole[0..($#whole>7 ? 7 : $#whole)]),"\n"; It doesn't pull out the carriage returns, but I was using this for debugging an array that I knew didn't have them. If you know that each line is terminated by a return, you should be able to get away with... print join("",@whole[0..($#whole>7 ? 7 : $#whole)]),"\n"; (That "7" is the number of entries you want to print out, minus 1.) Tim Bailey / tim@moonrise.org |\/ "If you don't know where you are going, telestro@earthlink.net |\/ you will probably end up somewhere http://www.moonrise.org | else." @>--`--,-- CJZ -- Lawrence J. Peter ---(27 days to the millennium!)-- # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org