One sample is not enough, but maybe something like this?
#! perl -slw
use strict;
my %data = (
1047633 =>
'01.12.199100.00.00003 T8 15 SN Y2001.11.200400095.8000071.8500081.454
+001.11.1994(Anaes.)5001.12.1991Metatarsal, 1 of, treatment of fractur
+e of'
);
my $re_date = qr[\d{2}\.\d{2}\.\d{4}];
my $re_float= qr[\d{5}\.\d{2}];
for my $key ( keys %data ) {
my @fields = $data{ $key } =~ m[
( 20 $re_date $re_float{3} )
( 40 $re_date \( [^)]+ \) )
( 50 $re_date .* $ )
]x;
print "'$_'" for @fields;
}
__END__
P:\test>401374
'2001.11.200400095.8000071.8500081.45'
'4001.11.1994(Anaes.)'
'5001.12.1991Metatarsal, 1 of, treatment of fracture of'
To explan the regex:
m[
## Capture, starting with '20', one date, and 3x %8.2 floats
( 20 $re_date $re_float{3} )
## Capture, starting with '40', one date, '(', non-')' to the ')'
( 40 $re_date \( [^)]+ \) )
## Capture, '50', a date, everything to the end of line.
( 50 $re_date .* $ )
]x; ## ignore whitespace.
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
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.