Help for this page

Select Code to Download


  1. or download this
    @bar = (1,2,3) unless @bar;
    
  2. or download this
    $bar ||= (1,2,'x');
    print $bar, "\n";
    
  3. or download this
    my ($a, $b);
    ($a, $b) ||= ('a', 'b', 'c'); # $a unchanged, $b <- 'c'
    ($a, $b) ||= (1, 2, 3); # $a unchanged, $b unchanged
    $b = (1, 2, 'x'); # $b <- 'x'
    $a ||= (3, 4, 5); # $a <- 5
    
  4. or download this
    ($a, $b) = (7,8,9); # $a <- 7, $b <- 8