[mplspm]: Howto do switch with fall-through
Dan Oelke
Dan at oelke.com
Fri Aug 30 11:02:28 CDT 2002
Ahhhhhh - that is what I love about you guys. Always another way to do
it. I really like this solution. Especially since I'm going to have from
10-20 "phases" and this scales up much easier.
Thanks a million!
Dan
>Since you have well defined phase names you could do something like this:
>
>my %phase = ('Default',0,'Deliver',1,'Baseline',2,'Rebase',3,'Build',4);
>my @funcs = (\&default,\&deliver,\&baseline,\&rebase,\&build);
>
>
>
>my $onlyFlag = 0;
>$_ = $ARGV[0];
>
>for (my $i = $phase{$_} || $phase{'Default'}; $i < @funcs; $i++) {
> $funcs[$i]();
> last if $onlyFlag || !$i;
>}
>
># subs
>sub default {
> print "Default\n";
>}
>sub deliver {
> print "Deliver\n";
>}
>sub baseline {
> print "Baseline\n";
>}
>sub rebase {
> print "Rebase\n";
>}
>sub build {
> print "Build\n";
>}
>
>
>Eric
--------------------------------------------------
Minneapolis Perl Mongers mailing list
To unsubscribe, send mail to majordomo at pm.org
with "unsubscribe mpls" in the body of the message.
More information about the Mpls-pm
mailing list