#!/usr/bin/perl use strict; use warnings; my $url = "http://172.20.37.115:8080/se/1.0/provision/subscribers/198968"; # use rindex to get the position of the rightmost / character, add 1 # use substr to extract the remainder of the string after this position # perldoc -f rindex # perldoc -f substr my $subscriber = substr( $url, ( rindex($url, '/') + 1 ) ); print "$subscriber";