siddheshsawant has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks, I was trying to print the contents of array which was referenced.The code is given below

$desc_ref = \@description."\n"; print"Description =".$$desc_ref[$i]."\n";

And I am getting empty array as a output.Kindly let me know how to print contents of the array @description in this case

Thanks in advance !!!

Replies are listed 'Best First'.
Re: printing content of referenced array
by ikegami (Patriarch) on Mar 23, 2010 at 17:40 UTC

    Start by using use strict; use warnings;. It'll point out that $desc_ref doesn't contain a reference. (."\n"???)

Re: @ printing content of referenced array
by toolic (Bishop) on Mar 23, 2010 at 17:42 UTC
    $desc_ref = \@description."\n";
    Get rid of the newline:
    $desc_ref = \@description;
    Data::Dumper is extremely helpful:
    use Data::Dumper; print Dumper($desc_ref);
Re: @ printing content of referenced array
by 7stud (Deacon) on Mar 23, 2010 at 18:03 UTC

    Did you take a wrong turn somewhere? This isn't a php forum, it's a perl forum.

    use strict; use warnings; use 5.010; my @numbers = (10, 20, 30); say "The numbers are: @numbers"; #The numbers are: 10 20 30 my $aref = \@numbers; say "The numbers are: @$aref"; #The numbers are: 10 20 30 say "One number is: @$aref[0]"; #10 say "Another number is: " . $aref->[2]; #30
    A reply falls below the community's threshold of quality. You may see it by logging in.