in reply to Re^6: Writing an array inside an array
in thread Writing an array inside an array

print "$graph";

There's no $graph variable in that scope. Did you mean @graph instead?

You define a useless my $graph variable in the loop header, but that only exists until the end of the block.

Replies are listed 'Best First'.
Re^8: Writing an array inside an array
by talha099 (Initiate) on Nov 18, 2010 at 16:13 UTC
    Thank you very much again for your help.
    Actually, I was trying to store the array in the form:
    my $graph = [ 1, 2, 14 , 2, 3, 18 ];
    I wanted to pass $graph to another function which expects the input in that form. Would you recommend me using $graph or @graph?
    Thanks again.
      Would you recommend me using $graph or @graph?

      Use the @ sigil. It gives you several advantages: it behaves sensibly in scalar context, and the syntax for working with it less convoluted than reference syntax.