Re: passing array ref to subroutine

2003-01-07 Thread R. Joseph Newton
Hi Paul, I think you're looking for: sub suby { $temp=$_[0]; print "$_[0]\n"; print "$$temp[0]\n"; } I'm not sure why. It seems like it should be print "$$_[0]\n";, but I believe the results I got from the interpreter. Output: ARRAY(0x1ab28e0) paul ARRAY(0x1ab28e0) paul Joseph Paul Kr

Re: passing array ref to subroutine

2003-01-06 Thread Paul Johnson
On Mon, Jan 06, 2003 at 04:29:41PM -0500, Paul Kraus wrote: > I don't understand why the output of the two print statements inside the > subroutine is different. The one only prints the new line. Hmm, I get "Use of uninitialized value in concatenation (.) or string at qw" for both. > #!/usr/bin/

RE: passing array ref to subroutine

2003-01-06 Thread Dan Muey
-Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 3:30 PM To: Perl Subject: passing array ref to subroutine Because the second one is printing the '0' item fo an array called 'temp' you need to do $$temp[0] the same as yo

RE: passing array ref to subroutine

2003-01-06 Thread Timothy Johnson
is the same as: ${$temp}[0] P.S. The same works for hashes. $temp->{key} accesses an element of the hash referenced by $temp -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 1:30 PM To: Perl Subject: passing array ref to subroutine I don

passing array ref to subroutine

2003-01-06 Thread Paul Kraus
I don't understand why the output of the two print statements inside the subroutine is different. The one only prints the new line. #!/usr/bin/perl -w @array=qw/paul david kraus/; $arrayref=\@array; print "$arrayref\n"; print "$$arrayref[0]\n"; &suby($arrayref); sub suby { $temp=$_[0]; p