perl514 has asked for the wisdom of the Perl Monks concerning the following question:
Both produce the same result, the output is it prints out the word "this". What do I do if I want to print out the entire contents of one of the elements? I dont mean the whole four lines, but say, I just want to print out one line, how do I do that in case I have created an array of references or an array reference to a reference of arrays (whee, I'mgetting wordy here, and confused too)#!/usr/bin/perl use warnings; use strict; my @refarray1 = (qw[this is the first line], qw[Second one is here], qw[squint your eyes to see the third], qw[fourth is surely near],); print "$refarray1[0]\n"; my $refarray2 = [qw[this is the first line], qw[Second one is here], qw[squint your eyes to see the third], qw[fourth is surely near],]; print "$refarray2->[0]\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A question on array references.
by BrowserUk (Patriarch) on Dec 16, 2011 at 16:28 UTC | |
by perl514 (Pilgrim) on Dec 16, 2011 at 16:39 UTC | |
by BrowserUk (Patriarch) on Dec 16, 2011 at 16:52 UTC | |
by johngg (Canon) on Dec 16, 2011 at 16:55 UTC | |
by Eliya (Vicar) on Dec 16, 2011 at 16:49 UTC | |
|
Re: A question on array references.
by choroba (Cardinal) on Dec 16, 2011 at 16:32 UTC | |
|
Re: A question on array references.
by TJPride (Pilgrim) on Dec 16, 2011 at 16:53 UTC | |
|
Re: A question on array references.
by TomDLux (Vicar) on Dec 16, 2011 at 20:10 UTC | |
|
Re: A question on array references.
by perl514 (Pilgrim) on Dec 16, 2011 at 17:44 UTC |