Re: Perl if statements evaluates wrongly if we use '=>' as operator



* praveen.kane@xxxxxxxxx wrote in comp.lang.perl.misc:
$count = 10;
print "Count value : 10 \n";

if ($count => 20) {
print "Count value is greater than 20 \n ";
}else {
print "Count value is less than 20 \n";
}

`perldoc perlop` says:

The "=>" operator is a synonym for the comma except that it causes its
left operand to be interpreted as a string if it begins with a letter
or underscore and is composed only of letters, digits and underscores.

It does not mean "equal or greater than". For that use "the greater than
or equal" `>=` operator.
--
Björn Höhrmann · mailto:bjoern@xxxxxxxxxxxx · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
.



Relevant Pages

  • Re: Continuation of string literals
    ... occur inside an underscore continued string. ... Yes perhaps my Icon vocabulary is not up to par ...
    (comp.lang.icon)
  • Re: Regex: deleting non-matching words
    ... is to remove all words that do NOT strt with an underscore and simply ... the end of the string. ... regex lazily chooses 0 and completes a match. ... the end-of-line just before \n. ...
    (comp.lang.perl.misc)
  • Re: string comparisons
    ... > type in what I think is the right string, it goes to the else part of ... This header is deprecated in favor of. ... underscore followed by either another underscore or an uppercase letter. ... Even if your compiler ...
    (comp.lang.cpp)
  • Re: If...Then...Else Statement Help
    ... To continue from one line to another, you need a space and an underscore: ... Or cboBranch = "Something Else" Then ... Note that to continue in the middle of a string, you need to end the string ... In the separate table with the branch names, add the region as well, so ...
    (microsoft.public.access.formscoding)
  • Re: Inconsistencies in KDC status messages formats
    ... As part of KDC status reporting, ... generated and incorporated into log messages to be recorded in KDC log ... "ANONYMOUS NOT ALLOWED" (all upper case without underscore) ... The logical thing would be to make the string status messages more ...
    (comp.protocols.kerberos)