in reply to Google has failed me! Using pack and substr for fixed width file output
use Parse::FixedLength; my $pfl = Parse::FixedLength->new([qw( name:10 date:6 filler:10 )]); my %hash = ( name => 'Joe', date => '020414', ); my $str = $pfl->pack(\%hash); print "[$str]\n"; $hash{name} = 'Bob'; $str = $pfl->pack(\%hash); print "[$str]\n"; # Or even: use Parse::FixedLength; my $pfl = Parse::FixedLength->new([qw( name:10 date:6 filler:10 )], {href => \my %hash} ); %hash = ( name => 'Joe', date => '020414', ); my $str = $pfl->pack(); print "[$str]\n"; $hash{name} = 'Bob'; $str = $pfl->pack(); print "[$str]\n";
|
|---|