Hello again zarath,

I noticed a few things on your code:

You do not need use File::Path; and use File::Glob;.

Also you do not need these lines, you do not do anything with the opendir(). You open and close the directory for no reason.

my $base = 'D:\\Some\\specific\\folder\\'; opendir (my $dhb, $base) or die "Cannot open ".$base.": ".$!; closedir $dhb;

I would prefer to get the time like this:

# 0 1 2 3 4 5 6 7 8 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(t +ime); # $mon the month in the range 0..11 , with 0 indicating January and 11 $mon += 1; # $year contains the number of years since 1900. To get a 4-digit year + write: $year += 1900;

By doing so, you do not need the package use Time::Piece;.

Update: I would also recommend to add and if() and else condition at your for loop. Also you can remove the else condition inside the loop in case the if() condition is not met it will jump straight to next;

if (@files) { foreach my $file (@files) { if ($file = glob(($base)."*.txt")){ move($file, $to) or die ("The move operation failed for ".$fil +e." because ".$!); print "Moved ".$file." to ".$to or die $!; } next; } } else { print "No files found to move\n"; }

These are some minor recommendations, hope you will love Perl and continue working on it.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re^2: Wildcards for a wide array of strings? by thanos1983
in thread Wildcards for a wide array of strings? by zarath

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.