On 14 May 2002, at 16:40, Philip Morley wrote:
> The O'Reilly books don't really cover this subject, and I'm having
> difficulty figuring out how to do so. The script:
>
> sub printarray {
>
> my @array = @_;
> my $i;
>
> foreach $i (@array) {
> print "$i\n";
> }
>
> }
>
> my @flintstones = qw(fred, wilma, pebbles);
> printarray(\@flintstones);
>
The subroutine you've written takes an array, not a reference to an
array.
To call it use printarray(@flintstones); alternatively recode it as
Sundara Rajan suggests to take a reference to an array. Note
there is no real need to use a reference in this case, it might be
faster, I don't know.
Personally, I only use references to arrays when more than one
must be passed to a subroutine.
> prints ARRAY(0xb92e98), which I guess is the memory address of
> @flintstones. But I'd like to print the contents of the array. Probably a
> straightforward thing to do, but I have RTFM and still don't know how. Any
> suggestions?
>
> Thanks,
>
> Phil Morley
>
>
>
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
--
The information in this e-mail is for use by the addressee(s) only. If you
are not the intended recipient, please notify us immediately and delete the
message from your computer. No liability or responsibility is accepted for
viruses and it is your responsibility to scan attachments (if any).
Opinions and views expressed in this email are those of the sender and
do not reflect the opinions and views of antenova Ltd.
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs