Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: Problem printing return value from a subroutine

by zing (Beadle)
on Oct 04, 2012 at 15:40 UTC ( #997251=note: print w/replies, xml ) Need Help??


in reply to Re^3: Problem printing return value from a subroutine
in thread Problem printing return value from a subroutine

Hi AM, I changed the code as per your suggestion
sub induced { my (@z) = @_; my $triplet = $trip[0]; my %Pie; undef @Pie{ @z }; delete @Pie{ @$triplet }; print "@$triplet\n" if keys(%Pie) <= (@z - @$triplet); return @$triplet; }
But the output is still far from wanted
component 2 = e d $VAR1 = 'b'; $VAR2 = 'c'; $VAR3 = 'a'; component 1 = c a b b c a $VAR1 = 'b'; $VAR2 = 'c'; $VAR3 = 'a';

Let me explain you what is wanted.Consider for example component 2. It has two vertices e,d. Now I want to see if any of the rows from "DATA" is a subset of these points.Now since each of the row of "DATA" has 3 vertices/points,therefore clearly for component two there isnt any induced line from DATA.Therefore there should be anything to print for the subroutine "induced" for this case.

But for component 1,which has vertices as = c,a,b; the first line of "DATA" which is "b c a" gets induced.

Similarly if component=a,b,c,d ; then first two rows of DATA get induced ,as they are both the subset of the component.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997251]
help
Chatterbox?
[Discipulus]: M4ver1k are you debug/dump vars in the loops? are you sure you are not quitting the loop earlier?
[Corion]: A good weekstart to everybody!
[Discipulus]: good morning nuns and monks! hello Corion

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2017-11-20 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (285 votes). Check out past polls.

    Notices?