For a short list like yours it doesn't really matter. But for a really big string with lots of elements, it's wasteful to create a big list (which is a copy of the string but split up) only to grab the last element. ...think along the lines of photocopying a book, and throwing away the entire copy except the last page.
Here's a method that uses a regexp to find only the last element in the string:
my $last_element; my $line = <FILEHANDLE>; if( $line =~ m/:([^:]*)\Z/ ) { $last_element = $1; }
Dave
In reply to Re: perlish way of splitting file records
by davido
in thread perlish way of splitting file records
by narashima
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |