Hi all,

I have a case where by adding or removing a simple print statement, the results of my program change. My program is using OLE to set colors of certain text in Visio. Here is the code, I am using Perl 5.8.3

while ($text =~ /($pattern)/g) { my $startindex = $-[0]; my $endindex = $+[0]; my $capture = $1; print "$startindex $endindex\n"; ####REQUIRED OR WON'T WORK CO +RRECTLY! my $vsoChars = $VShape->Characters; $vsoChars->{Begin}=$startindex; $vsoChars->{End}=$endindex; $vsoChars->{Text}=$capture; $vsoChars->SetProperty('CharProps', 1, $color); }

I capture the start and end location of my found string into '$startindex' and '$endindex'. What I have found is that if I comment out the print statement, the {Begin} and {End} properties don't set correctly. With the print statement, everything works perfectly. Without it, it doesn't. I can't just print a carraige return or space or something else, I have to actually print the $startindex and $endindex values. I have verified that the data in $startindex and $endindex is the same (and correct) with and without the print statement. Has anyone ever seen anything like this?

Thanks in advance!


In reply to print statement changes results! by cr8josh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.