Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Perl: Extracting specific text from a .txt file and outputting into a new format

by fisher (Priest)
on Nov 18, 2010 at 10:49 UTC ( #872193=note: print w/replies, xml ) Need Help??


in reply to Perl: Extracting specific text from a .txt file and outputting into a new format

How to find the system name in this log? Please explain using natural language. Does it have static position (say, the very first line)? Does it have empty line before? Maybe, there is some pattern to look for (say, system\d+-.*) ?
  • Comment on Re: Perl: Extracting specific text from a .txt file and outputting into a new format

Replies are listed 'Best First'.
Re^2: Perl: Extracting specific text from a .txt file and outputting into a new format
by fisher (Priest) on Nov 18, 2010 at 11:50 UTC
    well, so what seems to be the problem?
    #!/usr/bin/env perl # use strict; use warnings; open F, "<fff" or die "Aaaahg..."; # current system my $system; # our params here my %box; my %bin; my %bout; my %desc; while (<F>) { /^system\d+-server$/ and do {$system= $_; next}; /^HW a2b.*\(.*\)$/ and $box{$system}= $_; s/^\s*(\d+) packets input.*$/$1/ and $bin{$system}= $_; s/^\s*(\d+) packets output.*$/$1/ and $bout{$system}= $_; s/^Description: (.*)$/$1/ and $desc{$system}= $_; } foreach (keys %desc) { print "System: ". $_; print "Box: ". $box{$_}; print "ByteIn: ". $bin{$_}; print "Byteout: ". $bout{$_}; print "Description: ". $desc{$_}; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://872193]
help
Chatterbox?
[ambrus]: ah, it's one of thos
[Eily]: what, there's a difference between proof of concept and production?
[LanX]: 20 years ago traders were complaining about the latency of the trading system...
[ambrus]: I'm currently in the process of rewriting my proof of concept programs. They sort of developped organically as I was experimenting, so now I've got an ugly mess of multiple programs and one-liners held together by nothing. I'll have to rewrite them to som
[ambrus]: ething that's both cleanly organized and mostly automated.
LanX in train, bad connection
[Corion]: ambrus: Yeah - we're in that situation too, except that there is no time to do the reorganizing :-/
[LanX]: ... so my boss started a project with the newest sun servers and invited the traders to come on weekend to test it... and they were so pleased, that they forced him to keep it in production...
[ambrus]: Corion: sure, this is the long-term plan. The short term is that I have to run this ungodly mess to get results from the new input data today.

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (16)
As of 2017-03-29 11:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (350 votes). Check out past polls.