I am working on some code that performs several tasks. Some of the items for
the tasks have exceptions.
I have been working on creating data structures to handle these exceptions.

I have been doing pretty well so far with speed (cpu), space (ram) and
non-repeating loops. But I am stumped on my current problem.
Please keep in mind this program is 2000+ lines of perl which have 20+
subroutines and that's not even including the 4+ custom modules with more
subroutines.

So I am going to give you my problem and the only solution (which is not
good enough for me) that I know.

__CODE__

## this is a structure that contains the exceptions
our %except = (
        "test1" => [ "stuff to add" ],
        "test2" => [ "more stuff to add" ]
        # etc. for about 4 or 5 more
        );

## [snip to later in the code to some subroutine working]

FILE: foreach my $file ( @arrayOfManyManyFiles ){

        ## deal with exception first which doesn't occur often
        ## this is the slow solution but I need to use the keys of %except
as a regex
        foreach my $test (keys %except) {
                if($file =~ /$test/){
                        # do stuff with @{ $except{$test} }
                        next FILE;
                }
        }
        
        ### does work to other files that weren't an exception
}

__END__

Any ideas on how to work around recompiling /$test/ every time? AND
to get around going through the foreach my $test so many useless times?


Thanx in advance,
Nikola Janceski

A sudden bold and unexpected question doth many times surprise a man and lay
him open.
-- Francis Bacon


----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to