Help for this page

Select Code to Download


  1. or download this
    my($ret) ||= foo();
    
  2. or download this
    1.  my ($ret);       # Create a scalar variable called $ret
    2.  $ret ||= foo()   # If $ret is undefined or zero, assign it to foo(
    +)
    
  3. or download this
    my($ret) = $ret || foo();
    
  4. or download this
    
    use strict;
    ...
    
    my $x = $x || 5;
    print "Now x = $x\n";
    
  5. or download this
    Now x = 5
    
  6. or download this
    Global symbol "$x" requires explicit package name at test.pl line 5.
    Execution of test.pl aborted due to compilation errors.
    
  7. or download this
    use strict;
    use warnings;
    ...
    
    $x = $x || $y;
    print "Now x = $x\n";
    
  8. or download this
    
    use strict;
    ...
    
    $x ||= $y;
    print "Now x = $x\n";
    
  9. or download this
    Now x = 7