in reply to print statement changes results!

My guess is that if you do:

while( $text =~ /($pattern)/g ) { my $startindex = $-[0]; my $endindex = $+[0]; my $capture = $1; my $vsoChars = $VShape->Characters; $vsoChars->{Begin} = "$startindex"; $vsoChars->{End} = "$endindex"; $vsoChars->{Text} = $capture; $vsoChars->SetProperty( 'CharProps', 1, $color ); }

or even:

while( $text =~ /($pattern)/g ) { my $vsoChars = $VShape->Characters; $vsoChars->{Begin} = "$-[0]"; $vsoChars->{End} = "$+[0]"; $vsoChars->{Text} = $1; $vsoChars->SetProperty( 'CharProps', 1, $color ); }

they will also work.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: print statement changes results!
by cr8josh (Sexton) on Jun 06, 2011 at 17:57 UTC
    Both worked. Thank you!
      Sounds like some XS code is accessing the string buffer of the scalar whether the scalar holds a string or not. That code should be coercing the value of the scalar into a string if the scalar doesn't contain one.
      A reply falls below the community's threshold of quality. You may see it by logging in.
Re^2: print statement changes results!
by CountZero (Bishop) on Jun 06, 2011 at 17:51 UTC
    So you think one has to use the stringified version of the value?

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      The values return from $-[0]/$+[0] are integers stored in the IV part of the scalar.

      Interpolating them in the print statement will have the side effect of forcing the PV slots to be populated with the stringified versions of those integers.

      If the XS code that is behind this VShape object is only looking at the PV slot, that would explain why the print statement has the effect of making the code work.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.