I do not understand regular expressions. That being said I have tried, but the "ah ha" moment when the syntax finally makes sense I still wait upon as I read tutorial after tutorial.
I've been working on a program to collect user data so that I can be lazy at work. I have to answer about 10 "Do you know where I forwared my mail to?" type questions and about 5 "Can you setup my account with a vacation message?" type questions per shift. It gets old fast; so I've got a script that will jump from server to server (using Net::SSH) looking at files and changing them depending on what I tell it to do. It works fine, but I have designs on making users use a non-root version from the web (Net::SSH::Perl so I can get their passwords and login as them) of it so they don't even have to ask me.
That being said I need to clean up the output a bit. So I was wondering about a regular expression that could match the following output.
cat: cannot open $HOME/$library::common{username}/filename Can't open $HOME/$library::common{username}/filename
$HOME and $library::common{username} are scalars (well kinda) that hold data. I do not need to match their names, but instead what they contain. I would much rather handle both of those cases in one regular expression then in two seperate if statements. The best i have turned up so far is
if($vacation_str =~ /^.*$HOME\/$library::common{username}\/.vacation.m +sg/i)
and it does not work. Tips anyone?

jcpunk
all code is tested, and doesn't work so there :p (varient on common PM sig for my own ammusment)

In reply to a really dumb regular expression question by jcpunk

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.