I'm trying to write a subroutine that takes two scalars and two arrays as parameters. I've read that if you try to do this in a function, both arrays will get combined within '@_'. Instead, I want the subroutine to take two scalars and two array references. I will not be doing any modification of the array data in the subroutine, so it will be more effecient this way, anyway. I vaguely remember reading in Learning Perl (or maybe Programming Perl) that the subroutine can be defined something like:

sub my_subroutine([EMAIL PROTECTED]@) {

}

My syntax may be off. Someone please correct me if so. (Do I really need to say this?) Now, how do I get those values in the subroutine?

sub my_subroutine([EMAIL PROTECTED]@) {
  my ($scalar1, $scalar2, $arrayref1, $arrayref2) = @_;
}

Another thing, how do you access an array through a reference? I know you access a hash through a reference by doing '$hashref->{hashkey}' instead of just '$hashref{hashkey}', but I've never done it with arrays (never needed to). One more thing (I promise). Do I need to do anything special to pass arrays as references to the function, like this:

my_subroutine $scalar1, $scalar2, [EMAIL PROTECTED], [EMAIL PROTECTED];

or can I pass them without the '\'? Sorry for all the questions in one post, but atleast they are all related :)

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to