in reply to pattern matching question

Just for TIMTOWTDI sake:
use strict; my @pathandfile = qw(c:\dir1/dir2/file1.txt c:\dir1/dir3/file2); for (@pathandfile) { $_ =~ /(.*)(\\|\/)(.*)$/; print "PATH: $1 - FILE: $3\n"; }

Replies are listed 'Best First'.
Re^2: pattern matching question
by smokemachine (Hermit) on Dec 28, 2005 at 22:46 UTC
    almost the same, but...
    perl -e 'my @pathandfile = qw(c:\d1/d2/f1.txt c:\d1/d3/f2 c:\d1\d2\f4 +c:\d1\d2\d3\f5); for (@pathandfile){print "PATH: $1 - FILE: $2\n" i +f /(.*)[\\|\/]([^\/|^\\]+)$/;}'