Hi t-rex,

I can't reproduce the issue with the code you showed. I tested with both the original code you posted (with dummy values inserted for the missing variables) and the following boiled down version.

my $inp = <<'END'; <%= my $capi = 'foo'; $capi; %> <%= my $marega = 'bar'; $marega; %> END while($inp =~ /<%=(.*?)%>/s) { print "Dollar 1 before eval = $1\n"; $inp =~ s/<%=(.*?)%>/eval $1/es; print "INP after substitution = $inp\n"; } __END__ Dollar 1 before eval = my $capi = 'foo'; $capi; INP after substitution = foo <%= my $marega = 'bar'; $marega; %> Dollar 1 before eval = my $marega = 'bar'; $marega; INP after substitution = foo bar

Please try to boil down your problematic code into a Short, Self-Contained, Correct Example that reproduces the problem.

Perhaps if (@{$ctxt{'capi_devices'}}) is false, and that's why the $capi output is not showing up? (Although based on your sample output that wouldn't fully explain why that code block is skipped - your sample output appears to show only one iteration of the loop.)

You could try to insert debugging warn statements at strategic places to see what does and doesn't get executed. See also the Basic debugging checklist.

Regards,
-- Hauke D


In reply to Re: Regex error in the second last string by haukex
in thread Regex error in the second last string by t-rex

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.