Hi All!
Is there an easy way (or module) to turn a flat fixed-width database into useful data? I would like to dump particular database fields into a hash.
Tom Jones 12345 Something Dr. Atlanta GA 25467 John Doe 1704 Green Street Boston MA 62481 Erica Fields 301 w Tree Circle New York NY 91528
You can use unpack() for this:
@fields = unpack "A[8] A[8] A[25] ...", $record;
where the A[#] specify the length of each field. Note that the spaces an square brackets are in this string only for readability.
Would become...
%hash = ( First_Name => 'Tom',
Last_Name => 'Jones',
City => 'Atlanta',
State => 'GA',
);
In that case, define @fieldnames = qw( First_Name Last_Name City State); somewhere at the top.
Then in processing the records, do:
@[EMAIL PROTECTED] = unpack ...;
This splices the fields into %hash.
Rhesa Rozendaal _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs