On Jul 22, Brent Clark said:

Think I have a better unstanding of the use of () for my regex search, but this morning I have a new set of problems, whereby I need to perform a search and replace and then pass on to the new variable.

My current code is as so, and works:

$_ =~ s/(^\w+\.dat\|)//; my $lineExtract = $_;

I'd ask first why you've got something in $_. You might be able to save time by putting the content directly into $lineExtract.

Also, you don't need to say '$_ =~' when doing a pattern match or substitution against $_; it's implied:

  s/foo/bar/;  # works on $_

This one-liner stores $_'s contents in $lineExtract, and THEN runs the substitution on $lineExtract (keeping $_ intact):

  (my $lineExtract = $_) =~ s/.../.../;

But again, I'm curious how you got stuff into $_ that you want to copy to another location anyway.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to