I am trying (big emphasis on trying ) to write a script to parse log files, I thought it would be a good idea to store the regex in a hash table and use the event ID as the key. So that I can add to the hash table as new log messages types are added. My problem is that I get the regex string working properly but when I put it in a variable it stops working, a quick example is the regex to extract the event ID this works: $current_line =~ q{\A.*? %(.*?): }xms; $event_id = $1; this fails: $RGX_EVENTID = 'q{\A.*? %(.*?): }xms'; $current_line =~ $RGX_EVENTID; $event_id = $1; I'm not understanding what I'm doing wrong. Sal

In reply to store regex in hash by salp

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.