while ( ) { if ( /browse(\/.*)\// ) { #if the current $_ matches #browse followed by a # / followed by anything #but having to be followed by # another / #then put whatever was found #between the parens in $line my $line = $1; print "$line\n"; } } __DATA__ http://www.url.com/browse/ASP/scripts/homesites/ /browse/ASP/scripts/homesites/ /browse/ASP/scripts/homesites/index.htm