Help for this page

Select Code to Download


  1. or download this
    sub foo ($x) { say($x) }
    
  2. or download this
    sub foo ($x:) { say($x) }
    
  3. or download this
        sub foo($x, $y, $z) {...}    # expects three scalars
        @onetothree = 1..3;          # array stores three scalars
    ...
        foo(1,2,3);                  # okay:  three args found
        foo(@onetothree);            # error: only one arg
        foo(*@onetothree);           # okay:  @onetothree flattened to thr
    +ee args
    
  4. or download this
    sub perl6foo ($bar, $baz) { }
    
  5. or download this
    sub perl5foo { my ($bar, $baz) = @_; }