On Dec 18, 2007 10:08 PM, goldtech <[EMAIL PROTECTED]> wrote:

> Hi,
>
> If I have:
>
> ...
> foreach (@ARGV) {
>    print "do something only to .mdb files";
> }
>
> I could use File::Basename's fileparse and test for the file extension
> and put a big if statement around or in the foreach loop. So if a user
> puts a non .mdb file argument on the cmd line it won't process and
> prints a usage.
>
> But I suspect in perl theres a more compact way of doing that?

I don't think you need to use File::Basename.

You can simply do this.

foreach my $file (@ARGV) {
    if ( $file !~ /\.mdb$/ ) {
        print "$file is not a mdb file. Ignoring...\n";
        next;
    }

    # code to pocess .mdb file
    ...
    ...
}

-- 
Ankur

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to