Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
From this input file I am trying to caputure the value QUEUE(#####) and RNAME(#####) from each line starts with AMQ8409 , I am able to get to the line and capture it but not sure how to split it or do any trick to only get the QUEUE and RNAME value , my output should look like :Timed out (reason: in while loop) ::expect_out(0,string) = > ::expect_out(1,string) = RF use CSWT#RF### dis qremote(MQSI.3PL846) RNAME1 : dis qremote(MQSI.3PL846) RNAME AMQ8409: Display Queue details.QUEUE(MQSI.3PL846)TYPE(QREMOTE)RNAME(MQ +SI.3PL846) No commands have a syntax error. AMQ8409: Display Queue details.QUEUE(MQSI.3PL944)TYPE(QREMOTE)RNAME(MQ +SI.3PL944) end2 : end
Here is what I have so far :QUEUE(MQSI.3PL846) ----- > RNAME(MQSI.3PL846) QUEUE(MQSI.3PL944) ------> RNAME(MQSI.3PL944)
However , this will catch the whole line.. Any advice is appreciated. Thanksopen (INPUT, "out") || die "couldn't open the file!"; open (OUTPUT, ">outF") || die "couldn't open the file!"; foreach $line (<INPUT>) { chomp $line; if ( $line =~ "AMQ8409" ) { print OUTPUT "$line\n"; } } close(OUTPUT); close(INPUT);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: capturing words
by kyle (Abbot) on Nov 08, 2007 at 16:06 UTC | |
by Anonymous Monk on Nov 08, 2007 at 16:13 UTC | |
|
Re: capturing words
by gamache (Friar) on Nov 08, 2007 at 16:01 UTC | |
by johngg (Canon) on Nov 08, 2007 at 16:17 UTC | |
|
Re: capturing words
by mwah (Hermit) on Nov 08, 2007 at 19:21 UTC | |
by johngg (Canon) on Nov 08, 2007 at 23:55 UTC |