in reply to Re: Confused by a couple of idioms
in thread Confused by a couple of idioms

Here this construction is equivalent, but variation with 'and' ends up as an expression and can be used further. E.g.,  print( $xls = $csv if $csv ); cause a syntax error, but with 'and' - don't.

Also it is worth to mention that an alternative for "if( xxx ){ yyy }" one can use "xxx and do { yyy };" (with semicolon if it is the end of sentence; 'do BLOCK' in do docs)

Replies are listed 'Best First'.
Re^3: Confused by a couple of idioms
by bliako (Abbot) on Feb 22, 2019 at 11:36 UTC

    slight problem I see here (for me at least) is the use of && in *nix, in conditional execution, e.g. ls abc && grep aaa abc. You mentioned that && may not do what one intends. Do you have an example where && does not do what intended? thanks, bliako

      The higher precedence of && can be illustrated by the difference between these two:

      $ perl -E '$foo = 1 && $bar = 3; say $foo' 3 $ perl -E '$foo = 1 and $bar = 3; say $foo' 1

      This is why the word operators ( and or not ) should generally be used for control flow instead of the high-precedence symbolic operators ( && || ! ). HTH.

        got it thanks.