Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Help with parsing a file

by tybalt89 (Monsignor)
on May 29, 2022 at 14:59 UTC ( [id://11144263]=note: print w/replies, xml ) Need Help??


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

    Thank you for your help tybalt89. I think your solution prints out (adds to the hash) only the two records for solvent1 from the first (top) block.Still very useful as I learn a lot.

      Nope, does all F***

      Outputs:

      { solvent1_F001 => 1.2, solvent1_F101 => 3.2, solvent2_F001 => 2.2, solvent2_F101 => 7.2, }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-24 00:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found