use strict; use warnings; my @tags = qw( 8 9 35 49 56 50 57 34 52 81 11 14 17 20 31 32 37 38 39 54 55 60 50 51 98 109 163 167 200 207 40 44 113 56 10 ); my @sorted_tag = sort { $a <=> $b } @tags; my $re = '\\[' . join('', map { "($_)=(.*?)" } @tags) . '\\]'; while () { chomp; my %hash = /$re/; if (not %hash) { warn("Line $. did not match\n"); next; } foreach my $tag (@sorted_tags) { printf("%-3s => %s\n", $tag, $hash{$tag}); } print("\n"); } __DATA__ 2005/11/18 00:07:18:328: FIXPump: Received data on connection {OBMSCNX} [8=FIX.4.29=040535=849=EXLINK256=DB_ORDER50=DESRISKGATEWAY57=DCN3230134=4045652=20051118-05:07:181=ATOP116=0.0000000011=DES:fud632_2005111814=15.000017=0131730438520=031=1531.0000000032=1.000037=131726063238=15.000039=254=255=NamerOfContr60=20051118-05:07:18150=2151=0.0000198=13173047161317260632109=DCN3230163=0167=FUT200=200512207=TSE40=244=1531.000000005113=06556=20051117-23:06:4910=021]