That does the first line in function:

   my($what, @array) = @_;

That puts to $what the first parameter passed to function and to @array the rest of parametres..in this case @names. So you have a copy of @names in @array. But I am begginer too, so maybe i undersand it wrong;-) And for begginings, I reccomend O'Reilly's Llama Book...
Good luck with perl
Jirka

Joseph Mwesigwa Bbaale wrote:
Hello,

I am a complete beginner - no programming background.
I want to begin with Perl and I decided to by Randal's book "*Learning Perl*".
I seem to have been progressing smoothly till when I arrived at the code
below on page 65.

my @names = qw/ tom fred dan betty roy /;
my $result = &which_element_is("dan" @names);

sub which_element_is {
    my($what, @array) = @_;
    foreach (0..$#array) {
        if ($what eq $array[$_]) {
            return $_;
        }
    }
    -1;
}

The author states or seems to imply that, "... *...@array* is a copy of 
*...@names
*"! But I don't understand how and why this is so.
I am stuck.
Please, can someone help and explain to me how and why *...@array* is a copy of
*...@names?
*
Thanking you in advance.

Kind Regards,

Joe.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to