Hi rob, 
you are right .

basically I need to search two different strings in one file which are
at different lines.
means string1 is on one line and string2 is on another line

can u plz give then actual syntax to achieve this ? that will be really
good.

regards
irfan.



-----Original Message-----
From: Rob Dixon [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 18, 2006 9:09 PM
To: beginners@perl.org
Subject: Re: search option in perl

Sayed, Irfan (Irfan) wrote:
> Hi all,
>  
> I need to search a file for a specific string thru perl script.
>  
> for example i want to put following condition in the script.
>  
> --- > first search the string string1
> ----> and if that string found then search for another string string2 
> ----> if both the string found then print both the string on shell
> prompt

Hi Irfan.

I think you want to search a file for all lines that contain both string
1 and string2, is that right? This does what you want

 > perl -n -e "print if /string1/ and /string2/" file

But it may be that string1 and string2 can be on separate lines. Please
could you calrify for us? Thanks,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/>
<http://learn.perl.org/first-response>



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to