Help for this page

Select Code to Download


  1. or download this
    sub test_function {
        my $ref = shift;    # this function takes one argument, a ref to a
    +n ARRAY
    ...
        # Not necessarily recommended: shown for educational purposes.
        defined($ref) or die "oops: you did not pass any arguments";
        @_ and die "oops: this function takes exactly one argument";
    
  2. or download this
    use strict;
    use warnings;
    ...
       test_function(undef);
    };
    say $@;
    
  3. or download this
    X:\>perl foo.pl
    Calling test_function with no arguments:
    ...
    
    
    X:\>
    
  4. or download this
    use strict;
    use warnings;
    ...
       test_function(undef);
    };
    say $@;
    
  5. or download this
    X:\>perl foo.pl
    Calling test_function with no arguments:
    ...
    
    
    X:\>