Main( @ARGV ); exit( 0 ); sub Main { my $activity = { ... }; my $fieldLength = measureFieldLengths( $activity ); $fieldLength and writeOutHashrefs( $activity, $fieldLength ); } #### ## $allActivity_hashref $allActivity_fieldLength_hashref ## $allActivity_href $allActivity_fieldLength_href ## $activity_href $activity_fieldLength_href ## $activity_href $activityFieldLength_href ## $activity_href $fieldLength_href ## $activity $fieldLength ## $activity $activityLength ## %activity %activityLength #~ activity-of-'1234-5678' #~ activity-of-'peter' #### #!/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); 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 $fieldLength = {}; eval { measureFieldLengths( $activity, $fieldLength ); 1; } and eval { writeOutHashrefs( $activity, $fieldLength ); }; warn Dumper( $activity, $fieldLength ); } ## end sub Main sub measureFieldLengths { my( $allActivity_hashref, $allActivity_fieldLength_hashref ) = @_; print "entering measureFieldLengths\n"; measureFieldLength( "ACTIVITY", $allActivity_hashref, $allActivity_fieldLength_hashref ); print "exiting measureFieldLengths\n"; } sub measureFieldLength { my( $tableName, $tableName_hashref, $tableName_fieldLength_hashref ) = @_; print "entering measureFieldLength\n"; print "--inside measureFieldLength--input --" . Dumper( $tableName_hashref ); for my $Id ( sort { $tableName_hashref->{$a} <=> $tableName_hashref->{$b} } keys( %$tableName_hashref ) ) { my $row_hashref = $tableName_hashref->{$Id}; for my $field_name ( sort { $row_hashref->{$a} <=> $row_hashref->{$b} } keys( %$row_hashref ) ) { my $field_valu = $row_hashref->{$field_name}; $tableName_fieldLength_hashref->{$Id}->{$field_name} = 0; $tableName_fieldLength_hashref->{$Id}->{$field_name} = length( $field_valu ) if( defined( $row_hashref->{$field_name} ) ); } } print "--inside measureFieldLength--output --" . Dumper( $tableName_fieldLength_hashref ); ## die "errorHit..."; print "exiting measureFieldLength\n"; } ## end sub measureFieldLength sub writeOutHashrefs { my( $allActivity_hashref, $allActivity_fieldLength_hashref ) = @_; print "entering writeOutHashrefs\n"; print "--inside writeOutHashrefs --input --" . Dumper( $allActivity_fieldLength_hashref ); writeOutHashref( "ACTIVITY", $allActivity_fieldLength_hashref ); print "exiting writeOutHashrefs\n"; } ## end sub writeOutHashrefs sub writeOutHashref { my( $tableName, $tableName_hashref ) = @_; print "entering writeOutHashref\n"; for my $Id ( sort { $tableName_hashref->{$a} <=> $tableName_hashref->{$b} } keys( %$tableName_hashref ) ) { my $row_hashref = $tableName_hashref->{$Id}; print $Id. "\n"; my $outline = $Id; for my $field_name ( sort { $row_hashref->{$a} <=> $row_hashref->{$b} } keys( %$row_hashref ) ) { my $field_valu = $row_hashref->{$field_name}; $outline = $outline . join( '=', $field_name, $field_valu ); } print $outline. "\n"; } print "exiting writeOutHashref\n"; } ## end sub writeOutHashref __END__ #### sub printTable { ... printRow( $table->{ $Id } ); } } ## end sub printTable #### sub TableWrite { ... RowWrite( $table->{ $Id } ); } } ## end sub TableWrite #### sub tableWrite { ... rowWrite( $table->{ $Id } ); } } ## end sub tableWrite