#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11160609 use warnings; use List::AllUtils qw( pairwise bundle_by ); my @keys = split /, /, 'Pressure, Geop Height, Temperature, Dew Point, Humidity, Wind Direction, Wind Speed MS, Wind UMS, Wind VMS, Precipitation Amount, Total Cloud Cover, Low Cloud Cover, Medium Cloud Cover, High Cloud Cover, Radiation Global, Radiation Global Accumulation, Radiation Net Surface LW Accumulation, Radiation Net Surface SW Accumulation, Radiation SW Accumulation, Visibility, Wind Gusts'; my @datasets = bundle_by { +{ pairwise { $a, $b } @keys, @_ } } 21, split ' ', getdata(); use Data::Dump 'dd'; dd @datasets[0 .. 2]; sub getdata { return '1016.1 7.7 20.6 13.8 72.9 215.0 6.64 3.94 5.33 0.0 31.3 31.3 0.0 0.0 ... 10727690.0 38242.3 10.8'; } #### ( { "Dew Point" => 13.8, "Geop Height" => 7.7, "High Cloud Cover" => "0.0", "Humidity" => 72.9, "Low Cloud Cover" => 31.3, "Medium Cloud Cover" => "0.0", "Precipitation Amount" => "0.0", "Pressure" => 1016.1, "Radiation Global" => 716.7, "Radiation Global Accumulation" => "8461717.0", "Radiation Net Surface LW Accumulation" => "NaN", "Radiation Net Surface SW Accumulation" => "7750386.0", "Radiation SW Accumulation" => "2224256.0", "Temperature" => 20.6, "Total Cloud Cover" => 31.3, "Visibility" => 38507.5, "Wind Direction" => "215.0", "Wind Gusts" => 10.9, "Wind Speed MS" => 6.64, "Wind UMS" => 3.94, "Wind VMS" => 5.33, }, { "Dew Point" => 13.7, "Geop Height" => 7.7, "High Cloud Cover" => "0.0", "Humidity" => 71.1, "Low Cloud Cover" => 2.1, "Medium Cloud Cover" => "0.0", "Precipitation Amount" => "0.0", "Pressure" => 1016.4, "Radiation Global" => 727.6, "Radiation Global Accumulation" => "11081057.0", "Radiation Net Surface LW Accumulation" => "NaN", "Radiation Net Surface SW Accumulation" => "10146792.0", "Radiation SW Accumulation" => 2372829.8, "Temperature" => 21.1, "Total Cloud Cover" => 2.1, "Visibility" => 40682.2, "Wind Direction" => "222.0", "Wind Gusts" => 11.2, "Wind Speed MS" => 6.82, "Wind UMS" => 4.67, "Wind VMS" => 4.95, }, { "Dew Point" => 13.2, "Geop Height" => 7.7, "High Cloud Cover" => "0.0", "Humidity" => 67.7, "Low Cloud Cover" => 0.8, "Medium Cloud Cover" => "0.0", "Precipitation Amount" => "0.0", "Pressure" => 1016.4, "Radiation Global" => 749.9, "Radiation Global Accumulation" => "13780637.0", "Radiation Net Surface LW Accumulation" => "NaN", "Radiation Net Surface SW Accumulation" => "12614863.0", "Radiation SW Accumulation" => 4011495.3, "Temperature" => 21.6, "Total Cloud Cover" => 0.8, "Visibility" => 44407.4, "Wind Direction" => "220.0", "Wind Gusts" => 11.3, "Wind Speed MS" => 6.71, "Wind UMS" => 4.37, "Wind VMS" => 5.1, }, )