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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.