Saravana Kumar wrote: > yitzle wrote: > >> You can read one list into an array (@list) and then loop through the >> other file ($item) and grep the list for the item. >> >> for ($item = <>) { # or foreach >> print "$item found" if ( grep $item, @list ); >> } >> >> On 4/20/07, Saravana Kumar <[EMAIL PROTECTED]> wrote: >>> Boga Srinivas wrote: >>> >>> > Hi kumar, >>> > >>> > Try this. >>> > >>> > [EMAIL PROTECTED]:~/perl$ cat reg.pl >>> > #! /usr/bin/perl >>> > $id="[EMAIL PROTECTED]"; >>> > while(<>) { >>> > chomp($_);print "$_\t"; >>> > print "$id found\n" if /$id/; >>> > print "$id not found\n" if ! /$id/; >>> > } >>> > >>> > [EMAIL PROTECTED]:~/perl$ cat mail.txt >>> > [EMAIL PROTECTED] >>> > [EMAIL PROTECTED] >>> > [EMAIL PROTECTED] >>> > [EMAIL PROTECTED]:~/perl$ ./reg.pl < mail.txt >>> > [EMAIL PROTECTED] [EMAIL PROTECTED] found >>> > [EMAIL PROTECTED] [EMAIL PROTECTED] not found >>> > [EMAIL PROTECTED] [EMAIL PROTECTED] not found >>> > >>> > >>> > ~Regards >>> > -srini >>> >>> Yes. I have tried that. It works. My problem is that the $id that i am >>> matching will also be read from another file. >>> >>> ie., a list of ids read one by one from a file and matched against >>> another file which has another list. >>> >>> Thanks! for your time. >>> >>> SK >>> >>> > >>> > Saravana Kumar wrote: >>> >> Hi list, >>> >> >>> >> I am testing a regex with email ids. I have a list of ids that i want >>> >> to match against a one more list of ids. >>> >> >>> >> I have this: >>> >> #! /usr/bin/perl >>> >> $id="[EMAIL PROTECTED]"; >>> >> while(<>) { >>> >> chomp($_);print "$_\t"; >>> >> print "$id found\n" if /$id/; >>> >> print "$id not found\n" if ! /$id/; >>> >> } >>> >> >>> >> and a file /tmp/sampleids >>> >> [EMAIL PROTECTED] >>> >> [EMAIL PROTECTED] >>> >> [EMAIL PROTECTED] >>> >> [EMAIL PROTECTED] >>> >> >>> >> When i run it i get : >>> >> [EMAIL PROTECTED] user1.net not found >>> >> [EMAIL PROTECTED] user1.net not found >>> >> [EMAIL PROTECTED] user1.net not found >>> >> [EMAIL PROTECTED] user1.net not found >>> >> >>> >> When i try to match simple text it works but matching email ids >>> >> doesn't. What am i doing wrong here? >>> >> >>> >> Please help me with this. >>> >> >>> >> TIA, >>> >> SK >> > Thanks to all who replied. Will try these out and post the results. > > Regds, > SK
I tried various options but could not make it work. I was writing a perl script to filter the mails. The script will read directly from the mail program. Compare the from addresses with contents in a file. If the id is present in the file then the mail will be allowed; else denied. First i regex the lines and store the from line in $from. Then i check if the id(in $from) is in the acl file i have. As you may know $from may have a String(fullname) with the email id or simply the email id alone. However i try it doesn't work. I can still give the ids directly in the if condition(escaping @ & .). But i want to have the list of allowed ids in a separate file so that the script need not be changed everytime we add new ids. ideas? TIA, SK -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/