in reply to Upper / Lower case extensions

The glob function can do that for you:

my @datafiles = grep { -f } glob("$basepath$ARGV[0]/$ARGV[1].{dat,DAT}");
Note that your program logic will change since there can be more than one file for a given pair of arguments.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Upper / Lower case extensions
by RMGir (Prior) on Jul 30, 2002 at 12:20 UTC
    Good one, Zaxo!

    If odd cases like Dat, dAt, and other such silliness might exist, you could also use:

    my @datafiles = grep { -f } glob("$basepath$ARGV[0]/$ARGV[1].{d,D}{a,A}{t,T}");
    But if you only have to deal with all upper or all lower case, Zaxo's answer is better.
    --
    Mike
      I suggest:
      my @datafiles = glob("$basepath$ARGV[0]/$ARGV[1].[dD][aA][tT]");

      It takes care of the special cases and eliminates the grep.

      Figuring out why it eliminates the grep is an exercise for the reader. :-) Hint: You might need to use man instead of perldoc. . .

      -sauoq
      "My two cents aren't worth a dime.";