Sorry to beat a dead horse but...

"switch" (or case or any variation) is not a great way to validate
input.  It means you need to update code every time the list changes.
It is better to put all the valid input into an array and check
against that.  If all code refers to the array, all code will be
updated any time the list changes.

Here's how to check if something appears in a Perl array:
http://stackoverflow.com/questions/720482/how-can-i-verify-that-a-value-is-present-in-an-array-list-in-perl

Here's how I'd rewrite the code:

print "$ARGV[0]\n";  #this prints the correct variable
$code = $ARGV[0];
@schoolcodes = qw(rc bp ac ce ng jh hu fj lc lf md oh ar sh wc aw jc jp);

# This requires Perl 5.10
#$school = 'ERROR';
#$school = $code if $code ~~ @schoolcodes;

# This works on older Perl:
if (grep{$_ eq $code} @schoolcodes) {
   $school = $code;
} else {
   $school = 'ERROR';
}
_______________________________________________
Tech mailing list
Tech@lists.lopsa.org
https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech
This list provided by the League of Professional System Administrators
 http://lopsa.org/

Reply via email to