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.

ack Albuquerque, NM

Replies are listed 'Best First'.
Re^2: Using Split function.
by vinoth.ree (Monsignor) on Aug 04, 2009 at 05:53 UTC
    ack,

    Did you read my question? Understood clearly?

    In my question,I told that I was using the temporary array and using the $#array_name to get the last element from the array. You also side the same thing.

    Update

    Spelling mistakes corrected