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

Re: [MacPerl] Loop question



###   Thus?

$\ = "\n"                                ##  line delimiter for output (or, instead of this, as last line: print $_, "\n" }

for (@whole) {
  if ( $i++ > 8 )  {  last  }
  chomp;
  print }


###  Detlef Lindenthal <detlef@lindenthal.com>

__END__



Matthew Fischer wrote:

> 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";  }


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