in reply to foreach in HoHoA problems
Also, if you haven't started using "perl -d" to run your script, it's time to learn about the perl debugger, so you can step through your code and check what is being assigned to your structure as it happens.use Data::Dumper; # add this near the top of your script: # ... now, down at line 383 (had been 382 before adding "use Data::Dum +per": SITEKEY: for $sitekey (sort {$a <=> $b } keys %{$matches{$fasta +seq}}) { print "\$matches{$fastaseq}{$sitekey} is:\n", Dumper( $matches{$fastaseq}{$sitekey} ); # add this SET: foreach $hit ( ... ) { # the above print statement used to be here
One other hint: if you're looking at data structure trouble at line 384 and you've lost your train of thought, your problem may be "fasta pasta" -- i.e. spaghetti code. (Sorry, couldn't resist.)
Try modularizing -- identify functions or code blocks that can be made fairly independent, put them into separate files that simply define subroutines, and put "require" statements into the main script to load those other files.
This will make it easier to test things, and so long as the different "modules" really function independently, you'll find it easier to focus your attention on the problem areas, because they will be smaller. The discipline of not using or altering global variables within subroutines (because the subs will be defined in separate source files), will do you good.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: foreach in HoHoA problems
by mdunnbass (Monk) on Oct 28, 2006 at 17:02 UTC | |
by mdunnbass (Monk) on Oct 28, 2006 at 17:15 UTC | |
by graff (Chancellor) on Oct 28, 2006 at 21:41 UTC |