mabman2 has asked for the wisdom of the Perl Monks concerning the following question:
I have also tried changing the comparison operator to "eq" tried the match "=~", but it still won't work correctly.
Thanks in advance.
#!usr/bin/perl sub test { print "@_\n"; if (@_ == 1.0000) { print "entering loop 1\n"; $hashname = "hash1"; } elsif (@_ == 2.0000) { print "entering loop 2\n"; $hashname = "hash2"; } print "$hashname\n"; return ($hashname); } %hash1 = ( 1 => 1.1, 2 => 2.2, 3 => 3.3, ); %hash2 = ( 1 => 4.4, 2 => 5.5, 3 => 6.6, ); $hash = test(sprintf("%.4f", 2)); print $$hash{1}; exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IF statements not being evaluated as expected
by ikegami (Patriarch) on Dec 13, 2009 at 04:36 UTC |