http://qs321.pair.com?node_id=220311


in reply to Re: Printing the last few elements of an array.
in thread Printing the last few elements of an array.

Thanks dakkar - now I understand! Is there any way I could have phrased that to make the $count mechanism work?
  • Comment on Re: Re: Printing the last few elements of an array.

Replies are listed 'Best First'.
Re: Re: Re: Printing the last few elements of an array.
by dakkar (Hermit) on Dec 19, 2002 at 09:07 UTC
    @record=reverse @record; my @record1; my $count=0; my $line; while (($count<5) && ($line=$record[$count])) { push @record1,$line; $count++ } @record1=reverse @record1; print join ',',@record1;

    The last reverse is to get the elements in the original order.

    Just promise me you won't really use this version, please? ;-)))

    -- 
            dakkar - Mobilis in mobile
    
      I really appreciate this, dakkar - I understand what pain it must have caused you to write that. I do promise not to use it - but it's very useful for me to see how it works! Thank you.