hweefarn has asked for the wisdom of the Perl Monks concerning the following question:
how can i get the output "a"? i try this$a = "/home/a/ff.pl"; print "full path name is ", $a, "\n"; if ( $a =~ /^(\/home\/)(\S+).*$/ ) { print "\$1 = ", $1, "\n"; # output is /home/ print "\$2 = ", $2, "\n"; # output is a/ff.pl }
but cannot.if ($a =~ /^(\/home\/)(\W)(\S+).*$/)
for your information, the pattern of the beginning part of the pathname will always be same, only the file name at the end will be different. sample input are: /home/a/ff.pl, /home/a/bb.pl, /home/b/cc.pl. that's all. thank you very much :)
regards,
hweefarn
update (broquaint): tidied up formatting + title change (was filter a string).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching part of a path
by Aristotle (Chancellor) on Dec 16, 2003 at 07:11 UTC | |
by Hena (Friar) on Dec 16, 2003 at 07:56 UTC | |
by Aristotle (Chancellor) on Dec 16, 2003 at 10:08 UTC | |
|
Re: Matching part of a path
by edoc (Chaplain) on Dec 16, 2003 at 07:00 UTC |