Home > Archive > PERL Beginners > May 2004 > Query
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Sudhindra Bhat 2004-05-17, 7:30 am |
| Hi
I wanted some help on a piece of code that I was writing. Well the
requirement is like this. I have a file whose looks like this
(1) Test: 123456 ABCDEF
123456
(2) Results: ABCDEF
Now I want my script to output all the contents between the two tags Test
and Results. i.e. 123456 ABCDEF 123456. Can someone help me with this?
Regards,
Sudhindra
| |
| John W . Krahn 2004-05-17, 8:30 am |
| On Monday 17 May 2004 03:15, Sudhindra Bhat wrote:
>
> Hi
Hello,
> I wanted some help on a piece of code that I was writing. Well the
> requirement is like this. I have a file whose looks like this
>
> (1) Test: 123456 ABCDEF
>
> 123456
>
> (2) Results: ABCDEF
>
> Now I want my script to output all the contents between the two tags
> Test and Results. i.e. 123456 ABCDEF 123456. Can someone help me with
> this?
while ( <FILE> ) {
if ( /Test:/ .. /Results:/ and !/Test:/ and !/Results:/ ) {
print
}
}
John
--
use Perl;
program
fulfillment
| |
| Sudhindra Bhat 2004-05-17, 9:30 am |
| Hi
Thanks. But there is a small issue. Considering the same example, the piece
of code sent by you prints 123456 which is not on the same line as "Test:"
But it doesn't print the characters 123456 ABCDEF which is on the same line
as "Text:"
Regards,
Sudhindra
-----Original Message-----
From: John W.Krahn [mailto:krahnj@acm.org]
Sent: Monday, May 17, 2004 4:56 PM
To: Perl Beginners
Subject: Re: Query
On Monday 17 May 2004 03:15, Sudhindra Bhat wrote:
>
> Hi
Hello,
> I wanted some help on a piece of code that I was writing. Well the
> requirement is like this. I have a file whose looks like this
>
> (1) Test: 123456 ABCDEF
>
> 123456
>
> (2) Results: ABCDEF
>
> Now I want my script to output all the contents between the two tags
> Test and Results. i.e. 123456 ABCDEF 123456. Can someone help me with
> this?
while ( <FILE> ) {
if ( /Test:/ .. /Results:/ and !/Test:/ and !/Results:/ ) {
print
}
}
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
|
|
|
|
|