The offset of the last element in an array is $#array.  So $array[$#array]
is the last value.

At 03:58 PM 4/21/05 -0400, Chris wrote:
>> $s1 = "c:\\temp\\foo.pl"; 
>> $barename = (split( /\\/, $s1)[2];  # $barename gets "foo.pl" 

To do it in one shot you can do:
$last = (reverse (split /\\/, $s1))[0]; or best:
$last = (split /\\/, $s1)[-1];

But for grokking paths u should really use File::Basename.



--
REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 >=--
"...ne cede males"

00000100

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to