Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi Monks,
Being completely new to Perl and regexps, I thought the best way to learn is to get some practice. I thought I was getting the hang of it with simpler searches so I tried to use it for a problem at work. Here's where I got stuck:
There are a series of folders and each folder is named like so: "6 digit number" "optional ." "optional 2 digit number" "optional letter"

i.e. ######, ######.##, or ######.##a

Inside each folder is a file with the same name as the folder plus "_vml_1.htm". i.e. 274813.99a_vml_1.htm and inside this file I want to find <foldername>_vml_1.emz and replace it with <foldername>_gif_1.gif

Here's a little test program
... $folder = shift(@dir); #dir is a listing of folders $folder =~ /(\d{6}.?\d{2}?\w?)/; open FILE, ">./$folder/$1_vml.htm"; ...
I realize I must be doing something really stupid when I try to match the foldername. But I can't figure out why the expression after \d{6} does not work.
Please help shed some light on this so I don't have nightmares ;-)
Thanks in advance!

In reply to Regular Expression Question by MistaMuShu

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    Domain Nodelet?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others goofing around in the Monastery: (4)
    As of 2024-07-12 21:03 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found

      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.