in reply to How to return a two dimensional array from a function in Perl?

For the problem at hand, you could modify a copy of the 2-D array if you replace the initial line of your sub with these four lines:
sub add_edge { my @graph; for ( @_ ) { push @graph, [ @$_ ]; } ...
(But I would be inclined to add some checks, and Carp if the input list is empty or includes anything that isn't an array ref.)
  • Comment on Re: How to return a two dimensional array from a function in Perl?
  • Download Code

Replies are listed 'Best First'.
Re^2: How to return a two dimensional array from a function in Perl?
by gunners.newark (Initiate) on Nov 03, 2008 at 16:47 UTC
    Thanks a lot graff. That really helped.