Не очень гладко, но я делал это так:
my $recordType = unpack("A3", $_);
if ($recordType eq "APT")
{
$currentKey = parseFAAAirportAirportRecord($_);
}
elsif ($recordType eq "ATT")
{
parseFAAAirportAttendenceRecord($currentKey, $_);
}
elsif ($recordType eq "RWY")
{
parseFAAAirportRunwayRecord($currentKey, $_);
}
elsif ($recordType eq "RMK")
{
parseFAAAirportRemarkRecord($currentKey, $_);
}
...
sub parseFAAAirportAirportRecord($)
{
my ($line) = @_;
my ($recordType, $datasource_key, $type, $id, $effDate, $faaRegion,
$faaFieldOffice, $state, $stateName, $county, $countyState,
$city, $name, $ownershipType, $facilityUse, $ownersName,
$ownersAddress, $ownersCityStateZip, $ownersPhone, $facilitiesManager,
$managersAddress, $managersCityStateZip, $managersPhone,
$formattedLat, $secondsLat, $formattedLong, $secondsLong,
$refDetermined, $elev, $elevDetermined, $magVar, $magVarEpoch, $tph,
$sectional, $distFromTown, $dirFromTown, $acres,
$bndryARTCC, $bndryARTCCid,
$bndryARTCCname, $respARTCC, $respARTCCid, $respARTCCname,
$fssOnAirport, $fssId, $fssName, $fssPhone, $fssTollFreePhone,
$altFss, $altFssName,
$altFssPhone, $notamFacility, $notamD, $arptActDate,
$arptStatusCode, $arptCert,
$naspAgreementCode, $arptAirspcAnalysed, $aoe, $custLandRights,
$militaryJoint, $militaryRights, $nationalEmergency, $milUse,
$inspMeth, $inspAgency, $lastInsp, $lastInfo, $fuel, $airframeRepairs
,
$engineRepairs, $bottledOyxgen, $bulkOxygen,
$lightingSchedule, $tower, $unicomFreqs, $ctafFreq, $segmentedCircle,
$lens, $landingFee, $isMedical,
$numBasedSEL, $numBasedMEL, $numBasedJet,
$numBasedHelo, $numBasedGliders, $numBasedMilitary,
$numBasedUltraLight,
$numScheduledOperation, $numCommuter, $numAirTaxi,
$numGAlocal, $numGAItinerant,
$numMil, $countEndingDate,
$aptPosSrc, $aptPosSrcDate, $aptElevSrc, $aptElevSrcDate,
$contractFuel, $transientStorage, $otherServices, $windIndicator,
$icaoId) =
unpack("A3 A11 A13 A4 A10 A3 A4 A2 A20 A21 A2 A40 " .
"A42 A2 A2 A35 A72 A45 A16 A35 A72 A45 A16 A15 A12 A15 A12 A1 A5 A1 " .
"A3 A4 A4 A30 A2 A3 A5 A4 A3 A30 A4 A3 A30 A1 A4 A30 A16 A16 " .
"A4 A30 A16 A4 " .
"A1 A7 A2 A15 A7 A13 A1 A1 A1 A1 A18 A6 A2 A1 A8 A8 A40 A5 A5 A8 " .
"A8 A9 A1 A42 A7 A4 A3 A1 A1 A3 A3 A3 A3 A3 A3 A3 " .
"A6 A6 A6 A6 A6 A6 A10" .
"A16 A10 A16 A10 A1 A12 A71 A3 A7", $line);