Ratna_Ranjan has asked for the wisdom of the Perl Monks concerning the following question:
I want to pass an array into a subroutine and dereference it and print it in a particular format.Below is the code that I tried.
But the error i get is Gobal symbol "$sample" requires explicit package name at deref.pl line 9.
can someone plz explain me what is wrong in my code??and how to dereference the array and print the array elements with a tab between them??
#!/usr/bin/perl use strict; my @sample=qw(a,b,c); &trial(\@sample); sub trial { @sample=@_; print join("\t",@$sample); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: dereferencing array in a subroutine
by toolic (Bishop) on Oct 28, 2009 at 17:56 UTC | |
|
Re: dereferencing array in a subroutine
by almut (Canon) on Oct 28, 2009 at 17:46 UTC |