> I've got this problem: pulling the bare filename off of > a fully pathed string, using split. The tricky part is > getting the last element in the array when I don't know > how many members are in it.
If you insist on using split, then use the -1 index: $basename = (split( m#[\\/]#, $s1)[-1]; Alternatively, you could use a regex: $basename = $s1 =~ m#^.*[\\/](.*)# ? $1 : $s1; The reason for the conditional is that $s1 might not have any directory separators in it (that is, just the filename). But a better solution is to use the File::Basename module. -- Mike Arms _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
