Hi,
Thank you - it worked. I got my output as expected. But why is '\n' considered so bad in perl unlike shell scripting. Why did I not get the output with '\n'. Just curious!!! Satya "Nikola Janceski" <nikola_janceski@sum To: "'[EMAIL PROTECTED]'" mithq.com> <[EMAIL PROTECTED]>, "Nikola Janceski" <[EMAIL PROTECTED]> 02/20/2002 10:02 AM cc: [EMAIL PROTECTED] Subject: RE: Grep function inside a for loop does NOT grep the values. I think Brett McCoy was correct with the trailing newline. try this: chomp($item = $_); just after the foreach (@prv_lst) in place of the line there. You might have to chomp again for the second list. Your array looks like it might have the following in it. @prv_lst = ("N001\n", "N015\n"); let us know how it goes. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 20, 2002 9:11 AM To: Nikola Janceski Cc: [EMAIL PROTECTED] Subject: RE: Grep function inside a for loop does NOT grep the values. Thanks guys, I am trying to get a count of transactions(in txn_lst) by txn id 557, 255, 243 etc. that were sent to different customers(in prv_lst) N001, N015 etc., from the log txn_log. txn_log A 557 was sent back to N015 at Mon Jan 14 14:48:06 EST 2002 A 255 was sent back to N015 at Mon Jan 14 14:58:51 EST 2002 A 243 was sent back to N001 at Thu Jan 17 16:08:16 EST 2002 A 242 was sent back to N001 at Fri Jan 18 12:44:11 EST 2002 A 242 was sent back to N001 at Fri Jan 18 12:45:18 EST 2002 prv_lst N001 N015 txn_lst 557 255 243 242 Satya "Nikola Janceski" <nikola_janceski@sum To: "'[EMAIL PROTECTED]'" mithq.com> <[EMAIL PROTECTED]>, [EMAIL PROTECTED] cc: 02/19/2002 05:28 PM Subject: RE: Grep function inside a for loop does NOT grep the values. can you give us a snip of what's in @prv_lst @txn_log -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 19, 2002 5:18 PM To: [EMAIL PROTECTED] Subject: Grep function inside a for loop does NOT grep the values. Hi, I am sorry, I meant to say grep does not work inside a for loop. regards, Satya ----- Forwarded by Satya Devarakonda/THP on 02/19/2002 05:18 PM ----- Satya_Devarakonda@tufts- health.com To: [EMAIL PROTECTED] cc: 02/19/2002 05:13 PM Subject: Grep function inside a for loop does grep the values. Can somebody help me on what is wrong in the following piece of code? foreach (@prv_lst) { $item = $_; @list_prv = grep (/$item/, @txn_log); print "The foll. are the Txn details for Trading Partner $item \n"; print @list_prv; for (@txn_lst) { $aprf = $_; $cnt = 0; @list_prv_txn = grep (/$aprf/, @list_prv); for (@list_prv_txn) {$cnt++}; print "The number of ${aprf}'s are ${cnt} \n" ; } } I dont see any values in the @list_prv eventhough I get one assiging a value to $item like $item = "abc"; -------------------- Thanks in advance, Satya -- 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] ---------------------------------------------------------------------------- -------------------- 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. ---------------------------------------------------------------------------- -------------------- 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]