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

Re: Hash Uninitialized Values Error

by Anonymous Monk
on Dec 26, 2013 at 00:30 UTC ( #1068384=note: print w/replies, xml ) Need Help??

in reply to Hash Uninitialized Values Error

Well, I've run that code through perltidy to see what I can see, and that looks very much like something called spaghetti code ... its to hard to read for humans, to hard to fix for humans, me included

So my advice, if you want to solve your warning, start rewriting the program to work without goto

See Text Based Perl Game and especially the responses (and links in responses) for specifics

So in the end you write something like, something short, where the control-flow is easy to seee (birds eye view), no gotos :) no spaghetti

sub LHCC { DECISION: while( 1 ) { WelcomeMsg(); my $decision = GetDecision(); if( $decision =~ /quit/ ) { last DECISION; } elsif( $decision =~ /ready/ ) { GoDoReadyDecision(); } else { TryAgainMessage(); } } } ## end sub LHCC sub GoDoReadyDecision { my $no_statements = GetNoStatements(); ...; GetQPStatements( \%Statements ); ...; my( $conclusions, $o_conclusions ) = ConcludeConclusions( \%Statements, \%Contrapositives ... ); return $conclusions, $o_conclusions; } ## end sub GoDoReadyDecision sub ConcludeConclusions { my( $Statements, $Contrapositives ) = @_; while( my( $key, $value ) = each %$Statements ) { ...; } for my $key ( keys %$Contrapositives ) { my $value = $Contrapositives->{$key}; ...; } ...; return \@Conclusion, \@OtherConclusion; } ## end sub ConcludeConclusions

And when you get "use of unitialized ..." you can focus only on one small subroutine, you Data::Dump::dd( \@_ ) and can debug only this one small part

Good luck

Replies are listed 'Best First'.
Re^2: Hash Uninitialized Values Error
by slinky773 (Sexton) on Dec 26, 2013 at 01:33 UTC
    Thank you for the advice. Actually, I kind of didn't realize how bad my code was getting. I was just focused on the end product, since I was supposed to finish it by Christmas. Now I'll go back and make everything into subroutines, like I should have originally. Thanks.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1068384]
[erix]: infallibility breeds inquisition
[erix]: ( hm. that doesn't make sense really -- infallibility is a 19th century invention, the Inquisition quite a bit earlier )

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2017-01-17 23:56 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (159 votes). Check out past polls.