in reply to Small question: Why can't I print "@-"?

You can interpolate both arrays, but you have to do so at the right time

print "@-:@+" while 'the quick brown fox jumps over the lazy dog' =~ /(\b.+?\b)(.+ +?)\b/g 0 0 3:4 3 4 4 4 9:10 9 10 10 10 15:16 15 16 16 16 19:20 19 20 20 20 25:26 25 26 26 26 30:31 30 31 31 31 34:35 34 35 35 35 39:40 39 40 print "@-:@+" :

Both arrays are reset before a new match is attempted, so when the match fails, they contain nothing to interpolate.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.

Replies are listed 'Best First'.
Re: Re: Small question: Why can't I print "@-"?
by Not_a_Number (Prior) on Sep 23, 2003 at 19:58 UTC

    Right, thanks, this must be a version thing. If I use your code:

    print "@-:@+\n" while 'the quick brown fox jumps over the lazy dog' =~ /(\b.+?\b)(.+ +?)\b/g

    I get the following output:

    @-:@+ @-:@+ @-:@+ @-:@+ @-:@+ @-:@+ @-:@+ @-:@+
    whereas if I adapt it as per sauoq's suggestion below:

    print "@{-}:@{+}\n" while 'the quick brown fox jumps over the lazy dog' =~ /(\b.+?\b)(.+ +?)\b/g

    I get what I want.

    I use AS 5.61 on XP

    dave

      Yep, this a known bug in 5.6.1, but it is fixed in 5.8.0.

      -- Mike

      --
      XML::Simpler does not require XML::Parser or a SAX parser. It does require File::Slurp.
      -- grantm, perldoc XML::Simpler

      Ah! I ran the sample on AS 5.8.0


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
      If I understand your problem, I can solve it! Of course, the same can be said for you.