The simplest way is to split the input string and use
Date::Manip::ParseDate recursively on resulting array, as it does exactly what you need, i.e. removes the part containing date from the beginning of input without any knowledge about the format.
Example:
#!/usr/bin/perl
use warnings;
use strict;
use Date::Manip qw(); # I strongly recommend version 5.54
our $TZ = 'GMT'; # to avoid error message
while (<DATA>) {
s/(-!-)/ $1/; #to deal with strange comment format
my @line = split /(\s+)/;
1 while (Date::Manip::ParseDate(\@line));
$_ = (join "", @line) || "\n";
print;
}
__DATA__
09:12: 5:14:29-!- {more garbage goes here}
09:12: 5:14:37
09:12: 5:14:37
2008-12-12 00:39 * {more stuff here}
2008-12-12 01:17 < {data here}
2008-12-12 01:30
2008-12-12 01:31
However, you need to test this method on all types of your data to check if it 'eats' all your bizarre date formats.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.