Hello karthiknix,

Sample of your code using strict and warnings as haukex correctly pointed out.

#!/usr/bin/perl use strict; use warnings; use Data::Dumper qw(Dumper); my @examples = ('perl', 'linux'); my $reference_of_example = \@examples; #referencing print Dumper your_sub($reference_of_example); # prints $VAR1 = 1; print Dumper my_sub($reference_of_example); print Dumper my_solution($reference_of_example); print Dumper haukex_solution($reference_of_example); sub your_sub { my $ref = @_; return $ref; } sub my_sub { return @_; } sub my_solution { my $ref = shift @_; return $ref; # or return shift @_; } sub haukex_solution { my ($ref) = @_; return $ref; } __END__ $ perl test.pl $VAR1 = 1; $VAR1 = [ 'perl', 'linux' ]; $VAR1 = [ 'perl', 'linux' ]; $VAR1 = [ 'perl', 'linux' ];

Update: Adding haukex solution.

Hope this helps.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re^2: Passing a hash byreference to a subroutine by thanos1983
in thread Passing a hash byreference to a subroutine by edimusrex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.