Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Unable to get the paragraph in the list of hashes. Getting single lines instead.

by tybalt89 (Monsignor)
on Sep 22, 2020 at 14:39 UTC ( [id://11122087]=note: print w/replies, xml ) Need Help??


in reply to Unable to get the paragraph in the list of hashes. Getting single lines instead.

It's really logically a one-liner

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11121971 use warnings; my @answer = grep %$_, # ignore empty hashs map +{ /^\h*(.*?)\h*= (.*)/gm }, # convert a paragraph to anon hash + by lines do { local $/ = ''; <DATA> }; # get list of paragraphs use Data::Dump 'dd'; dd \@answer; __DATA__ ..... data section same as my other example .....

( Shown on multiple lines with comments added to avoid annoying GrandFather :)

  • Comment on Re: Unable to get the paragraph in the list of hashes. Getting single lines instead.
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-23 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found