I am having a bit of doubt about deciphering the regex; so, here's my best shot. Please correct me when I am wrong

 $line =~ /^([^:]+):(\s+)/ && exists $subs{$1}

So, regex on $line is as follows (according to me ;-) )

"^" regex string must be at the start of the line.

The string is grouped by using the "( )", if the entire string in the "()" matches then it will substitute with a new value in the hash.

I am not sure why the class  "[ ]" are opened or mean in this regex...???

Whatever is in the class bracket, it is looking for a match of"^:" character. I am not sure about the carrot "^" does here before the ":" ?? then the class bracket closes.

The "+" plus signs indicates that there may be more strings that match the ":" character ...maybe? I am guessing here. then we close the group.

Then the character ":" appears again after the parenthesis has closed. I'm not sure what this ":" does here.

then (s+) there may be one or more spaces after the first regex match.

Then checks if that regex it just performed exists, if it does, then the new hash value replaces old to new value.

I could not run your code because it kept giving me an error

Error

reading file No such file or directory

Any ideas why this "reading file does not exist" when it was integrated in the code


In reply to Re^2: Edit a New file in place after reading it in by perlynewby
in thread Edit a New file in place after reading it in by perlynewby

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.