Re: A Switch Case for multi-state returns.

2002-04-01 Thread Jonathan E. Paton
> > What if there is HUNDREDS of items, then > > it'd be really slow. For a better approach > > using hashes then see what I did in: > > > > http://groups.yahoo.com/group/perl-beginner/message/9583 > > The question that now comes to mind is why > not put all of the 'response functions' > into a P

Re: A Switch Case for multi-state returns.

2002-04-01 Thread drieux
On Sunday, March 31, 2002, at 07:07 , Jonathan E. Paton wrote: [..] I had not thought of the SWITCH case being one way or the other in the OO v. Proceduralists approach - but your proposition does present the problem - what is the tradeoff between 'runtime performance' and maintainability. >>

Re: A Switch Case for multi-state returns.

2002-03-31 Thread Jonathan E. Paton
> >If ( $data{$statefield} ) { > ># OR If ( $data{uc($rs->Fields('state')->value)} ) { > > # Process data > >} Arg! Don't do that nesting of the if!, use: if (condition1) { #action 1 } elsif (condition2) { #action 2 } else { #default } > SWITCH: { > >

Re: A Switch Case for multi-state returns.

2002-03-31 Thread drieux
>> ??- >> @state="MA CI DE IN OH"; let me try that another way - without the bugs: vladimir: 81:] perl Switch.pl MA CI bob OH Process Says: MA_response Process Says: CI_response we do not know about state bob Mr Wizard the stateField OH unguarded at Switch.pl line 41. vladimir: 82:] sed 's/^/##

A Switch Case for multi-state returns.

2002-03-31 Thread drieux
On Sunday, March 31, 2002, at 08:25 , Zeus Odin wrote: > #!D:\perl\bin\perl -w > use strict; > my %data; > > # fill in 11 other states > my @state = qw(MA CI DE IN OH); > @data{ @state } = (1) x @state; [..] >If ( $data{$statefield} ) { ># OR If ( $data{uc($rs->Fields('state')->value)} )