http://www.perlmonks.org?node_id=997173


in reply to Problem printing return value from a subroutine

induced() returns a list flattened from an array. my $qw=induced(@{ $subgraphs[$d-1] }); evaluates that return value in scalar context. If you want to return a scalar, you should join the elements of the array. If you want to return a list, you need to capture it as an array or something which provides list context.


Improve your skills with Modern Perl: the free book.

Replies are listed 'Best First'.
Re^2: Problem printing return value from a subroutine
by zing (Beadle) on Oct 04, 2012 at 08:10 UTC
    But the problem chromatic is this :-
    component 2 = e d induced=3 component 1 = c b a b c a induced=3
    For component 2 (e d),, there shouldn't be any return value,as there is no line in data which has these vertices. Whereas for component 1(c b a), the first line of data file (b c a) should be returned.