in reply to Simple Text Conversion
Anyway:
I haven't tested this very thorougly, but it looks like it'll work. It's rather ugly, too. :)use strict; open FH, "foo" or die "Can't open: $!"; my @recs; while (<FH>) { chomp; push @{$recs[int(($.-1) / 5)]}, $_; } close FH or die "Can't close: $!"; open FH, ">foo.new" or die "Can't open: $!"; for my $ref (@recs) { # break up the city, state, zip into 3 parts my($city, $state, $zip); if ($ref->[2] =~ /(.*?),\s(.*?)\s(.*)/) { ($city, $state, $zip) = ($1, $2, $3); } # join it all together into a pipe-separated # record, then write it out my $new = join "|", @{$ref}[0,1], $city, $state, $zip, @{$ref}[3,4]; print FH $new, "\n"; } close FH;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Simple Text Conversion
by chromatic (Archbishop) on Apr 06, 2000 at 21:38 UTC | |
by btrott (Parson) on Apr 06, 2000 at 22:21 UTC | |
by chromatic (Archbishop) on Apr 06, 2000 at 22:57 UTC |