in reply to Re: split string and always get last word
in thread split string and always get last word

I'll post a non-split solution. IRL I'd probably use a regex for this anyway.
my $string = "/alex/samsung/t2"; $string =~ m/(.+)\/(.+)$/; print "$1, $2";


"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

Replies are listed 'Best First'.
Re^3: split string and always get last word
by matze (Friar) on Mar 02, 2006 at 11:40 UTC
    Another regexp if you don't need the path:
    my $string = "/alex/samsung/t2"; $string =~ m/([^\/]+)$/; print $1, "\n";