in reply to Help with parsing a file
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11144249 use warnings; open my $fh, '<', \<<END; # FIXME with normal open F001 1.2 F101 3.2 solvent1 0 solvent2 3 three lines of text that are not important and can be skipped F001 2.2 F101 7.2 solvent1 5 solvent2 0 END local $_ = do{ local $/; <$fh> }; # slurp entire file my %solvent_face; $solvent_face{ "$3_$1" } = $2 while /\b (F\w+) \h+ ([\d.]+) (?=.*? ^ (\S+) \h+ 0 \h* \n )/gmsx; use Data::Dump 'dd'; dd \%solvent_face;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help with parsing a file
by Odar (Novice) on May 29, 2022 at 18:10 UTC | |
by tybalt89 (Monsignor) on May 29, 2022 at 18:24 UTC |