If you've got 150 if/elsif conditions I'd suggest taking a step back and rethinking the design. A dispatch table might be a more elegant solution.
Secondly, I'm not sure how much your data in @act_bsites varies, but from the example you posted it looks like you could generate this on the fly with a few parameters. For example:
use strict; use warnings; use Data::Dumper; my %foodata = ( 'foo1' => { thirdpart => 229, size => 3 }, 'foo2' => { thirdpart => 218, size => 7 } ); foreach my $foo qw( foo1 foo2 ) { my @act_bsites = map { join( ' - ', $_, 201, $foodata{$foo}{thirdpart +} ) } 1 .. $foodata{$foo}{size}; print Dumper( \@act_bsites ); }
Finally, to actually answer your question, yes. You can put the data and/or the conditions into a separate file. See use, do, and eval (then there's the OO approach...).
I apologize for being a bit on the vague side, but I'd rather understand the problem a little better before jumping in and recommending a complete solution.
Update following the update to the OP:
A database comes to mind, but that might be overkill. If so, I'd suggest putting the data into 150 separate files. Use a simple lookup mechanism (e.g., a hash) to determine the appropriate path/filename for a given input (e.g., 'foo1'), then use a single routine (which takes the path/filename as a parameter) to read in the data. If your data sets are small, you could put them all into one file, as GrandFather suggested.
In reply to Re: Accessing Large Else-If Condition in a Separate Files
by bobf
in thread Accessing Large Else-If Condition in a Separate Files
by neversaint
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |