theravadamonk has asked for the wisdom of the Perl Monks concerning the following question:
I have a file /tmp/file1.txt. it is like this.
Message Time: Feb 3 11:24:54
Mail From: <letter@leemaletter.com>
Mail to: <info@example.com>,<jay@example.com>
quarantine: spam-JF6LBytcy_3D.gz
Message Time: Feb 3 11:25:18
Mail From: <noreply@lankaemarketing40.info>
Mail to: <jay@example.com>
quarantine: spam-uXWM3SJ-nlB0.gz
Message Time: Feb 3 11:25:29
Mail From: <bounce@rhmarketing.info>
Mail to: <sam@example.com>
quarantine: spam-uOG8ycqZrq1s.gz
Message Time: Feb 3 11:25:47
Mail From: <jay@example.com>
Mail to: <userx@gmail.com>
quarantine: spam-FxfQDEDm-5MW.gz
Now, I want to get the output of user jay's info.
OUTPUT shoud be like this.
Message Time: Feb 3 11:24:54
Mail From: <letter@leemaletter.com>
Mail to: <info@example.com>,<jay@example.com>
quarantine: spam-JF6LBytcy_3D.gz
Message Time: Feb 3 11:25:18
Mail From: <noreply@lankaemarketing40.info>
Mail to: <jay@example.com>
quarantine: spam-uXWM3SJ-nlB0.gz
Message Time: Feb 3 11:25:47
Mail From: <jay@example.com>
Mail to: <userx@gmail.com>
quarantine: spam-FxfQDEDm-5MW.gz
How can I achieve this?
I have written a code like this. But it does NOT work?. I also need a case insensitive search
open(my $fh_daily_user_in, '<', $qfn_daily_user_in) or die("Unable to +read file \"$qfn_daily_user_in\": $!\n"); while (<$fh_daily_user_in>) { if (/jay/) { print $_ , "\n"; } }
any comment?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: search a string and get the output that belongs to the string
by Athanasius (Archbishop) on May 07, 2016 at 02:53 UTC | |
by theravadamonk (Scribe) on May 31, 2016 at 10:39 UTC | |
|
Re: search a string and get the output that belongs to the string
by graff (Chancellor) on May 07, 2016 at 20:17 UTC | |
|
Re: search a string and get the output that belongs to the string
by NetWallah (Canon) on May 08, 2016 at 01:53 UTC |