#!/usr/bin/perl
use POSIX;
open(FF,"tt.txt");
while(;){
my ($date,$desc,$income,$expend) = unpack("A10xA27xA7xA*",$_);
$tot_income += $income;
$tot_expend += $expend;
$income = sprintf("%.2f", $income);
$expend = sprintf("%12.2f", $expend);
print pack("A11 A28 A8 A*", $date, "$desc", $income, $expend),"\n";
}
$tot_income = sprintf("%.2f", $tot_income); # Get them into
$tot_expend = sprintf("%12.2f", $tot_expend); # "financial" format
$date = POSIX::strftime("%m/%d/%Y", localtime);
print pack("A11 A28 A8 A*", $date, "Totals", $tot_income, $tot_expend),"\n";
signed unsigned byte length in C byte length in Perl
s! S! sizeof(short) $Config{shortsize}
i! I! sizeof(int) $Config{intsize}
l! L! sizeof(long) $Config{longsize}
q! Q! sizeof(longlong) $Config{longlongsize}
+---------+ +----+----+ +---------+
TOS: | IP |TOS+4:| FL | FH | FLAGS TOS+14:| SI |
+---------+ +----+----+ +---------+
| CS | | AL | AH | AX | DI |
+---------+ +----+----+ +---------+
| BL | BH | BX | BP |
+----+----+ +---------+
| CL | CH | CX | DS |
+----+----+ +---------+
| DL | DH | DX | ES |
+----+----+ +---------+
my( $ip, $cs, $flags, $ax, $bx, $cd, $dx, $si, $di, $bp, $ds, $es ) = unpack( 'v12', $frame );
my( $fl, $fh, $al, $ah, $bl, $bh, $cl, $ch, $dl, $dh ) =
unpack( 'C10', substr( $frame, 4, 10 ) );
+-----------------+-----------------+
| S Z - A - P - C | - - - - O D I T |
+-----------------+-----------------+
MSB LSB MSB LSB