And the output is -use strict; use Data::Dumper; while (<DATA>) { chomp; # remove trailing \n, optional my @rec = split /\|/; # split records my $date = $rec[0]; my ($activity, $machine, $requester) = $rec[2] =~ /(.*)\sfor\s(.*)\s\(requested by (.*)\)/; print "$date, $activity, $machine, $requester\n"; } __DATA__ 10/1/2003 2:06:32 AM|1|Checkout Started for US-02-14@comany.com (reque +sted by aad6870) 10/2/2003 2:07:17 AM|1|Checkout Processed for US-02-14@company.com (re +quested by aad6870) 10/3/2003 2:09:37 AM|1|Checkin Processed for DN-US-02-14@company.com ( +requested by aad6870) 10/4/2003 9:37:53 AM|1|Checkout Started for DN-US-02-14@company.com (r +equested by heavis6608) 10/5/2003 9:38:29 PM|1|Checkout Processed for US-02-14@company.com (re +quested by heavis6608) 10/6/2003 10:10:21 AM|1|Checkout Started for US-02-17@company.com (req +uested by vm_karthik3521)
I think the only trick here is with the my ($var) = $str =~ /(.*)/; idiom. Which is a handy one to master. tachyon had a Perl Meditation not long ago on this topic... 29154310/1/2003 2:06:32 AM, Checkout Started, US-02-14@comany.com, aad6870 10/2/2003 2:07:17 AM, Checkout Processed, US-02-14@company.com, aad687 +0 10/3/2003 2:09:37 AM, Checkin Processed, DN-US-02-14@company.com, aad6 +870 10/4/2003 9:37:53 AM, Checkout Started, DN-US-02-14@company.com, heavi +s6608 10/5/2003 9:38:29 PM, Checkout Processed, US-02-14@company.com, heavis +6608 10/6/2003 10:10:21 AM, Checkout Started, US-02-17@company.com, vm_kart +hik3521
In reply to Re: Regular Expression help
by Roger
in thread Regular Expression help
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |