in reply to Converting fixed record length files to pipe delimited
Update: This post and its follow-up keep getting panned. It would be nice to get some constructive criticism rather than watching the numbers continue to fall on this, after all I would like to know what's wrong or could be done better so I can grow as a Perl programmer.#!/usr/bin/perl use strict; my @record_layout = qw( state_code place_code state_alpha_code class_code place_name county_code county_name zip_code ); my %field_types = ( state_code => 'A2', place_code => 'A5', state_alpha_code => 'A2', class_code => 'A2', place_name => 'A52', county_code => 'A3', county_name => 'A22', zip_code => 'A5' ); my %fips_data; my $fips_template = join(" ", @field_types{@record_layout}); while(my $fips_line = <>){ @fips_data{@record_layout} = unpack($fips_template, $fips_line); next if $fips_data{'state_code'} == 52; print STDOUT join('|', @fips_data{@record_layout}); }
Thanks,
Mike
"The two most common elements in the universe are hydrogen... and stupidity."
Harlan Ellison
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Converting fixed record length files to pipe delimited a follow-up
by unixwzrd (Beadle) on Feb 22, 2001 at 00:50 UTC |