Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] regexp

Expand Messages
  • timothy adigun
    ... output, instead, the output will be 18:0. I suppose you didn t put the *:* into consideration as part of the output, since you are you *split* on the $b[1]
    Message 1 of 9 , Nov 5, 2011
    • 0 Attachment
      Yatin Jadhav <yatinjdhv@...> wrote:

      >
      >
      > Try this it works...........
      >
      > $a = "20111014-18:00:14.474 : 8=FIX.4.2 9=68 35=1 34=1074
      > 49=FIX13480052=20111014-18:00:14.474 56=BVMF 112=TEST 10=191";
      > @b = split(m/-/,$a);
      > @c = split(m//,$b[1]);
      > print ("$c[0]$c[1]$c[2]$c[3]\n");
      >
      > print ("$c[0]$c[1]$c[2]$c[3]\n"); will not print 18:00, if that is the
      output, instead, the output will be 18:0. I suppose you didn't put the *:*
      into consideration as part of the output, since you are you *split* on the
      $b[1] according to your script.

      You could also write *print ("$c[0]$c[1]$c[2]$c[3]\n"); * more clearly as
      *print @c[ 0 .. 4 ];*, which i believe will be more error prone free.

      Do one really have to go through all the trouble of array and split when,
      one could just use substitution and regex to extract what you want? Anyway,
      I guess, there is more than one way to do it!
      Try this:

      #!/usr/bin/perl -wl
      use strict;

      my $a =

      "20111014-18:00:14.474 : 8=FIX.4.2 9=68 35=1 34=1074
      49=FIX13480052=20111014-18:00:14.474 56=BVMF 112=TEST 10=191";

      ( my $new_val = $a ) =~ s/^(\d+)-(\d{2}:\d{2})(?:.*)/$2/imgx;
      print $new_val;
      __END__
      OUTPUT: 18:00
      --
      Tim


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.