in reply to how to find particular string and store in to variable

A different approach:

#!/usr/bin/env perl use strict; use warnings; use URI::URL; use feature qw(say); my $url = URI::URL->new( q(http://172.20.37.115:8080/se/1.0/provision/subscribers/198968)); # say( map { ( split /\// )[-1] } $url->path ); my ($var) = map { ( split /\// )[-1] } $url->path; say $var; __END__ karls-mac-mini:monks karl$ ./1131943.pl 198968

Please see also URI::URL, map, split and TMTOWTDI.

Update: For a better solution (my @paths = $url->path_segments;) please see below.

Regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Replies are listed 'Best First'.
Re^2: how to find particular string and store in to variable
by Anonymous Monk on Jun 25, 2015 at 19:20 UTC

    Why not use the module to its full potential?

    use URI::URL; my $url = URI::URL->new( 'http://172.20.37.115:8080/se/1.0/provision/subscribers/198968'); my @paths = $url->path_segments; my $last = $paths[-1]; print "$last\n"; __END__ 198968
      "Why not use the module to its full potential?"

      Good question. Let us assume that i didn't remember it ;-(

      Update: And thanks for this advice.

      Best regards, Karl

      «The Crux of the Biscuit is the Apostrophe»