Dear Monks, I have this weird case of string substitution that work on perl 5.10 but doesn't work on 5.8.3 solaris. I was wondering if it's a bug?
sub rpt_parsetoken($$$$$) { my ($rptsql,$n,$sd,$ed,$d) = @_; my $newval; while ($rptsql =~ m/{(\w+)}/) { print "token : $&\n"; my $token = $&; my $newval; my $streval; if ($1 eq 'node') { $newval = qq{$n}; } elsif ($1 eq 'startdate') { $newval = qq{$sd}; } elsif ($1 eq 'enddate') { $newval = qq{$ed}; } elsif ($1 eq 'date') { $newval = qq{$d}; } print ("getting value from token: ".$newval."\n"); print (" eval = $streval\n"); #eval $streval; $rptsql =~ s/{$token}/'$newval'/; } print $rptsql."\n"; return $rptsql; } sub test($) { my ($str) = @_;#q{ this is nothing to $fess about}; my $nstr; #while ($str =~ m/##\w+##/) { while ($str =~ m/\$\w+/) { my $token = $&; print "original: $str\n"; print "token: $token\n"; $token = "\\".$token; print "modified token : $token\n"; my $newval = qq{'wierd'}; $str =~ s/$token/$newval/; print "patched: $str\n"; } } output from solaris 9 + perl 5.8.3: ----------------------------------- token : {node} getting value from token: dws2 '/val = $rptsql =~ s/$token/'dws2 'elect 1, 2 from RECON_SAP_DATA where DWS_NODE = 'dws2 '0080910-07:26:21 : preparing sql: select 1, 2 from RECON_SAP_DATA whe +re DWS_NODE = 'dws2 output from windows + perl 5.10: --------------------------------- token : {node} getting value from token: dws2 eval = $rptsql =~ s/$token/'dws2'/ 20080910-12:42:44 : preparing sql: select 1, 2 from RECON_SAP_DATA whe +re DWS_NODE = 'dws2' for some reason the ' is getting shuffled around to start of the strin +g
Am I missing something here? If you can enlighten me, it will be greatly appreciated. Regards Troy

In reply to Perl 5.10 & perl 5.8.3 solaris by troy222

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.