Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Accessing Large Else-If Condition in a Separate Files

by Zaxo (Archbishop)
on Jun 05, 2007 at 04:24 UTC ( [id://619296]=note: print w/replies, xml ) Need Help??


in reply to Accessing Large Else-If Condition in a Separate Files

You want a hash of arrays. That simplifies the logic and puts the data all in one place.

my %data = ( foo1 => [ '1 - 201 - 229', '2 - 201 - 229', '3 - 201 - 229', ], foo2 => [ '1 - 201 - 218', '2 - 201 - 218', '3 - 201 - 218', '4 - 201 - 218', '5 - 201 - 218', '6 - 201 - 218', '7 - 201 - 218', ], # . . . );
Then you can just say,
my @act_bsites = @{$data{$dataset}};
If the 1-150 ordering is natural and important, you may want to drop the 'foo' part of the designation and use an array instead of a hash.

Update: I don't understand how hardcoding the data in an extended if-else construct improves anything with respect to hard-won data. Here's a version with a seperate data file:

# file: /path/to/foosites { foo1 => [ '1 - 201 - 229', '2 - 201 - 229', '3 - 201 - 229', ], foo2 => [ '1 - 201 - 218', '2 - 201 - 218', '3 - 201 - 218', '4 - 201 - 218', '5 - 201 - 218', '6 - 201 - 218', '7 - 201 - 218', ], # . . . };
and then in your code it can be as simple as,
my @act_bsites = @{(do '/path/to/foosites')->{$dataset}};

After Compline,
Zaxo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://619296]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-23 15:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found