Dec 13, 2001 #1 mikerobb Programmer Joined Nov 7, 2001 Messages 13 Location US Hi- my $file=$x; $file=~s/$path//; How can I do this in one line? -TIA! --Mike Robb http://www.js-x.com
Hi- my $file=$x; $file=~s/$path//; How can I do this in one line? -TIA! --Mike Robb http://www.js-x.com
Dec 13, 2001 #2 tsdragon Programmer Joined Dec 18, 2000 Messages 5,133 Location US I don't know WHY you need to do it on one line, but you can do it like this: Code: my $file=$x, $file=~s/$path//; Tracy Dryden tracy@bydisn.com http://www.bydisn.com Meddle not in the affairs of dragons, For you are crunchy, and good with mustard. Upvote 0 Downvote
I don't know WHY you need to do it on one line, but you can do it like this: Code: my $file=$x, $file=~s/$path//; Tracy Dryden tracy@bydisn.com http://www.bydisn.com Meddle not in the affairs of dragons, For you are crunchy, and good with mustard.
Dec 13, 2001 Thread starter #3 mikerobb Programmer Joined Nov 7, 2001 Messages 13 Location US hi- i really was looking for a quicker method to do the two steps with one step. maybe something like: my $file= ($x =~ s/$path/); ... ? Upvote 0 Downvote
hi- i really was looking for a quicker method to do the two steps with one step. maybe something like: my $file= ($x =~ s/$path/); ... ?
Dec 13, 2001 #4 stakadush Programmer Joined Oct 1, 2001 Messages 195 Location IL you could also do it like this: Code: my ($file) = ($x =~ /$path(.*)/); $x is not affected. (-: Upvote 0 Downvote
Dec 13, 2001 #5 Coderifous Programmer Joined Dec 13, 2001 Messages 782 Location US my($file = $x) =~ s/$path//; There... is that what you are looking for? $file gets the value of $x and then $file has $path stripped out. $x stays unaltered. Hope this helps, --Jim Upvote 0 Downvote
my($file = $x) =~ s/$path//; There... is that what you are looking for? $file gets the value of $x and then $file has $path stripped out. $x stays unaltered. Hope this helps, --Jim
Dec 13, 2001 Thread starter #6 mikerobb Programmer Joined Nov 7, 2001 Messages 13 Location US thanks! Upvote 0 Downvote