Orchid Fairy (兰花仙子) wrote:
> On Wed, Nov 25, 2009 at 11:06 AM, John W. Krahn <[email protected]> wrote:
>
>> $ perl -le '$_="aXXXb"; print "one word is $1 at $-[0] to $+[0]" while
>> /(X*)/g;'
>> one word is at 0 to 0
>> one word is XXX at 1 to 4
>> one word is at 4 to 4
>> one word is at 5 to 5
>>
>
> Thanks that's so smart~
>
> But I'm still confused since 4 is the end, why still run for the last
> step of 5 to 5?
>
> //Fairy
>
I agree with you; I think it's a bug. But I think it's the one at "4
to 4" that's the bug.
$ perl -le 'for(qw( ab aXb aYb )){ print "$_";print "\tone word is
\"$1\" at $-[0] to $+[0]" while /(X*)/g;}'
ab
one word is "" at 0 to 0
one word is "" at 1 to 1
one word is "" at 2 to 2
aXb
one word is "" at 0 to 0
one word is "X" at 1 to 2
one word is "" at 2 to 2
one word is "" at 3 to 3
aYb
one word is "" at 0 to 0
one word is "" at 1 to 1
one word is "" at 2 to 2
one word is "" at 3 to 3
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
I like Perl; it's the only language where you can bless your
thingy.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/