Adapting toolic's approach above:
But why do you care that it's on one line and/or without a for-loop?c:\@Work\Perl\monks>perl -wMstrict -le "my $line = '2011-01-01 15:34:554 some words and numbers then email@ho +st.com'; printf qq{date '%s' time '%s' email '%s' \n}, (split /\s+/, $line)[0, + 1, -1]; " date '2011-01-01' time '15:34:554' email 'email@host.com'
Update: Or, if you want to go the regex route:
I suppose the definitions of all the qr// regex objects make this more than one line, but that's life. Also, I hope you can come up with a better e-mail address regex than mine.c:\@Work\Perl\monks>perl -wMstrict -le "my $rx_d = qr{ \d{4} - \d\d - \d\d }xms; my $rx_t = qr{ \d\d : \d\d : \d\d }xms; my $rx_e = qr{ \S+ }xms; ;; my $line = qq{2011-01-01 15:34:55 blah blah yada email\@host.com\n}; print qq{[$line]}; printf qq{d '%s' t '%s' e '%s' \n}, $line =~ m{ \A ($rx_d) \s+ ($rx +_t) .*? ($rx_e) \s* \z }xms; " [2011-01-01 15:34:55 blah blah yada email@host.com ] d '2011-01-01' t '15:34:55' e 'email@host.com'
Give a man a fish: <%-{-{-{-<
In reply to Re^3: matching multiple patterns in one line
by AnomalousMonk
in thread matching multiple patterns in one line
by jose_m
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |