Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Contents of @_ using subroutine signatures with default values

by davido (Cardinal)
on Jul 13, 2020 at 22:22 UTC ( #11119273=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub baz ($this, $that) {
        warn '@_ contains ', scalar(@_), " elements.\n";
    }
    
    baz('hello', 'world') # @_ contains 2 elements.
    
  2. or download this
    sub foo ($this, $that = 'world') {
        warn '@_ contains ', scalar(@_), " elements.\n";
    }
    
    foo('hello'); # @_ contains 1 elements.
    
  3. or download this
    #!/usr/bin/env perl
    
    ...
    
    note "\n\nTesting foo()";
    foo("a");
    
  4. or download this
    1..8
    # 
    ...
    # Looks like you failed 2 tests of 8.
    
    shell returned 2
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11119273]
Approved by marto
Front-paged by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (None)
    As of 2021-10-17 14:46 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My first memorable Perl project was:







      Results (71 votes). Check out past polls.

      Notices?