The approach that I was thinking was similar to ig's but used the $#array construct rather than the index -1 that ig used. I like ig's much better as it shortens the construct to a single line of code to get the answer.
My approach suggestion was:
my @separated = split(/\//,$path); my $answer = $separated[$#separated];
However, as I noted, ig's solution is much more elegant and efficient.
In reply to Re: Using Split function.
by ack
in thread Using Split function.
by vinoth.ree
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |