in reply to Message regex

I guess pm stripped something from the OPs post.

To the question, that's a really fuzzy one. Splitting "8=FIX" is no problem, but you should tell us how to get that part. How to break up this for instance?
8=FIX.4.29=040535=849=EXLINK
or that one:
116=0.0000000011=DES:fud632_2005111814=15.000017=013

Ordinary morality is for ordinary people. -- Aleister Crowley

Replies are listed 'Best First'.
Re^2: Message regex
by minixman (Beadle) on Nov 24, 2005 at 16:38 UTC
    Yeah sorry the questions is fuzzy. What i need to do is i have an array of tags ie
    #!/usr/bin/perl use strict; use warnings; my @tags = ("8=","9=","35=","49=","56=","50=","57=", "34=","52=","91=","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=" ); open(FH, "test.log")||die("Unable to open log file: $! \n"); while (<FH>) { if($_ =~ any of the tags in array) { printf $fulltag; } }

    So here we go over each line and match up 8=FIX then put that into a variable something like $first. Does that make sense.

      Should
      31=aaaaaa38=bbbbbbb
      return
      31 => 'aaaaaa', 38 => 'bbbbbbb'
      or
      31 => 'aaaaaa3', 8 => 'bbbbbbb'
      That's why @tags must be populated in advance and must be in order

      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 $re = '\\[' . join('', map { "($_)=(.*?)" } @tags) . '\\]'; while (<DATA>) { chomp; my %hash = /$re/; if (not %hash) { warn("Line $. did not match\n"); next; } foreach my $tag (@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=DCN323 +0134=4045652=20051118-05:07:181=ATOP116=0.0000000011=DES:fud632_20051 +11814=15.000017=0131730438520=031=1531.0000000032=1.000037=1317260632 +38=15.000039=254=255=NamerOfContr60=20051118-05:07:18150=2151=0.00001 +98=13173047161317260632109=DCN3230163=0167=FUT200=200512207=TSE40=244 +=1531.000000005113=06556=20051117-23:06:4910=021]

      or with sorted output:

      Output