Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^5: Repeating a capture group pattern within a pattern

by tybalt89 (Monsignor)
on Jul 15, 2024 at 18:04 UTC ( [id://11160623]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Repeating a capture group pattern within a pattern
in thread Repeating a capture group pattern within a pattern

I would probably do something like this to make an array of hashrefs.

#!/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, Precipi +tation 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 Accum +ulation, 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'; }

And here's what the first 3 elements of the answer array are:

( { "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, }, )

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11160623]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-09-13 17:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (21 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.