instead of $_ I used $name but nothing was found by grep. What do you mean
by another variable?


-----Original Message-----
From: Nikola Janceski [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 9:40 AM
To: 'Nazary, David'; '[EMAIL PROTECTED]'
Subject: RE: unexpected results with grep 


inside grep $_ is a special var assigned to each value of the array.
use another var for the //;


> -----Original Message-----
> From: Nazary, David [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 23, 2002 12:29 PM
> To: '[EMAIL PROTECTED]'
> Subject: unexpected results with grep 
> 
> 
> Hi,
> 
> I am trying to use grep in a simple perl script to find all 
> the lines in a
> list (@labels) that contain certain names in a list (@names). 
> The problem is
> that grep finds all the lines in @labels  for every name in 
> the @names. here
> is the script:
> 
> >>>>>>>>>>>>
> 
> open(NAMES, "names");
> open(LABELS, "labels");
> @labels = <LABELS>;
> @names = <NAMES>;
> 
> foreach $name (@names){
>       open(NEW, ">$name");    #create a file with the name 
> from  @names
>       @labeled_names = grep (/$_/, @labels);
>       print NEW @labeled_names;
>       @labeled_names = "";            #clear the list for the 
> next name
>       close NEW;
> }
> close NAEMS;
> close LABELS;
> 
> >>>>>>>>>>>>>
> 
> any idea what is not write here?
> 
> Thanks in advance
> David
>  
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to