Dalin has asked for the wisdom of the Perl Monks concerning the following question:

Hey all, Taking my first stabb at porting a script I wrote to win32. I'm running into some trouble globbing the file names I want. Here is my code:
use strict; no strict "refs"; use Mail::Sender; my $f2dir = "C:\\windows\\desktop\\tmp"; print $f2dir; my @names = <$f2dir\*.f2mail>; print @names;
I'm using ActiveState's port of Perl. The $f2dir comes across fine, but I get no output for the @names. Can someone tell me where I am going wrong? Thanks in advance, Bradley
Where ever there is confusion to be had... I'll be there.

Replies are listed 'Best First'.
Re: WIN32 File Globbing
by particle (Vicar) on Jun 29, 2001 at 18:05 UTC
    there's a bug in your code.
    my @names = <$f2dir\*.f2mail>;
    should read
    my @names = <$f2dir\\*.f2mail>; # or my @names = <$f2dir/*.f2mail>;

    ~Particle

Re: WIN32 File Globbing
by Graham (Deacon) on Jun 29, 2001 at 17:51 UTC
    You have no backslash between your directory variable and your filenames.
    Edit @names to read
    my @names = <$f2dir\\\*.f2mail>;
    or edit $f2dir to be
    my $f2dir = "C:\\windows\\desktop\\tmp\\";
Re: WIN32 File Globbing
by LD2 (Curate) on Jun 29, 2001 at 17:56 UTC
    I've tried your code and it worked with one modification. You want to change:
    my $f2dir = "C:\\windows\\desktop\\tmp";
    to:

     my $f2dir = "C:\\windows\\desktop\\tmp\\";

    It should work fine after that.
    Update:Oops, Graham beat me to it. :)