in reply to Re^4: Short form (ternary) if else
in thread Short form (ternary) if else
This prints:sub foo1 { print "Hello, World!\n"; } sub foo2 { print "Goodbye, World!\n"; } 1 ? foo1() : foo2(); 0 ? foo1() : foo2();
I think what you're confused about is still scope; like the if/else block in the original post, if you declare my $vxdg inside the ternary operator, it will fall out of scope before you try to access it again.Hello, World! Goodbye, World!
|
|---|