in reply to Making the later front slash "/" optional
makes the front slash optional.next if $file =~ /^\/?$location/;
update: See the exemplary code below, which will result in OK2 OK3 OK4:
my $s1 = "abc"; my $s2 = "/abc"; my $all = "/abc"; print "OK1\n" if $all =~ /^$s1/; print "OK2\n" if $all =~ /^$s2/; print "OK3\n" if $all =~ /^\/?$s1/; print "OK4\n" if $all =~ /^\/?$s2/;
update 2: Thanks for the hint davido. Now that you point it out, I see that I misinterpreted front and later. @OP: please use the solution provided by davido instead!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Making the later front slash "/" optional
by davido (Cardinal) on May 03, 2011 at 07:38 UTC |