Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Create output from Perl hash

by choroba (Cardinal)
on Feb 13, 2018 at 10:29 UTC ( [id://1209052]=note: print w/replies, xml ) Need Help??


in reply to Create output from Perl hash

What should this do?
$myline =~ /(<SUBBEGIN)(.*)(<SUBEND)/g;

You're reading the file line by line. Your sample input contains the SUBBEGIN and SUBEND markers on separate lines. Is it possible to have them on the same line?

It's unclear how one should get from the sample input to the expected output. Can you describe the algorithm? See also SSCCE.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Create output from Perl hash
by gbwien (Sexton) on Feb 13, 2018 at 10:53 UTC

    The input file contains a starting and ending string, so I am using a regular expression to extract group $2 which is what is between SUBBEGIN and SUBEND. I then split $2 based on the equals sign to create my hash %hash.Then within the while loop and using two separate if statements I use the hash function exists to check if key1 is in the %hash(first if statment) and if key2 is in the %hash (second if statement)

Log In?
Username:
Password:

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

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

    No recent polls found