in reply to Loading all .txt files within current directory

Please note that your script will probably not do the same thing under Linux and Windows.

As an example, this:

$ perl -E 'say $_ for @ARGV' m*.txt mail_cmc.txt modules.txt mots.txt ...
prints the file names matching the "m*.txt" pattern under Linux, Unix or Cygwin. But it doesn't work under Windows:
C:\Users\Laurent>perl -E "say $_ for @ARGV" t*.* t*.*
The difference is that the Unix or Linux shell will expand "m*.txt" into a list of files matching the pattern and pass the list to the Perl script, whereas Windows is too lazy to do that and just passes the pattern as you have entered.

In the latter case (i.e. with Windows, you need glob or something equivalent to expand this pattern into a list of files.

perl -E "my @a = glob(shift); say $_ for @a" t*.* test_hash.pl test_parl10_1.pl test_perl10.pl test_perl11.pl ...

Replies are listed 'Best First'.
Re^2: Loading all .txt files within current directory
by Discipulus (Canon) on Feb 01, 2016 at 11:26 UTC
    Because of this I use
    BEGIN { @ARGV = map glob, @ARGV}
    or some variations of it in oneliners and rarely in scripts too. The result is more portable: using the perl glob instead of that offered by the shell. That said windows cmd is totally unreliable, infact * expansions works as expected but within few commands only:
    Wildcards are supported by the following commands: ATTRIB, CACLS, CIPER, COMPACT, COPY, DEL, DIR, EXPAND, EXTRACT, FIND, +FINDSTR, FOR, FORFILES, FTP, ICACLS, IF EXIST, MORE, MOVE, MV, NET (* +=Any Drive), PERMS, PRINT, QGREP, REN, REPLACE, ROBOCOPY, ROUTE, TAKE +OWN, TYPE, WHERE, XCACLS, XCOPY

    as explained in details on this external site

    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.