Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Matching numeric digits in strings

by Samy_rio (Vicar)
on Jan 10, 2007 at 12:37 UTC ( #593895=note: print w/ replies, xml ) Need Help??


in reply to Matching numeric digits in strings

Hi flemi_p, this will help you if I understood your question correctly.

use strict; use warnings; open(IN, 'E:\test\infile.txt') || die $!; my @infile = <IN>; close(IN); open(RE, 'E:\test\require.txt') || die $!; my @reqids = <RE>; close(RE); chomp @infile; chomp @reqids; for my $index (0..$#infile){ for my $rindex (0..$#reqids){ if ($infile[$index] =~ m/$reqids[$rindex]/){ if ($infile[$index] =~ m/select/i){ my $count = $index; $count += 3; print "$infile[$_]\n" for ($index..$count); } } } } __END__ Output as: ---------- 15:53:43.908 Dbg 10739 Oracle: id='12.1' req='834531' SQL: SELECT crf_ +routing.CRF_RT_ACD1_QUEUE,crf_routing.CRF_RT_ACD1_SIZE,crf_ro' +0551 Executed SQL statement 'SELECT', start retrieve records... +0826 MSG_RETRIEVED2 status='DBM_SUCCESS' +0826 MSG_RETRIEVED status='DBM_NOMORE'

Updated Thanks davorg.

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';


Comment on Re: Matching numeric digits in strings
Select or Download Code
Re^2: Matching numeric digits in strings
by davorg (Chancellor) on Jan 10, 2007 at 12:53 UTC
    map{chomp($_)}@infile; map{chomp($_)}@reqids;

    I think you mean:

    chomp @infile; chomp @reqids;

    Isn't that simpler?

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re^2: Matching numeric digits in strings
by flemi_p (Novice) on Jan 10, 2007 at 14:48 UTC
    Hi Velusamy R.,

    Thanks for this. It works fine. However, I need all lines matched with the reqid, which includes the line with the reqid and a select, and the 3 lines in the log file after a line with a select. This constitutes all data for a reqid in the log file and I need them to be output together in the order they are in the log file. Apologies, I didn't explain this very well originally.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2014-12-21 18:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls