You probably don't want to assing [] to @sub - that way the array doesn't become empty, but holds a single value, which is a reference to an empty array. Use @sub = () instead.
Also you'll probably want $graph[$i] = \@sub (no my before it. You're assigning to a part of an existing data structure, declaring a new variable doesn't make sense in that context).
Also please read perllol, which talks about arrays of array references.
In reply to Re: Writing an array inside an array
by moritz
in thread Writing an array inside an array
by talha099
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |