in reply to Data Salad Address Problem

The above all looks like decent advice .. One additional thought/approach i had that might save some steps is to "right-align" the data. First, this is assuming the the last non-blank column has the city/state/zip and the second-to-last has the address (street name/number), and thus saves the "if zip_in_6 elsif zip_in_5 elsif zip_in_4 ..." branching).
my @data = ( [...], [...], ... ); # assume AoA foreach my $row (@data){ while(scalar(@$row) && ! $row->[-1]){ # if last item is blank pop @$row; #then remove it } my $city_state_zip_str = $->row[-1]; my $address_str = $row->[-2]; # parse those two vars w/regexp's here }
(Note you could reverse the @$row array and work with ($row->[0], $row->[1]) instead)

Replies are listed 'Best First'.
Re^2: Data Salad Address Problem
by bofh_of_oz (Hermit) on Jul 28, 2005 at 18:22 UTC
    I would probably use something like this:

    my @fields; ... foreach my $row (@data) { @string = split(/ +/); for (0..$#string) { push @{ $fields[$_] }, $string[$_]; } } ...
    That should get the multiline record string, process it by-line, and push the corresponding field into an AoA. What needs to be added is the processing for ZIP code since it's the last field of the last row in a record.

     

    --------------------------------
    An idea is not responsible for the people who believe in it...