Helter has asked for the wisdom of the Perl Monks concerning the following question:
My initial search/replace was this:__msr2f6: data8 0b00000000000000000000000000_1_0_000000000000001 +0101_00000000000000000
This causes an error to be printed:$line =~ s/^(__msr2f6:\s+data8 0b[01]+_)[01]_[01](_[01]+_[01]+)/$10_0$ +2/;
A co-worker suggested a change, but didn't know why it might work:Use of uninitialized value in concatenation (.) at myscript.pl line 33 +, <FILE> line 915.
So I moved the leading and trailing underscore out of the parens and put them in the replace string.$line =~ s/^(__msr2f6:\s+data8 0b[01]+)_[01]_[01]_([01]+_[01]+)/$1_0_0 +_$2/;
But it is probably slower than the other working solution.$line =~ s/^(__msr2f6:\s+data8 0b[01]+_)[01]_[01](_[01]+_[01]+)/$1."0_ +0".$2/e;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: search, replace and backrefrences
by diotalevi (Canon) on Sep 30, 2002 at 15:18 UTC | |
Re: search, replace and backrefrences
by demerphq (Chancellor) on Sep 30, 2002 at 15:27 UTC | |
by rir (Vicar) on Sep 30, 2002 at 16:52 UTC | |
by diotalevi (Canon) on Sep 30, 2002 at 16:56 UTC | |
by rir (Vicar) on Sep 30, 2002 at 17:03 UTC | |
by demerphq (Chancellor) on Sep 30, 2002 at 19:27 UTC | |
by rir (Vicar) on Sep 30, 2002 at 20:23 UTC | |
by demerphq (Chancellor) on Sep 30, 2002 at 20:32 UTC | |
by Shendal (Hermit) on Sep 30, 2002 at 20:28 UTC | |
Re: search, replace and backrefrences
by Helter (Chaplain) on Sep 30, 2002 at 17:46 UTC |