If your data is as regular as it appears to be, a couple of splits instead of regexes will get the job done.
#!/usr/bin/perl -w use strict; while (<DATA>) { chomp; my ($basedir, @dot_names) = split(/\./,$_); my $type = (split('/',$basedir))[-1]; my $school = "null"; $school=$dot_names[-2] if (@dot_names >1); #open the file here and use the variables as prefix for each line print "type: $type school: $school\n"; } =prints type: abc school: null type: def school: null type: abc school: cole type: abc school: drew type: def school: cole type: def school: drew =cut __DATA__ /home/test/abc/.date_run_dir /home/test/def/.date_run_dir /home/test/abc/.date_file_sent.email@wolverine.cole.edu /home/test/abc/.date_file_sent.dp3.drew.net /home/test/def/.date_file_sent.email@wolverine.cole.edu /home/test/def/.date_file_sent.dp3.drew.net

In reply to Re: Help constructing proper regex to extract values from filenames and concurrently opening those same files to access records by Marshall
in thread Help constructing proper regex to extract values from filenames and concurrently opening those same files to access records by JaeDre619

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.