thor has asked for the wisdom of the Perl Monks concerning the following question:

What is wrong with this piece of code:
($failed = 1 and $failed_job = $1 and last LOOP) if ($2 eq "No" and $3 + eq "F")
Obviously, this is is a loop called LOOP. When I invoke perl with the -w switch, it tells me that it "found = in conditional, should be ==".

However, every "=" that I have in this line is meant to be an assignment (e.g. set the $failed variable to 1, set $failed_job to the failed job)

Thanx
thor

2001-03-03 Edit by Corion : Changed title, added <CODE> tags.

  • Comment on Why do I get a 'found = in conditional, should be ==' error ? (was: Am I smoking Crack?)
  • Select or Download Code

Replies are listed 'Best First'.
Re: Am I smoking Crack?
by Adam (Vicar) on Feb 15, 2001 at 06:12 UTC
    Yes.

    That is a great example of poor programing style. Remember, "White space is cheap" and then try something like:

    if( $2 eq "No" and $3 eq "F" ) { $failed = 1; $failed_job = $1; last LOOP; }
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Am I smoking Crack?
by MrNobo1024 (Hermit) on Feb 15, 2001 at 05:13 UTC
    You should just use a comma instead of the and operator:
    ($failed = 1, $failed_job = $1, last LOOP) if ($2 eq "No" and $3 eq "F +")