in reply to dereferencing array in a subroutine

Here is an annotated version of your code to try and demonstrate the issue:
#!/usr/bin/perl use strict; # Great start! my @sample=qw(a,b,c); # Declare array variable &trial(\@sample); # Pass array as a reference to sub sub trial { @sample=@_; # Clobber the contents of your origina +l array # setting the original array to the co +ntents # of the special array (@_), which jus +t has # a reference print join("\t",@$sample); # Try to dereference a scalar variable + named # 'sample', which you never declared. }

use strict and warnings... warnings would also show another issue with your use of qw. Here is an improved version:

#!/usr/bin/perl use strict; use warnings; my @sample = qw(a b c); trial(\@sample); sub trial { my ($aref) = @_; print join "\t", @{ $aref }; }

See also References quick reference