I've written two perl data debugging inspection functions that help my coding. While my perl code probably needs more help than I can give it, I'll let that slide for the moment.
I like Damian Conway's ideas regarding Huffman coding language, i.e. using short verbs for things you do all the time, and setting the tweakable defaults to the most common use case. With say() and look() below, we get two quick and dirty routines that know the context of the caller and just pass the data through accordingly.
sub say { my $line = join ' ', grep { defined $_ } @_ , "\n"; print $line; wantarray and return @_; # array defined wantarray and return $line; # scalar return; # void } sub look { require 'Data/Dumper.pm'; # load at runtime only if needed print Data::Dumper::Dumper(@_); wantarray and return @_; # defined wantarray and return $_[0]; return; }
my @lines = map { s/fish/yu2/ } say grep { /fish/ } `cat /etc/passwd`; my $complex = look make_foo_more_complex $$hash{$foo};