#!/perl/bin/perl -w use strict; use warnings; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); print header(); my $test_match = "D:/newdir/cgi-bin/testbin/errors/cgi-bin/testbin/"; #Here it will match just fine #$test_match =~/(.*?)\/([^\/]+)$/; $test_match =~/(.*)\/([^\/]+)\/$/; print "
*****$1*****$2****
"; #But in here the if doesn't, it will go to the ELSE, why? if($test_match =~/(.*?)\/([^\/]+)\/$/){ print "
^^^^$1^^$2^^^^
";} else{ print "No Match"; }