From: "Michael Marziani" <[EMAIL PROTECTED]>

> I have an array @exclude_dirs that I want my list of directories matched
> against, and if it matches, then I want to go on to the next one.  I
> thought I saw someone do something like:
>  
> if( $line =~ /@exclude_dirs/ ) {
>     next;
> }

Well ... if the @exclude_dirs contains just the names of directories 
to skip, you do not need to use regexps at all, you may create a 
hash with the directories as the keys and then just tet whether a 
directory exists in the hash:

        %exclude_dirs = {
                foo => 1,
                bar => 1,
                baz => 1,
        };

        # or @exclude_dirs{@exclude_dirs} = ();
        # if you have the list in @exclude_dirs already

        while (...) {
        ...
                if (exists $exclude_dirs{$line}) {
                        next;
                }
        ...

If the @exclude_dirs contains regexps you might try something 
like this:

        $exclude_dirs = join '|', @exclude_dirs
        $exclude_dirs = qr/^(?:$exclude_dirs)$/; #compile the regexp

        while (...) {
        ...
                if ($line =~ /$exclude_dirs/) {
                        next;
                }
        ...

HTH, Jenda

=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
                                        --- me
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to