>> ??- >> @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/^/### /' Switch.pl ### #!/usr/bin/perl ### ### use strict; ### ### my %data; ### ### #fill in 11 other states ### my @state = qw(MA CI DE IN OH); ### ### #Make each element of @state a key of hash %data ### #@data{@state } = (1) x @state; ### %data = map { $_ => 1 } @state; ### ### my $response=''; ### ### foreach my $statefield (@ARGV) { ### ### # read in the args as states ### ### if ($data{$statefield} ) { ### # ### # Use a switch through ### # ### $_ = $statefield; ### SWITCH: { ### ### /MA/ && do { ### #do MA specific stuff ### $response='MA_response'; ### last SWITCH; ### }; # end do MA stuff ### ### /CI/ && do { ### #do CI specific stuff ### $response='CI_response'; ### last SWITCH; ### }; # end do MA stuff ### ### ### die "Mr Wizard the stateField $statefield unguarded"; ### ### } # end of switch ### ### print "Process Says: $response\n"; ### } else { ### print "we do not know about state $statefield \n"; ### } # end if statefield ### ### }# end foreach ### ### exit(0); vladimir: 84:]Thread Previous | Thread Next