my $string="/ae/gowtham_langTests/hpgl2/hpgl2/linepath/masters/top2bottom/top2bottom9/top2bott om9.plt1.tiff "; my $pattern = "/hpgl2/"; if ( $string =~ /\A(.*?)$pattern/ ) { print "place: ", length $1, "\n"; } print "index: ", index( $string, $pattern ), "\n"; __END__ place: 21 index: 21