penguin-attack has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I have 3 potential input files that user can input
8=FIX.4.2<SOH>
8=FIX.4.2^A (^A in text )
8=FIX.4.2^A (^A as a Control char hidden)
I want to split by the end character either <SOH> ^A or ^A
my split will work for \cA and <SOH> but I cant get it working for the text based ^A
Logic - 1) read the file in . 2) run through each line splitting on regex match for either text ^A or control A or <SOH . 3)stick in array .4) remove whitespace from array . 5) else throw error
Heres the code:
Problem is that if a tag is encounter like this : 8=A^A, it strips the first A instead of the ^A
I know its staring at me in the face but dunno why my regex ignores the text based ^A
Thanks for your time. Penguin.sub reader { my $stream = "$somefile"; open( FILE, $stream ) or die "Cant open File:$!\n"; while (<FILE>) { if ( $_ =~ m/[\^A\cA\<SOH\>]{1}/g ) { @split= split /[\^A\cA\<SOH\>]+/g, $_; foreach my $line (@split) { foreach my $line (@split) { ( $line =~ s/[\s\n]{1,}//g ); } } } else { my $url = "http:/xxxxx.com/error.html"; my $t = 0; # time until redirect activates print "<META HTTP-EQUIV=refresh CONTENT=\"$t;URL=$url\">\n +"; last; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regex anchoring issue
by kcott (Archbishop) on Feb 15, 2013 at 05:49 UTC | |
by BillKSmith (Monsignor) on Feb 15, 2013 at 14:01 UTC | |
by kcott (Archbishop) on Feb 16, 2013 at 06:35 UTC | |
by smls (Friar) on Feb 15, 2013 at 11:23 UTC | |
by kcott (Archbishop) on Feb 16, 2013 at 05:58 UTC | |
Re: regex anchoring issue
by smls (Friar) on Feb 15, 2013 at 12:01 UTC | |
by Anonymous Monk on Feb 15, 2013 at 22:30 UTC |