> > 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: { > > /MA/ && do { > #do MA specific stuff > ..... > last SWITCH; > } # end do MA stuff > > /CI/ && do { > #do MA specific stuff > ...... > last SWITCH; > } # end do MA stuff > > ..... > > die "Mr Wizard the stateField $statefield unguarded"; > > } # end of switch > > } else { > # not in our state List > } There is only certain people that appeals to, not including myself. Those who like it should notice Damian Conway uses it in "Object Orientated Perl"... > this way as the @state list grows or shrinks the one simply > adds in one more switch statement.... 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 Remembering you can build your hash like: my %hash = ( state1 => sub { # Do something }, state2 => sub { # Do something } ); Jonathan Paton __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.comThread Previous | Thread Next