[Kc] subroutine parameter list

Frank Wiles frank at wiles.org
Wed Apr 9 10:38:34 PDT 2008


On Wed, 09 Apr 2008 13:14:33 -0400
James Carman <developer at peelle.org> wrote:

> Hey all,
> 
> Is it possible to do something like:
> 
> 
> &param_test("somestring", "another_string" $arrayref);
> 
> sub param_test($tom; $george; @$array) {
>      print $tom;
>      ....;
> }

  Hi James, 

  You can do: 

  sub param_test ($$$) { 
     my ( $tom, $george, $array_ref ) = @_; 

  } 

  That will ensure that three scalars are passed in.  However, using
  subroutine parameter checking like this isn't considered a best
  practice. 

  Check out the Prototypes section of 'man perlsub' if you want
  more info on it. 

 -------------------------------------------------------
   Frank Wiles, Revolution Systems, LLC. 
     Personal : frank at wiles.org  http://www.wiles.org
     Work     : frank at revsys.com http://www.revsys.com 



More information about the kc mailing list