Re: How do I pass arrays into a subroutine

2013-09-07 Thread Karol Bujaček
Hello, On 09/07/2013 02:15 PM, Dr.Ruud wrote: On 07/09/2013 13:43, Karol Bujaček wrote: print Dumper(@_);# just look how the @_ looks like Consider: print Dumper( \@_ ); I chose Data::Dumper::Simple

Re: How do I pass arrays into a subroutine

2013-09-07 Thread Shawn H Corey
On Sat, 07 Sep 2013 14:15:39 +0200 "Dr.Ruud" wrote: > On 07/09/2013 13:43, Karol Bujaček wrote: > > >print Dumper(@_);# just look how the @_ looks like > > Consider: print Dumper( \@_ ); > > > >my($animals, $digits) = @_; > > > >my @animals = @$animals; # dereference > >

Re: How do I pass arrays into a subroutine

2013-09-07 Thread Dr.Ruud
On 07/09/2013 13:43, Karol Bujaček wrote: print Dumper(@_);# just look how the @_ looks like Consider: print Dumper( \@_ ); my($animals, $digits) = @_; my @animals = @$animals; # dereference my @digits = @$digits; # dereference The comment is inaccurate. Why would

Re: How do I pass arrays into a subroutine

2013-09-07 Thread Karol Bujaček
On 09/07/2013 01:11 PM, eventual wrote: Hi, In the example below, how do I pass @pets and @numbers into the subroutine so that @animals = @pets and @digits = @numbers. Thanks my @pets = ('dogs' , 'cats' , 'horses'); my @numbers = (1..10); &study (@pets , @numbers); sub study { my (@animals

Re: How do I pass arrays into a subroutine

2013-09-07 Thread *Shaji Kalidasan*
- Your talent is God's gift to you. What you do with it is your gift back to God. --- From: eventual To: "beginners@perl.org&qu

Re: How do I pass arrays into a subroutine

2013-09-07 Thread Shlomi Fish
Hi Eventual, On Sat, 7 Sep 2013 04:11:06 -0700 (PDT) eventual wrote: > Hi, >   > In the example below, how do I pass @pets and @numbers into the subroutine so > that @animals = @pets  and > @digits = @numbers. Please look into references and pass the arrays as references. See: http://perl-beg

How do I pass arrays into a subroutine

2013-09-07 Thread eventual
Hi,   In the example below, how do I pass @pets and @numbers into the subroutine so that @animals = @pets  and @digits = @numbers. Thanks   my @pets = ('dogs' , 'cats' , 'horses'); my @numbers = (1..10);   &study (@pets , @numbers);   sub study {   my (@animals, @digits) = (@_[0] , @_[1]);