in reply to Dissecting a complete pathname to a file
I'm pretty sure pure regular expressions isn't really the best answer here.
If you wish to do things like expand the ./, have a look at Cwd (e.g., $full = abs_path($file)). It has all that magic built in. For finding the test.txt (assuming / is the only magic character in your paths), you probably just want something like my $short = $1 if $file =~ m/([^\\]+)\z/;.
UPDATE: I wasn't trying to complete a programming assignment, I was just giving general suggestions... My suggestion was that filling out the fullpath is probably not the job of a regular expression. Clearly, File::Spec (below) is a cleaner solution anyway, and that doesn't involve regular expressions at all. I'm also pretty sure Cwd is a Core perl module, so I'm not sure where you're going with that.
UPDATE2: Ahh, I see what you mean, my mistake.
-Paul
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dissecting a complete pathname to a file
by ikegami (Patriarch) on Feb 28, 2007 at 00:03 UTC | |
|
Re^2: Dissecting a complete pathname to a file
by ikegami (Patriarch) on Feb 28, 2007 at 03:50 UTC |