in reply to split delimiters #2
Bailybj, a more reasonable solution is located at: split delimiters II, but this uses split, per your request(s).
but in the spirit of TIMTOWTDI, here is my entry for knuckleheaded-code-of-the-day (hey, it's monday but fun is still allowed, eh?)
again, you may just want to do it smarter than this :-)
#!/bin/perl while (<DATA>) { my $line = $_; $line =~ s/[A-Z,a-z,\>,\(,\),\-,\[,\],\:\_]/ /g; # remove stuff my ($dt,$ev,$id,$st) = split(/\s+/,$line); # split on spac +es print "Date:$dt\nEvent:$ev\nId:$id\nStatus:$st\n"; # tada! } __DATA__ 2001/03/12 time>Event [21]Alert Completed (34562), Status: [22] Alert +Completed,MN_netware-support
which outputs:
xdev$ ./split.pl Date:2001/03/12 Event:21 Id:34562 Status:22
have fun!
|
|---|