Here's a couple of different choices inspired by LanX's Re: Help with parsing a file (hash keys are unique)
#!/usr/bin/perl
use strict; # https://perlmonks.org/?node_id=11144249
use warnings;
my $file = 'data.11144249';
open my $fh, '<', $file or die "$! opening $file";
local $_ = do{ local $/; <$fh> }; # slurp entire file
my %solvent_face;
# as requested
$solvent_face{ "$3_$1" } = $2 while
/\b (F\S+) \h+ ([-\d.]+) (?=.*? (\S+) \h+ 0.00000000 )/gsx;
# by solvent, then arrays of each F***
push @{ $solvent_face{ $3 }{ $1 } }, $2 while
/\b (F\S+) \h+ ([-\d.]+) (?=.*? (\S+) \h+ 0.00000000 )/gsx;
# by F***, then arrays of solvent
push @{ $solvent_face{ $1 }{ $3 } }, $2 while
/\b (F\S+) \h+ ([-\d.]+) (?=.*? (\S+) \h+ 0.00000000 )/gsx;
use Data::Dump 'dd'; dd \%solvent_face;
Outputs:
{
"acetonitrile" => {
"F002" => [1.69945785],
"F011" => [0.74578421],
"F101" => [2.67268035],
"F11-1" => [1.64808218],
"F111" => [1.95840198],
},
"acetonitrile_F002" => 1.69945785,
"acetonitrile_F011" => 0.74578421,
"acetonitrile_F101" => 2.67268035,
"acetonitrile_F11-1" => 1.64808218,
"acetonitrile_F111" => 1.95840198,
"F002" => { acetonitrile => [1.69945785], h2o => [4.66656083] },
"F011" => { acetonitrile => [0.74578421], h2o => [26.13597035] },
"F101" => { acetonitrile => [2.67268035], h2o => [32.47411476] },
"F11-1" => { acetonitrile => [1.64808218], h2o => [29.58963453] },
"F111" => { acetonitrile => [1.95840198], h2o => [30.24092207] },
"h2o" => {
"F002" => [4.66656083],
"F011" => [26.13597035],
"F101" => [32.47411476],
"F11-1" => [29.58963453],
"F111" => [30.24092207],
},
"h2o_F002" => 4.66656083,
"h2o_F011" => 26.13597035,
"h2o_F101" => 32.47411476,
"h2o_F11-1" => 29.58963453,
"h2o_F111" => 30.24092207,
}