in reply to string manipulation
What have you tried? What didn't work? What is your experience with Perl? We appreciate shown effort around here.
Examination of your data implies you would like to transform dates from DDMONYEAR to MM\DD\YEAR format. You can do this is a fairly trivial fashion using a hash on month names and a regular expression:
#!/usr/bin/perl use strict; use warnings; my $string = '944|O|1234567890123|14NOV2010|15NOV2010|01JAN3000|C|4567 +8|COMM||045 094|O|1099721190211|14NOV2010|15NOV2010|01JAN3000|C|35077 +|FREE||044 928|O|1234567890123|14NOV2010|15NOV2010|01JAN3000|C|45678| +FREE||030 028|O|2009876543210|14NOV2010|15NOV2010|01JAN3000|C|99212|C +OMM||054'; my %months = (JAN => '01', FEB => '02', MAR => '03', APR => '04', MAY => '05', JUN => '06', JUL => '07', AUG => '08', SEP => '09', OCT => '10', NOV => '11', DEC => '12', ); $string =~ s/ (\d{2}) # Two digits ([A-Z]{3}) # Three capital letters (\d{4}) # Four digits /$months{$2}\\$1\\$3/xg; print $string;
Note this is fragile, as are most regular expressions.
|
|---|