in reply to Using Split function.
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using Split function.
by vinoth.ree (Monsignor) on Aug 04, 2009 at 05:53 UTC |