Eliminating the many wrapper/tracing subs ... Devel::TraceCalls takes care of the tracing ... other tracing options
#!/home/gnu/bin/perl -- ## ## ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" #!/home/gnu/bin/perl -- use strict; use warnings; use autouse 'Data::Dumper' => qw(Dumper); use Devel::TraceCalls { Package => "main" }; Main( @ARGV ); exit( 0 ); sub Main { my $activity = { '1234-5678' => { 'Address' => "656 Poplar", 'City' => "Monroe", 'State' => "WI", 'Zip' => "87654", 'Phone' => "444-555-6666" }, '5757-4968' => { 'Address' => "656 Poplar", 'City' => "Nightmare", 'State' => "ND", 'Zip' => "56532", 'Phone' => "777-8888" } }; my $activityLength = masureActivityLengths( $activity ); $activityLength and activityWrite( $activity, $activityLength ); } ## end sub Main sub masureActivityLengths { my( $activity ) = @_; my $lengthRef = {}; for my $Id ( sort { $activity->{$a} <=> $activity->{$b} } keys( %$activity ) ) { my $row = $activity->{$Id}; for my $key ( sort { $row->{$a} <=> $row->{$b} } keys( %$row ) ) { my $val = $row->{$key}; $lengthRef->{$Id}->{$key} = defined $val ? length( $val ) +: 0; } } return $lengthRef; } ## end sub masureActivityLengths sub activityWrite { my( $activity, $activityLength ) = @_; for my $Id ( sort { $activityLength->{$a} <=> $activityLength->{$b} } keys( %$activityLength ) ) { my $row = $activityLength->{$Id}; print $Id. "\n"; my $outline = $Id; for my $key ( sort { $row->{$a} <=> $row->{$b} } keys( %$row ) ) { my $val = $row->{$key}; $outline .= ';'. join( '=', $key, $val ); } print $outline. "\n"; } } ## end sub activityWrite __END__ TRACE: main::Main() TRACE: +-main::masureActivityLengths( { : | | '1234-5678' => { : | | Phone => '444-555-6666', : | | Zip => '87654', : | | Address => '656 Poplar', : | | City => 'Monroe', : | | State => 'WI' : | | }, : | | '5757-4968' => { : | | Phone => '777-8888', : | | Zip => '56532', : | | Address => '656 Poplar', : | | City => 'Nightmare', : | | State => 'ND' : | | } : | | } ) Argument "444-555-6666" isn't numeric in numeric comparison (<=>) at - + line 49. Argument "Monroe" isn't numeric in numeric comparison (<=>) at - line +49. Argument "656 Poplar" isn't numeric in numeric comparison (<=>) at - l +ine 49. Argument "WI" isn't numeric in numeric comparison (<=>) at - line 49. Argument "777-8888" isn't numeric in numeric comparison (<=>) at - lin +e 49. Argument "Nightmare" isn't numeric in numeric comparison (<=>) at - li +ne 49. Argument "656 Poplar" isn't numeric in numeric comparison (<=>) at - l +ine 49. Argument "ND" isn't numeric in numeric comparison (<=>) at - line 49. TRACE: +-main::activityWrite( { : | | '1234-5678' => { : | | Phone => '444-555-6666', : | | Zip => 87654, : | | Address => '656 Poplar', : | | City => 'Monroe', : | | State => 'WI' : | | }, : | | '5757-4968' => { : | | Phone => '777-8888', : | | Zip => 56532, : | | Address => '656 Poplar', : | | City => 'Nightmare', : | | State => 'ND' : | | } : | | }, { : | | '1234-5678' => { : | | Phone => 12, : | | Zip => 5, : | | Address => 10, : | | City => 6, : | | State => 2 : | | }, : | | '5757-4968' => { : | | Phone => 8, : | | Zip => 5, : | | Address => 10, : | | City => 9, : | | State => 2 : | | } : | | } ) 1234-5678 1234-5678;State=2;Zip=5;City=6;Address=10;Phone=12 5757-4968 5757-4968;State=2;Zip=5;Phone=8;City=9;Address=10
In reply to Re^2: no visibility to global hashref ?!?
by Anonymous Monk
in thread no visibility to global hashref ?!?
by kerchunk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |