#the next 2 line have been assigned earler in the program from reading + in the config file $filter = "user (.*) has (logged on)"; $output_string = "user $1 has accessed the system and is $2"; #this line has been read in from a log file $log_string = "user bob has logged on"; # need to search the log string and format output string replacing $1 +& $2 $output_string =~s/filter//g; $output_string =~s/(\$\w+)/$1/eeg; print "$output_string\n";
output is "user has accessed the system and is"
should be "user bob has accessed the system and is logged on"
looks like the output string needs to evaluate $1 & $2 how can this be done ? I know that if the output string is assigned after $1 is assigned it will work, but I needs to do this in the order specified

In reply to How can I use $1 in an assigned string by kitsonrp

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.