cr8josh has asked for the wisdom of the Perl Monks concerning the following question:
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: print statement changes results!
by BrowserUk (Patriarch) on Jun 06, 2011 at 17:26 UTC | |
by cr8josh (Sexton) on Jun 06, 2011 at 17:57 UTC | |
by ikegami (Patriarch) on Jun 06, 2011 at 18:09 UTC | |
| |
by CountZero (Bishop) on Jun 06, 2011 at 17:51 UTC | |
by BrowserUk (Patriarch) on Jun 06, 2011 at 18:11 UTC | |
|
Re: print statement changes results!
by toolic (Bishop) on Jun 06, 2011 at 17:26 UTC | |
by chromatic (Archbishop) on Jun 06, 2011 at 18:05 UTC | |
by toolic (Bishop) on Jun 06, 2011 at 18:19 UTC | |
by chromatic (Archbishop) on Jun 06, 2011 at 22:06 UTC |