+1, though I assume there'd be a check to make sure the values are actually
valid?  Presumably that's why there's a if/elsif tree of values it's
expecting.  I didn't see a final "else" for handling all other unexpected
values, so maybe that wasn't being checked, but then you'd have a problem
where $school is undefined when an unexpected value is passed in.  That may
have been included in the "#Some lines snipped out" though.

On Fri Dec 20 2013 at 11:13:58 AM, Lance A. Brown <la...@bearcircle.net>
wrote:

> On 2013-12-20 10:45 am, Brandon Allbery wrote:
> > Actually Switch is considered rather bad.
> >
> >> #Okay lets setup the school variable
> >> #For sanity lets make sure we got the correct variable from the
> >> script
> >> print "$ARGV[0]n";  #this prints the correct variable
> >> if  ($ARGV[0] == "rc") {$school = "rc"} #This line is the only line
> >> evaluated. I always get this value
> >>         elsif ($ARGV[0] == "bp") {$school = "bp";}
> >
> > (...)
> >
> > This looks rather a lot like `$school = $ARGV[0];` or maybe `$school =
> > shift;`.
>
> This!  Very much this.
>
> if all those comparisons are of the form:
>
>    if $ARGV[0] == "X") {$school = "X";}
>
> and none of them do
>
>    if $ARGV[0] == "X") {$school = "Y";}
>
> then just assign
>
>    $school = $ARGV[0]
>
> No need for that big ugly "switch" statement.
>
> --[Lance]
>
> _______________________________________________
> 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/
>
_______________________________________________
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