C:\>perl f:\_wo\pl_test\669947.pl $0 is: f:\_wo\pl_test\669947.pl nikhil.patil's $2 is: f:\_wo\pl_test\669947.pl #### #!C:/Perl/bin -w print "\n\t\$0 is: " . $0 . "\n\n"; # nikhil.patil's regex $0 =~ /(.*\/)*(.+)/; print "\n\tnikhil.patil's \$2 is: $2\n\n"; print "\n\nww's failed\n\n"; if ( $0 =~ /(?!(.*?)\Q\\\E)\G(.+)$/ ) { print "\n\t \$1 is: |$1|. However, note my failure to capture the final '\\' in the path\n"; # $path = $1; # print "\n\t\$path is: $path\n"; # BUT HOW DO I CAPTURE THE LAST "\" IN THE PATH print "\n\t \$2 is: |$2| \n"; print "\n\t \$2 is the whole of \$0 because lookarounds, when completed, discard all intermediate info\n"; } else { print "\n\tNo match\n"; } #### ww's failed $1 is: |f:\_wo\pl_test|. However, note my failure to capture the final '\' in the path $2 is: |f:\_wo\pl_test\669947.pl| $2 is the whole of $0 because lookarounds, when completed, discard all intermediate info #### $foo = $0; print "\n\t \$foo: |$foo| before the substitution \n"; $foo =~s/^.*\\//; print "\n\t And, after the substitution: |$foo| \n"; #### $foo: |f:\_wo\pl_test\669947.pl| before the substitution And, after the substitution: |669947.pl| C:\>