I have been wrestling with this one for 2 days now, trying to come up with a rule that works. Let me describe exactly what I'm trying to accomplish:

my $dir = "/home/limo/Perl/2000/0827/steves/router/configs";
#new "yyyy/mmdd" are created daily

"Enter date of config file using < yyyy/mmdd >: ";  
chomp ( $date_cfg = <STDIN>);
# date of file that user wants to process

#code here which grabs the "2000/0827" directories: works fine
#code here that converts "2000/0827" to "08/27/2000" via s///
#stores it in "$new_date" for writing to STDOUT: works fine

print "Looking for Juniper router configuration file(s) from: $new_date\n";
Here's where my problem lies: I need the program to take the previous input from the user in "yyyy/mmdd" format, and plug it into $dir, and list files in the chosen directory.

This bombs:

opendir(DIR, $dir/$date_cfg)  or die "Can't read from $dir/date_cfg: $!\n";


as well as:

opendir(DIR, $dir/$new_date)  or die "Can't read from $dir/date_cfg: $!\n";
The program lists directory files just fine, if I hard code the path; I'm just having problems passing the correct directory argument to the code.

In reply to Search for file using element of path as file name by Limo

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.