Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: How can i debug compound map/grep statements just using print?

by tobyink (Abbot)
on Dec 01, 2012 at 18:34 UTC ( #1006625=note: print w/ replies, xml ) Need Help??


in reply to How can i debug compound map/grep statements just using print?

use strict; use warnings; { my $level = 0; sub reset_list_debug { $level = 0 } sub custom_list_debug (&@) { my $code = shift; print "==" x $level, $level ? "> " : '', join(q( ), map($code- +>($_), @_)), "\n"; $level++; return @_; } sub list_debug { custom_list_debug { "$_" } @_; } } my @letters = list_debug map { lc $_ } list_debug grep { /[AEIOU]/ } list_debug map { uc $_ } list_debug 'a'..'z'; reset_list_debug(); my @letters2 = custom_list_debug { qq("$_") } map { lc $_ } custom_list_debug { qq([$_]) } grep { /[AEIOU]/ } custom_list_debug { qq('$_') } map { uc $_ } custom_list_debug { qq( $_ ) } 'a'..'z'; reset_list_debug();
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re: How can i debug compound map/grep statements just using print?
Download Code
Re^2: How can i debug compound map/grep statements just using print?
by karlgoethebier (Vicar) on Dec 01, 2012 at 23:24 UTC

    I tried this:

    Karls-Mac-mini:find karl$ ./myFind.pl -a 1 -d . -s pl ./bar.pl ./benchmark.pdf ./foo.pl ./leftover.pl ./myFind.pl ./tobyink. +pl ==> ./bar.pl ./foo.pl ./leftover.pl ./myFind.pl ./tobyink.pl ====> 1354402483 1354402472 1354381750 1354402315 1354398126 ======> 1 1 ========> 1 1 Found 2 file(s)! Karls-Mac-mini:find karl$ ls -hlrt total 1408 -rw-r--r--@ 1 karl karl 684K 10 Nov 11:32 benchmark.pdf -rw-r--r-- 1 karl karl 58B 1 Dez 18:09 leftover.pl -rw-r--r--@ 1 karl karl 689B 1 Dez 22:42 tobyink.pl -rwxr-xr-x@ 1 karl karl 1,4K 1 Dez 23:51 myFind.pl -rw-r--r-- 1 karl karl 5B 1 Dez 23:54 foo.pl -rw-r--r-- 1 karl karl 5B 1 Dez 23:54 bar.pl

    Update: Thank you very much! Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006625]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (16)
As of 2015-07-01 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (12 votes), past polls