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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.