Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Fetch data between markers

by penantes (Acolyte)
on Jun 07, 2005 at 14:42 UTC ( [id://464325]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Fetch data between markers
in thread Fetch data between markers

Hi there
I read carefully everybodys opinions and found the .. operator to be the simplest way to do it. Altough, I think I didn't express myself very well since your code (in general) is very complex on the regex side altough its valid it is not necessary for the simple thing I needed to to wich I paste bellow.

I abandoned the @array solutions because Im linking 1,2 - 1,3 giga files :)


Nevertheless I deeply thank you all for your fast replies and for sharing with me that bit of knowledge.

ps: I actually found fun in those while in while solutions :) geeee what a geek!

How it will stay
#!/usr/bin/perl use warnings; use strict; #It needs ARGS and readable file my $logfile=$ARGV[0]; my $contract=$ARGV[1]; unless (@ARGV == 2) { print "USAGE: $0 \"logfile\" \"numero\"\n"; exit(1); } my $output="/tmp/session_".$contract.".txt"; unless (-e $logfile) { print "O ficheiro $logfile usado para input n\343o existe. Verifique +o nome do mesmo sff.\n"; exit(1); } if (-e $output) { unlink($output); } open(OUTPUT,">>",$output) or die("Could not open conf file."); open(LOG, $logfile) or die("Could not open conf file."); while (<LOG>) { if (/:NOTICE:user=$contract,session=\d+:/ .. /\)\[/) { print OUTPUT $_ } } close(LOG); close(OUTPUT);
Actually I allready had acomplish that result using a marker with a var and is actually 7 seconds faster than the .. operator, but, I have deprecate it because is better coded with the above script (IMHO).
open(OUTPUT,">>",$output) or die("Could not open conf file."); open(LOG, $logfile) or die("Could not open conf file."); while (defined($line = <LOG>) ) { if ($line =~/:NOTICE:user=$contract,session=(\d+):/) { print OUTPUT $line; $echo=1; } elsif ($echo == 1) { print OUTPUT $line; if ($line =~/\)\[/) { $echo=0; } } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://464325]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-19 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found