
abcperl
New User
Mar 27, 2010, 6:34 AM
Post #1 of 5
(435 views)
|
|
Subroutines questions
|
Can't Post
|
|
Hi, i'm trying to understand some code which I have to modify. I've been going through some tutorials, but can't figure out, how this function/subroutine works (sorry if I'm not using the proper perl terms yet, but i'm learning ;) So I have this function:
sub createWorkSheet($,$,$,$,@) { my ($excel, $db, $value, $speed, $ascd, $session, $time, $id, @tArray) = @_; my @time_start = @$time; my @ids = @$id; ... } which is called by the following line:
my %Results = &createWorkSheet($excel, $db, $value, $speed, $ascd, $session, \@time, \@id, @tArray); Here my questions: - The subroutine is called with 9 different arguments, but in the declaration of &createWorkSheets we have just five arguments (four scalars and an array). I don't understand why this is still working. I am aware that _@ represents the array of arguments passed to the subroutine. - What do the backslashes in \@time and \@id are for? - Why are the arguments \@time and \@id are passed as arrays and are transformed to the scalars $time and $id? - And why are scalar values transformed back to arrays with this lines: my @time_start = @$time; my @ids = @$id; ? Thank you for your help. Also If you can give me some good sources to read about the topics of this questions, that would be great! 123perl
|