in reply to Determine if item is last one

You could do that with something like this.
#!/usr/local/bin/perl -w use strict; opendir( DIR, './' ); my @files = readdir( DIR ); closedir( DIR ); my $i = scalar @files; foreach my $file ( @files ) { $i--; # do something with the items in list if ( $i == 0 ) { # do something special with last one. } }

Wonko

Replies are listed 'Best First'.
Re: Re: Determine if item is last one
by VSarkiss (Monsignor) on Nov 15, 2002 at 20:16 UTC

    Well, after

    opendir( DIR, './' ); my @files = readdir( DIR ); closedir( DIR );
    you can get the last element with my $last = $files[-1];Hardly a good golfer, just an avid reader of perldata ;-)