in reply to Reading a Line into an Array

By the way, in Perl you don't often have to find out how many elements there are in an array. If you want the last element use: my $last = $array[ -1 ];

-- iakobski

Replies are listed 'Best First'.
Re: Re: Reading a Line into an Array
by zeidrik (Scribe) on May 31, 2001 at 12:19 UTC
    Iakobski is right. This is smarter :)
    #!/usr/bin/perl -w use strict; open(R,"textfile"); my @F=<R>; close(R); pop @F if $F[-1] eq "\n"; print @F;