Update: After seeing some other replies, I would advise to use the "/" character instead of the "\" character in delimiting program paths. In Perl using "/" instead of "\" works just fine on both Unix and Windows and I recommend it.#!/usr/bin/perl use strict; use warnings; my @dirs = qw ( C:\somedirectory\anotherDirectory\WorkingDirectory\myFile.txt C:\somedirectory\anotherDirectory\WorkingDirectory\Logs\myLogs.txt C:\somedirectory\anotherDirectory\WorkingDirectory\Stuff\myStuff.txt C:\someBSdirectory\bogus.txt ); foreach my $dir (@dirs) { print "$1\n" if $dir =~ /(\\WorkingDirectory.*$)/; } __END__ prints: \WorkingDirectory\myFile.txt \WorkingDirectory\Logs\myLogs.txt \WorkingDirectory\Stuff\myStuff.txt
In reply to Re: Path parsing from full to relative
by Marshall
in thread Path parsing from full to relative
by Kaplah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |