[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Loop question



Assuming you wanted to still muck around with the rest of the array:

     foreach $line (@whole) {
        $count++;
        $line =~ s/\n//g;
        print "$line\n" if $count <= 8;
     }

If @whole is coming from a file, the while(<>) filehandle walker has a
special variable $. that keeps track of the current line number for you,
instead of using a counter.  See the perlvar POD file for more details.

-- 
Jeremy A. Mates                       (206) 221-4714   Fax: 685-7301
Senior Systems Administrator          K 353B, Health Sciences Center
http://www.mbt.washington.edu/        Mail Box 357730
University of Washington              Seattle, WA  98195


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org