Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

srings and REGEXP

Status
Not open for further replies.

mikerobb

Programmer
Nov 7, 2001
13
0
0
US
Hi-

my $file=$x;
$file=~s/$path//;

How can I do this in one line?

-TIA! :)

--Mike Robb
 
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

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
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/);

... ?
 
you could also do it like this:
Code:
my ($file) = ($x =~ /$path(.*)/);

$x is not affected. (-:
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top