Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: RFC: Basic debugging checklist (updated)

by toolic (Bishop)
on Feb 19, 2009 at 18:19 UTC ( #745150=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @righteous_monks= qw(
            GrandFather tye YourMother kyle Tanktalus
            JavaFan jplindstrom rcaputo roho
            bart ELISHEVA tilly gwadej        # from the CB
    );
    
  2. or download this
    use strict;
    use warnings;
    use diagnostics;
    
  3. or download this
    warn "$var\n";
    print "@things\n";   # array with spaces between elements
    
  4. or download this
    chomp $var;
    print ">>>$var<<<\n";
    
  5. or download this
    my $copy = $str;
    $copy =~ s/([^\x20-\x7E])/sprintf '\x{%02x}', ord $1/eg;
    print ":$copy:\n";
    
  6. or download this
    use Data::Dumper;
    print Dumper(\%hash);
    print Dumper($ref);
    
  7. or download this
    print ref $ref, "\n";
    
  8. or download this
    $ perl -MO=Deparse -p program.pl
    
  9. or download this
    open my $fh, '<', 'foo.txt' or die "can not open foo.txt: $!";
    
  10. or download this
    if (system $cmd) {
        print "Error: $? for command $cmd"
    ...
        print "Command $cmd is OK"
    }
    $out = `$cmd`; print $? if $?;
    
  11. or download this
    eval { do_something() }; warn $@ if $@;
    
  12. or download this
    use Carp qw(cluck);
    cluck "var is ($var)";
    
  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: note [id://745150]
help
Chatterbox?
[Discipulus]: tozzetti & vinsanto
[Lady_Aleena]: The whole line is push @line, ref($list_addition ) ? @$list_addition : $list_addition if $list_addition;
[Lady_Aleena]: And I forgot to do the array check, I'm such a doofus today.
[Lady_Aleena]: push @line, ref($list_addition ) eq 'ARRAY' ? @$list_addition : $list_addition if $list_addition; #trying again
[shmem]: Discipulus: yummy. I like those. Didn't have them for some time now, forgot the name. Should go get some...
[shmem]: Lasy_Aleena: correct, although for clarity I'd use an if() block, not a statement modifier
[shmem]: this allows you to add an else if maintainance makes it neccesary
[Lady_Aleena]: shmem, okeydokey.
[shmem]: ...or logging or debugging or such

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2017-04-27 11:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (504 votes). Check out past polls.