Unless one of you can prove my benchmark is wrong, I do see exactly what I expected:
$ perl test.pl Rate buk ike buk 71.1/s -- -36% ike 111/s 56% -- $
The DATA section in the script has trailing \r's:
#!/pro/bin/perl use strict; use warnings; use autodie; use Benchmark qw(cmpthese); my $data = do { local $/; <DATA> } x 400; my @data; { # 1. BrowserUk my $rec = chr (0) x 123; my @type3l = split m/:/, "02:10:33:15:19:10:3:18:6:4"; my $n = 0; my @type3o = map { $n += $_; $n - $_; } @type3l; my @type3 = map \substr ($rec, $type3o[$_], $type3l[$_]), 0 .. $# +type3o; my @typeOl = split m/:/, "02:98:11:9"; $n = 0; my @typeOo = map { $n += $_; $n - $_; } @typeOl; my @typeO = map \substr ($rec, $typeOo[$_], $typeOl[$_]), 0 .. $# +typeOo; sub buk { open my $fh, "<", \$data; while (<$fh>) { substr ($rec, 0) = $_; if (m/^03/) { @data = map $$_, @type3; } else { @data = map $$_, @typeO; } } } # buk } sub ike { local $/ = \(2 * 122); open my $fh, "<", \$data; while (<$fh>) { @data = unpack "A2 A10 A33 A15 A19 A10 A3 A18 A6 A4 x2" . "A2 A98 A11 A9 x2", $_; } } # ike cmpthese (-2, { ike => \&ike, buk => \&buk, }); __END__ 03002068454210482 000000004204.572011-04-14 + 19:53:41INTERNET C 750467375 0214833 + G02042954 03002068703214833 000000002558.662011-04-15 + 08:17:19INTERNET C 761212737 0211561 + 05601207284 03002068802911561 000000001463.702011-04-15 + 08:40:52INTERNET C 719807216 029911 + 00100275296
In reply to Re^4: Working with fixed length files
by Tux
in thread Working with fixed length files
by vendion
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |