Help for this page

Select Code to Download


  1. or download this
    my $square_this 
         = sub { my $x = shift; 
                 return $x**2; 
               };
    
  2. or download this
    sub square 
    { 
    ...
        return $x**2; 
    }
    my $square_this = \□
    
  3. or download this
    my $squared = $square_this->($hypotenuse);
    
  4. or download this
    package Square;
    sub square 
    ...
        my $x = shift; 
        return $x**2; 
    }
    
  5. or download this
    my $squared = square($hypotenuse);
    
  6. or download this
    my $squared = Square::square($hypotenuse);
    
  7. or download this
    use Square qw(square);
    my $squared = square($hypotenuse);
    
  8. or download this
    { # closure for cubed
    
    ...
      }
    
    } # end closure for cubed