Do you have a question? Post it now! No Registration Necessary. Now with pictures!
December 10, 2008, 3:14 am
rate this thread
Sorry I'm kind of a noob.
I have the following string:
and I need to parse out the word jimmy. So I tried:
print "$1, $2";
thinking it would output:
but it outputs:
So it thinks the last slash is the one I'm interested in. So the
$printdir is always the same but after that it changes and it can be
deeper or less deep that the sample line above.
Can anyone help me with this? Thanks.
Oh, I need the stuff after Jimmy to go to another variable ideally.
Re: Need help parsing
That can match slash characters...
Write your pattern so that the part you do not want to match slash
characters cannot match slash characters.
(And use an alternate delimiter to avoid backslash clutter):
my($another_variable) = $string=~ m#$printdir/[^/]*/(.*)#o;
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"
- » FAQ 9.14 How do I make sure users can't enter values into a form that cause my CGI script ...
- — Previous thread in » PERL Discussions