I have a scenario in which palettes are weighed prior to delivery and
then that data is submitted to a server. Once the data is transferred,
I have to parse a batch file and strip out information for each shipment
number and format it for print.
The problem is that one shipment might have more than one palette and I don't know how to strip multiple lines of data (with a unique shipment number) for processing. I'm using Active Perl 5.8 in a Windows environment.
For Example here are a few lines of dummy data (header provided for information only):
ShipmentNumber Weight Date Time LocationID
01000 254 03082005 11:25:21 500 01000 210 03082005 11:27:36 500 01401 112 03082005 11:35:21 500 01401 678 03082005 11:37:36 500 01002 450 03082005 17:54:00 001 01785 105 03082005 03:05:67 250
I need to be able to parse this data and know that shipment #01000 has 2 pallets, that shipment #01401 has 2 pallets, that shipment #01002 has only 1 pallet, and so on...
I also need to know which shipment # belongs to which locationid.
I think I know how to perform every task necessary with the exception of knowing how many pallets are with each shipment #.
Any ideas?
Off the top of my head (and untested.)
my %locations; my %pallets;
while ( <FILE> ) { my ( $ShipmentNumber, $LocationID ) = ( split )[ 0, -1 ]; $pallets{ $ShipmentNumber }++; push @{ $locations{ $LocationID } }, $ShipmentNumber; }
for my $ShipmentNumber ( keys %pallets ) {
print "$Shipment Number $ShipmentNumber has $pallets{$ShipmentNumber} pallets.\n";
}
for my $LocationID ( keys %locations ) { print "$Location ID $LocationID shipped to @{$locations{$LocationID}}.\n"; }
John -- use Perl; program fulfillment
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>