1. Command line argument
E:\Purand\temp>lastarray.pl 1.txt 2.txt 3.txt
print $ARGV[-1]
2. Current folder file list
use strict;
use warnings;
@files = <*>;
print "$files[-1]\n";
OR
my @files = glob("*");
my $last_file_name = pop(@files);
print $last_file_name;
3. From array
my @array = qw(purand kush haneesh nikil mukesh);
print $array[$#array];
No comments:
Post a Comment