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

Basic debugging checklist

by toolic (Bishop)
on Feb 23, 2009 at 00:06 UTC ( #745674=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    use diagnostics;
    
  2. or download this
    warn "$var\n";
    print "@things\n";   # array with spaces between elements
    
  3. or download this
    chomp $var;
    print ">>>$var<<<\n";
    
  4. or download this
    my $copy = $str;
    $copy =~ s/([^\x20-\x7E])/sprintf '\x{%02x}', ord $1/eg;
    print ":$copy:\n";
    
  5. or download this
    use Data::Dumper;
    print Dumper(\%hash);
    print Dumper($ref);
    
  6. or download this
    print ref $ref, "\n";
    
  7. or download this
    $ perl -MO=Deparse -p program.pl
    
  8. or download this
    open my $fh, '<', 'foo.txt' or die "can not open foo.txt: $!";
    
  9. or download this
    if (system $cmd) {
        print "Error: $? for command $cmd"
    ...
        print "Command $cmd is OK"
    }
    $out = `$cmd`; print $? if $?;
    
  10. or download this
    eval { do_something() }; warn $@ if $@;
    
  11. or download this
    use Carp qw(cluck);
    cluck("var is ($var)");
    
  12. or download this
    $ perl -MCarp::Always program.pl
    
  13. or download this
    # what the heck does /^\s+$/ mean?
    use YAPE::Regex::Explain;
    print YAPE::Regex::Explain->new('/^\s+$/')->explain();
    
  14. or download this
    use WWW::Mechanize;
    if ($mech->success()) { ... }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://745674]
help
Chatterbox?
[stevieb]: choroba my GPS home device is done, at least prototype v1 is. I'm just making sure all of my code does what it says now
[stevieb]: I test/prototype code on my Pi, then I migrate it over to Arduino when it's ready (if that's a better platform for what I'm doing). The whole RPi stuff was for learning at first, then it snowballed. I'm just trying to get my in-house CI...
[stevieb]: ...done, which obviously requires a specific hardware setup.
[stevieb]: I don't write tests for the lower-level distributions (ie. ICs, sensors etc) within those distributions, I have all tests in a master distribution which encompasess all of the sub-modules

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2017-06-25 22:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (572 votes). Check out past polls.