Look how interesting:
$ perl -MData::Dumper -e 'print Dumper (do { 1 if $_ }) for undef, 0, +"0", ""' $VAR1 = undef; $VAR1 = 0; $VAR1 = '0'; $VAR1 = ''; $ perl -MData::Dumper -e 'print Dumper ($_ and 1) for undef, 0, "0", " +"' $VAR1 = undef; $VAR1 = 0; $VAR1 = '0'; $VAR1 = ''; $ perl -MO=Concise -e 'sub a { 1 if $_ } print a for undef, 0, "0", "" +' k <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 2 -e:1) v:{ ->3 3 <;> nextstate(main 2 -e:1) v:{ ->4 j <2> leaveloop vK/2 ->k a <{> enteriter(next->g last->j redo->b) lK/8 ->h - <0> ex-pushmark s ->4 - <1> ex-list lKM ->9 4 <0> pushmark sM ->5 5 <0> undef s ->6 6 <$> const[IV 0] sM ->7 7 <$> const[PV "0"] sM ->8 8 <$> const[PV ""] sM ->9 9 <#> gv[*_] s ->a - <1> null vK/1 ->j i <|> and(other->b) vK/1 ->j h <0> iter s ->i - <@> lineseq vK ->- f <@> print vK ->g b <0> pushmark s ->c e <1> entersub[t2] lKS/TARG,1 ->f - <1> ex-list lK ->e c <0> pushmark s ->d - <1> ex-rv2cv sK/128 ->- d <#> gv[*a] s ->e g <0> unstack v ->h -e syntax OK $ perl -MO=Concise -e 'sub a { $_ and 1 } print a for undef, 0, "0", " +"' k <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 2 -e:1) v:{ ->3 3 <;> nextstate(main 2 -e:1) v:{ ->4 j <2> leaveloop vK/2 ->k a <{> enteriter(next->g last->j redo->b) lK/8 ->h - <0> ex-pushmark s ->4 - <1> ex-list lKM ->9 4 <0> pushmark sM ->5 5 <0> undef s ->6 6 <$> const[IV 0] sM ->7 7 <$> const[PV "0"] sM ->8 8 <$> const[PV ""] sM ->9 9 <#> gv[*_] s ->a - <1> null vK/1 ->j i <|> and(other->b) vK/1 ->j h <0> iter s ->i - <@> lineseq vK ->- f <@> print vK ->g b <0> pushmark s ->c e <1> entersub[t2] lKS/TARG,1 ->f - <1> ex-list lK ->e c <0> pushmark s ->d - <1> ex-rv2cv sK/128 ->- d <#> gv[*a] s ->e g <0> unstack v ->h -e syntax OK
Conclusion: $_ and 1 and 1 if $_ is exactly the same thing. perl compiles it to the same bytecode.
[]s, HTH, Massa (κς,πμ,πλ)

In reply to Re^4: return if 0 by massa
in thread return if 0 by zigdon

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.