On Thu, 2004-07-15 at 05:04, manojkumar vajram wrote:
> Plz. help me . I am new to perl
> I want to accept a pattern from screen
> and search the pattern in my one or two text data base
> and print the details
> 
> The pattern from screen may consist spaces and special
> char. line / - etc.
> I use redhat linux 8.0
> I have coded like below but fetched no result
> code------------------------------------------>
> system( "echo -en 'Enter Pattern :\c'");
> $pat = <STDIN>;
> open (FILEONE,"file1");
> while(<FILEONE>){
> if($pat=~$_){print $_;}
> close(FILEONE);
> open (FILETWO,"file2");
> while(<FILETWO>){
> if($pat=~$_){print $_;)
> close(FILETWO);
> 
> end of code----------------------------------->

I think , it will really help if you spend some time learning perl.
Learning Perl , etc from Oreilly is a great starter. Perl is the easiest
to learn language I have seen. 

Coming back to your problem , What you seem to be doing is a simple
grep. If you are not on windows , you could say 
grep PATTERN file1 file2 

If you really want to use perl , you can use a commandline like
perl -ne '/PATTERN/ && print'  <file1> <file2>

Doing it in a seperate perl script is also simple. Just be careful about
the matching Regular expression


HTH
Bye 
Ram





-- 
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