Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hello,
I got a warning message "Found = in conditional, should be" after executing that code:
perl -wle 'my $has_even; @_ = -1 .. 9; for( @_ ){ print $_; $_ % 2 or +$has_even = 1 and last } print "\$has_even:[$has_even]"; '
OUTPUT:
Found = in conditional, should be == at -e line 1. -1 0 $has_even:[1]
Here '=' is intentional, so a warning is obsolete.
I think it is useful warning message to catch mistype. But in perlop operators 'and' and 'or' are not named being conditional. It is explained in other words (e.g. for 'and'): "the right expression is evaluated only if the left expression is true". In perlop document there is a section named "Conditional Operator", which is about ternary conditional operator. But it seems that it is not the only one conditional operator. So for clarity this section could be renamed to "ternary conditional operator". And also it could be added "a conditional operator" within description of 'and' and 'or'. Also a conditioness attribute could be shown in a widened attribute table (idea proposed in earlier node: For discussion: operator attributes - associativity, chainity and ability to short-circuit).

Back to a warning message. In my code instead of "$has_even = 1" it could be '$has_even = "TRUE"'. In that case a warning would seem even more obsolete because "TRUE" is not number-like.

In reply to Situation where warning "Found = in conditional, should be" seems obsolete by rsFalse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-29 11:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found