Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: File lines being treated as one.

by minixman (Beadle)
on Mar 03, 2006 at 05:03 UTC ( [id://534183]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re^2: File lines being treated as one.
in thread File lines being treated as one.

So this is strange, when i run this code on the file on its own away from what i am trying to do.
#!/usr/bin/perl my $file = shift; open (LOG, "<$file"); my $tag1 = "11=Order53:1:1140693468"; @logarray=<LOG>; foreach(@logarray){ if(($_=~ m/35=8/)&&($_ =~ m/$tag1/)){ printf ("$_\n"); } }
I get the result i am looking for all be it away from what i am trying to do.
$ perl t.pl fix.log 8=FIX.4.29=034435=849=EXLINK_COMPLEX56=COMPLEX_EXLINK50=COMPLEXGATE57= +DBL9991134=552=20060223-11:18:3 31=L6096=0.000011=Order53:1:114069346814=0.000017=1118339840020=031=0. +0000000032=0.000037=132710014138=1.000039=054=155=Tester60=20060223-1 +1:18:33150=0151=1.0000109=Test23=0167=FUT200=200603207=Test 40=144=0.0000000010=026 $

But in my main code , all i do is call this routine and ask it to search for the file for the same entries as above, and return the results.

sub readfile() { my($tag1,$tag2) = @_; open(FF, "<$fixmessageloc") || die ("Unable to open file: $!: readfil +e_rt \n"); my @logarray = <FF>; if($debug){&writelog(1,"DEBUG: Entered into readfile_rt: passed ($tag +1)($tag2)");} foreach(@logarray){ if(($_ =~ m/35=8/)&&($_ =~ m/$tag1/)){ if(($debug)&&($datadumperdebug)){&writelog(1,"DEBUG: readfile_rt: + found string $_");} printf "Found = $_\n"; } }
But that returns loads of rows and not one row, and some of them don't even match

Replies are listed 'Best First'.
Re^4: File lines being treated as one.
by idle (Friar) on Mar 03, 2006 at 06:48 UTC
    I can't see any different between you first code and second with sub, perhaps the problem is how you call your sub?
    And I have to repeat GrandFather: make sure you are using strictures: use strict; use warnings;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://534183]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.