in reply to Re: Understanding variable scope in perl
in thread Understanding variable scope in perl

Try changing that || die to or die. It has to do with operator precedence (perldoc perlop for more info).

Replies are listed 'Best First'.
Re^3: Understanding variable scope in perl
by liverpole (Monsignor) on Sep 29, 2005 at 19:31 UTC
    I know what you're saying, but I don't believe it matters here.   Try commenting out either Dying(3) or Dying(4) below...
    #!/usr/bin/perl -w # Strict use strict; use warnings; # Assign $x my $x = 123; # Next 2 lines prove $x is defined. defined $x or die "Dying(1) because (defined \$x or die)\n"; defined $x || die "Dying(2) because (defined \$x || die)\n"; # Make $x undefined undef $x; # Doesn't matter which of the next 2 lines is commented-out (either wo +rks fine) defined $x || die "Dying(3) because (defined \$x || die)\n"; defined $x or die "Dying(4) because (defined \$x or die)\n";