C.R. wrote:
> In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
> says...
>> C.R. am Mittwoch, 25. Oktober 2006 20:38:
>>> Well, that kinda worked. I had to change it to work on a scalar so this
>>> is what I wrote:
>>> $s=~s/(\d+ +cm)/<bx;1>$1<ba>/g;
>>>
>>> Input string: 144 cm
>>> Output string: <bx;1>14<bx;1>4 cm<ba><ba>
>>>
>>> Why did I get duplicate <bx;1> and <ba> strings?
>> Hm, I can't reproduce this (perl 5.8.8):
>>
>> $ perl -le 'my $s=q(144 cm); $s=~s/(\d+ +cm)/<bx;1>$1<ba>/g; print $s;'
>> <bx;1>144 cm<ba>
>>
> My program (perl 5.6.1 on Solars) picks the data out of an array like
> this:
> $s=$a[2];
>
> Then I attemp to process $s like this:
> $s=~s/(\d+ +cm)/<bx;1>$1<ba>/g;
>
> It's not real complicated. Later I write out $s to a file. $s does not
> contain any line feeds or carriage returns.
>
> In the debugger I display $s just before the substitution executes, step
> past the line, then I display $s in the debugger where I can see too
> many <bx;1>s and <ba>s.

You need to show us your code Chuck. Perl doesn't do that, in any situation that
I can think of. Try running this on its own:

my $s = '144 cm';
$s =~ s/(\d+ +cm)/<bx;1>$1<ba>/g;
print $s;

I get

<bx;1>144 cm<ba>

what do you get?

That may help on its own. If not, like I said, post the relevant part of your
code.

Rob

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