in reply to Regular Expressions, IF, Issue

The first match doesn't work. Using warnings will tell you that $1 and $2 are uninitialized. It's not clear to me what you're trying to accomplish here. Perhaps a bit more explanation would help.

Replies are listed 'Best First'.
Re^2: Regular Expressions, IF, Issue
by Anonymous Monk on Apr 21, 2006 at 15:06 UTC
    sorry didn't explain well, trying to match the path even if it's shorter or not.
      This works now!
      #!/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 "<br>*****$1*****$2****<br>"; #But in here the if doesn't, it will go to the ELSE, why? if($test_match =~/(.*?)\/([^\/]+)\/$/){ print "<br>^^^^$1^^$2^^^^<br>";} else{ print "No Match"; }