Just want to point out that you can also using symbolic substitution, which was how I interpreted the OP's "substituting certain keywords with variables".   Although I made a recent argument in favor of always being in the habit of using strict, I can see why this might be a good situation for using "no strict 'refs'":
#!/usr/bin/perl -w + use warnings; use strict; no strict 'refs'; + our $a = 10; our $b = 20; our $c = 33; our $d = 123; + my @lines = qw( <:a:0:> <:a:3:> <:b:0:> <:b:4:> <:c:5:> <:d:6:> ); + foreach my $line (@lines) { if ($line =~ s/<:(\w+):(\d+):>/$$1*($2||1)/e) { printf "Result = %d\n", $line; } }
Output is:
    Result = 10
    Result = 30
    Result = 20
    Result = 80
    Result = 165
    Result = 738

In reply to Re: Evaluating a regex replacement value by liverpole
in thread Evaluating a regex replacement value by McDarren

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.