[Chicago-talk] ok im feeling a bit (lot) retarted
Dooley, Michael
Dooley.Michael at con-way.com
Wed Apr 21 14:23:06 CDT 2004
if that was the case wouldn't each (this is where the fog lifted) "segment" be replaced by Address_V2?
if its s/PATTERN/REPLACEMENT/
fulley expanded would be
s/Address_V1||FromAddr||||315 Benjamin Lane||||Boise||ID||USA||83704/Address_V2/
if I put in single quotes around $_ I get Address_V2 appended to the beginning of $_.
ok nevermind iv apperently been spending to much time at play boy and not thinking.
since I don't have a modifer at the end of the expression it only matches the 1st entry in the expression. with that now clear you are most certenly correct. I should deffinetly be much more explicit w/ the pattern so it is less ?obtuse?
-----Original Message-----
From: chicago-talk-bounces at mail.pm.org [mailto:chicago-talk-bounces at mail.pm.org]
Sent: Wednesday, April 21, 2004 2:12 PM
To: Chicago.pm chatter
Subject: Re: [Chicago-talk] ok im feeling a bit (lot) retarted
Let's see if I can debug on the fly w/out testing
it...
If that's your input line, then note that it has regex
special characters in it, and they're being treated as
such.
So it's matching "Address_V1" OR an emptry string OR
"FromAddr" OR an empty string OR "315 Benjamin Lane"
OR ....
The first thing it happens to hit is "Address_V1", so
it successfully changes that to Address_V2.
Changing your delimiters away from pipes would yield
more expected results. Alternatively, it'd probably be
good to quote the string first.
s/\Q$_\E/Address_V2/;
To keep those metacharacters from having special
meaning.
-Jim.....
--- "Dooley, Michael" <Dooley.Michael at con-way.com>
wrote:
> while (<HANDLE>) {
> if ($. == 2) {
> s/$_/Address_V2/;
> print "$_";
> }
> }
>
> ORIG
> Address_V1||FromAddr||||315 Benjamin
> Lane||||Boise||ID||USA||83704
>
> NEW
> Address_V2||FromAddr||||315 Benjamin
> Lane||||Boise||ID||USA||83704
>
> It is what I wanted but I just cant see why it is
> doing it.
> I mean why is it not substitueing the whole line w/
> just "Address_V2"?
> I didn't tell it to keep the rest of the line
> contents. Heck I didn't
> even specify what it should match. but it understood
> to swap out
> Address_V1 with Address_V2 and continue to print out
> the full line.
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at mail.pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25ยข
http://photos.yahoo.com/ph/print_splash
_______________________________________________
Chicago-talk mailing list
Chicago-talk at mail.pm.org
http://mail.pm.org/mailman/listinfo/chicago-talk
More information about the Chicago-talk
mailing list