in reply to Re^5: printing unitialized value of the 'do BLOCK'
in thread printing unitialized value of the 'do BLOCK'

There's no negation anywhere in that code. $x IS the last expression evaluated when $x is true.

Replies are listed 'Best First'.
Re^7: printing unitialized value of the 'do BLOCK'
by rsFalse (Chaplain) on Dec 18, 2019 at 22:50 UTC
    Thanks for pointing this out!
    I haven't tested much, only tested with plain '1'.
    my $x = 1; print "[$_]" for do{ unless( $x ){ 5 } }, do{ unless( 1 ){ 6 } }, ;
    Output:
    [1] []
      I'm getting [1][1] from the above code. What version of perl do you run?
      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
        $ for v in 30 28 26 24 22 20 18 16 14 12 10; do printf '5.%s: ' $v 5.${v}t/bin/perl a.pl done 5.30: [1][1] 5.28: -bash: 5.28t/bin/perl: No such file or directory 5.26: [1][1] 5.24: [1][1] 5.22: [1][] 5.20: [1][] 5.18: [1][] 5.16: [1][] 5.14: [1][] 5.12: [1][] 5.10: [1][]

        I think it's an unintentional change that resulted from fixing this.

      And there we go. The reason the value is only defined when the last statement is an expression.

        I thought that '1' is also expression.