On Fri, Dec 20, 2013 at 10:39 AM, john boris <[email protected]> wrote:
> I have this perl script that I have a long if/elsif portion. I am porting
> a shell script to perl so I am trying to mimic a case statement from a
> shell script. I know I should use Switch but the version
>
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;`.
In any case, your problem is that `==` is numeric comparison. If you had
warnings turned on, as you always should, it would warn you that you were
using a non-numeric value in a numeric comparison.
`eq` is the string/lexicographic comparison operator.
--
brandon s allbery kf8nh sine nomine associates
[email protected] [email protected]
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________
Tech mailing list
[email protected]
https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech
This list provided by the League of Professional System Administrators
http://lopsa.org/