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

The file you've shown us doesn't even have 39 lines.

Either you've shown us the wrong script, or Graph::Matching does something really scary.

Replies are listed 'Best First'.
Re^6: Writing an array inside an array
by talha099 (Initiate) on Nov 18, 2010 at 13:44 UTC
    Yup, sorry I showed only a part of it
    Here is the complete script
    #!/usr/bin/perl BEGIN { push @INC,"C:/strawberry/perl/site/lib"; push @INC,"C:/strawberry/perl/vendor/lib"; push @INC,"C:/strawberry/perl/lib"; } use strict; use Graph::Matching; use Graph::Matching qw(max_weight_matching); my @sub = []; my @list = split(',', $ARGV[0]); #print("@list"); my $n = 0; my @graph = (); my $i = 0; my $j = 0; for ($i=0; $n<my $graph; $i++) { for ($j=0; $j<=2; $j++) { $sub[$j] = $list[$n]; $n++; } $graph[$i] = \@sub; @sub = (); } print "$graph";

    Thank you very much again!
      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.

        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.