Perl script help

Hi there,

I am trying to fix a bug in a Perl script.

Can someone explain what the below code does/would do?



while (my $a = readdir(DIR)){

    if($a =~ m/(.+?)_(air)?port/ && $a !~ m/featured_(air)?port/ && $a !~ m/london_airport/i && $a !~ m/glasgow/ && $a !~ m/_opt/i){

        push(@dirs,$a);

    }

}


Thanks

That code is reading all dirs and files in a certain directory
If file or dir matches any of those criteria, it is added to @dirs array.

You are not saying what error you are getting. The syntax is OK but is it that you have not done an opendir statement before.
For example: opendir(DIR, $some_dir)

Or is it that the matches are not picking up what you would expect to be picked up.