-----Original Message----- From: Barbara Manfredini [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 15, 2002 10:20 AM To: [EMAIL PROTECTED] Subject: Same help 2
I don't know if my mail arrived because I did not subscribe.Now I've sent a mail to [EMAIL PROTECTED] and I hope I'm ok. My simple questions were: How can I cut from a file a line where I match a word? - If I have a file with many lines,I want to cut the lines where the word "example"(or a pattern matching) is contained. ex. this is an example for you become this is for you And how can I cut just the word matched? ex. this is an for you TRY THIS FOR THE ABOVE REQ open (INP, "<$fileName"); while (<INP>) { chomp; if (/example/) { s/example//g; push (@ex2,$_); } else { push (@ex1,$_); push (@ex2,$_); } } foreach (@ex1) { print $_,"\n"; } print "\n\n"; foreach (@ex2) { print $_,"\n"; } I need to extract from a file what is after @(to know dominion names) and to take every name one time(I think to put it in a hash but I don't know how) ex2. [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] gives me hotmail.com #just one time aol.com yahoo.com example.com I hope to explain it better now.Thanks for your help.Bye FOR THE ABOVE, assuming that only one address is present in one line, try this open (INP,"<$fileName]"); while (<INP>) { chomp; /(.*?)\@(.*)/; if ($2) { $address{$2} = (); } } foreach (sort (keys %address)) { print $_,"\n"; } Hope it meets your requirements !! _________________________________________________________________ Scarica GRATUITAMENTE MSN Explorer dall'indirizzo http://explorer.msn.it/intl.asp. -- 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]