in reply to Wildcards for a wide array of strings?

This is amazing, the more I learn about this stuff, the more I'm starting to like it. Started with a 'task' which I didn't really want to do (bit out of my comfort zone), but ended up wanting to learn more and more about this new world. Well, new to me obviously.

Thank you very much for all the tips. I'll include the code I eventually ended up with. I think it's as short as it can possibly be and a lot of the suggestions are not included, this is because I like these things short, clean and clear (always try to do this with SQL too, with which I have more experience).

Might include some kind of logging if it goes wrong at some point, but I can't see this doing weird stuff as the applications that use these folders do what they're supposed to do.

#!perl -w # # Archiver for processed EDI messages # - move all messages to existing subfolder *\yyyy\mm\dd use strict; use warnings; use Time::Piece; use File::Copy; my $base = 'D:\\Some\\Specific\\Folder\\'; # The source folder my $to = $base.localtime()->ymd ('\\')."\\"; # The destination folder foreach my $file (glob qq($base\*.txt)) { File::Copy::move $file, $to or warn "Can't move $file to $to : $ +!"; } # The actual move exit 0; # The graceful ending

Replies are listed 'Best First'.
Re^2: Wildcards for a wide array of strings?
by Discipulus (Canon) on May 24, 2017 at 08:33 UTC
    Hello again zarath,

    glad you solved your issue and that you started to like the Perl many ways to problem solving.

    Perlmonks is a wonderful place to learn.

    Just a little consideration: finally you ended with 'D:\\Some\\Specific\\Folder\\' why?

    We all know MSwin32 is a weird platform and \\ will work, as will work c:/path\\to\\\another\\\\dir that is weird.

    Windows also accept the Linux directory separator / and I usaully use it in my programs: you can be interested by Paths in Perl and as the wise mr_mischief altready suggested, to use File::Spec module that with a bit of overhead makes your programs portable to different platform.

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      Hi Discipulus,

      Deciding on the platform that we use is not up to me (above my paygrade). I think they landed on this back in the day because they needed something easily implemented and they needed it instantly. The company I work for kind of tried to ride a bicycle before it could crawl. Right now it's got walking down and learning to run. We'll have to look into other platforms, but at the moment it is not in the top 10 prio-list.