hoodlooms has asked for the wisdom of the Perl Monks concerning the following question:
I have right now the following code:
#!/usr/bin/perl -w my $str = q~ <IPDR> <StartTime>1970-01-01T00:00:00.000Z</StartTime> <EndTime>1970-01-01T00:00:00.000Z</EndTime> <timeZoneOffset>0</timeZoneOffset> <callCompletionCode>CC</callCompletionCode> <originalDestinationId></originalDestinationId> <hostName>GWC2@LCSTCHVT02R</hostName> <subscriberId>E1/01/18/5@CIS01S03</subscriberId> <uniqueCallId>14007010000532ca0d25</uniqueCallId> <ipAddress>192.168.47.1</ipAddress> <portNumber>2944</portNumber> <seqNum>30756</seqNum> <averagePacketLatency>0</averagePacketLatency> <inboundByteCount>0</inboundByteCount> <outboundByteCount>4</outboundByteCount> <inboundPacketCount>0</inboundPacketCount> <outboundPacketCount>1</outboundPacketCount> <inboundLostPacketCount>0</inboundLostPacketCount> <packetDelayVariation>0</packetDelayVariation> </IPDR> <IPDR> <StartTime>1970-01-01T00:00:00.000Z</StartTime> <EndTime>1970-01-01T00:00:00.000Z</EndTime> <timeZoneOffset>0</timeZoneOffset> <callCompletionCode>CC</callCompletionCode> <originalDestinationId></originalDestinationId> <hostName>GWC1@LCSTCHVT02R</hostName> <subscriberId>N19Q01.test.cl</subscriberId> <uniqueCallId>14007010000532ca0d25</uniqueCallId> <ipAddress>10.100.9.27</ipAddress> <portNumber>2427</portNumber> <seqNum>30634</seqNum> <averagePacketLatency>0</averagePacketLatency> <inboundByteCount>4</inboundByteCount> <outboundByteCount>9120</outboundByteCount> <inboundPacketCount>1</inboundPacketCount> <outboundPacketCount>57</outboundPacketCount> <inboundLostPacketCount>0</inboundLostPacketCount> <packetDelayVariation>0</packetDelayVariation> </IPDR> <IPDR> <StartTime>1970-01-01T00:00:00.000Z</StartTime> <EndTime>1970-01-01T00:00:00.000Z</EndTime> <timeZoneOffset>0</timeZoneOffset> <callCompletionCode>CC</callCompletionCode> <originalDestinationId></originalDestinationId> <hostName>GWC2@LCSTCHVT02R</hostName> <subscriberId>E1/01/18/5@CIS01S03</subscriberId> <uniqueCallId>14007010000532ca0d25</uniqueCallId> <ipAddress>192.168.47.1</ipAddress> <portNumber>2944</portNumber> <seqNum>30756</seqNum> <averagePacketLatency>0</averagePacketLatency> <inboundByteCount>0</inboundByteCount> <outboundByteCount>4</outboundByteCount> <inboundPacketCount>0</inboundPacketCount> <outboundPacketCount>1</outboundPacketCount> <inboundLostPacketCount>0</inboundLostPacketCount> <packetDelayVariation>0</packetDelayVariation> </IPDR> ~; $str =~ s/\n//g; my @fetch = ($str =~ m/ ( \<IPDR\> (?:.*?) (?:test)+ (?:.*?) \<\/IPDR\> ) /xgi ); print join("\n",@fetch);
What Im trying to do is fill the array with paragraphs that start with <IPDR> and end with </IPDR>, but only those which have the "test" word in them.
The problema is that, although I think my regexp should work, it doesnt divide the paragraphs, instead it prints them all in one big line.
Any help is appreciated.
THANKS
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: one line regexp problem
by ikegami (Patriarch) on Sep 24, 2004 at 22:19 UTC | |
|
Re: one line regexp problem
by BUU (Prior) on Sep 25, 2004 at 08:23 UTC | |
|
Re: one line regexp problem
by JediWizard (Deacon) on Sep 24, 2004 at 22:20 UTC | |
by ikegami (Patriarch) on Sep 24, 2004 at 22:28 UTC | |
by hv (Prior) on Sep 25, 2004 at 12:18 UTC | |
by JediWizard (Deacon) on Sep 24, 2004 at 23:40 UTC |