SPUG: Variable in subroutines to check number of args?

Tim Maher tim at consultix-inc.com
Wed Jul 12 14:10:34 PDT 2006


On Wed, Jul 12, 2006 at 01:59:56PM -0700, John Costello wrote:
> 
> Is there a variable available within subroutines that tells how many 
> arguments were passed to the subroutine?  I haven't found such a var 
> through web searches or browsing my perlcd3.
> 
> Thanks,
> 
> John

You can use the following to load a variable with what you want:

   my $argc = @_; # get #-of-elements from @_ (sub-argument) array

-Tim
*-------------------------------------------------------------------*
|  Tim Maher, PhD  (206) 781-UNIX   (866) DOC-PERL  (866) DOC-UNIX  |
|  tim at ( Consultix-Inc, TeachMePerl, or TeachMeUnix ) dot Com    |
*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*
| UPCOMING CLASSES; 9/18: UNIX/Linux Fundamentals  10/9: Basic Perl |
|  Watch for my Aug '06 book: "Minimal Perl for UNIX/Linux People"  |
|  See MinimalPerl.com for details, ordering, and email-list signup |
*-------------------------------------------------------------------*


More information about the spug-list mailing list