分类:
2008-03-18 16:09:43
Date |Description | Income|Expenditure 01/24/2001 Ahmed's Camel Emporium 1147.99 01/28/2001 Flea spray 24.99 01/29/2001 Camel rides to tourists 235.00 |
#!/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 |