Re: general subroutine question



Derek B. Smith wrote:
Is there a commonly known way or method to limit the
number of arguments that a subroutine can store or pass?

You could kinda do that with prototypes, but that's not really a good
idea.

But subroutines are called by programs. The best way to limit what
happens is to write the limits into the code (for example, if you pass
an array to a sub but don't want to pass a huge array, pre-validate the
array's size before passing it to the sub).

--
David Filmer (http://DavidFilmer.com)

.



Relevant Pages

  • Re: Replacing a line
    ... #Using core module Tie::File to process a file in this subroutine ... sub process_one_file { ... $cpp_file = shift; ... for (@array) #Each line should come one by one ...
    (comp.lang.perl.misc)
  • Passing an array as Object
    ... I'm trying to write a subroutine that will fill an array of some type with several objects of that type. ... Private MyObjectsAs SomeObjectType ... Public Sub somemethod() ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Prototypes/Parameters to a Function/Sub-Routine
    ... That is supposed to be the idea behind subroutine prototypes, ... sub printScalar(my $num) ...
    (comp.lang.perl.misc)
  • Re: Passing an array section
    ... call SUB, N) ... subroutine SUB ... why am I not getting the array sections? ... compiler error. ...
    (comp.lang.fortran)
  • RE: Using array from subroutine
    ... Subject: Using array from subroutine ... sub open_file { ... die "Could Not Open $file: ... @lines is an empty array when the second subroutine is called. ...
    (perl.beginners)