Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Create output from Perl hash

by choroba (Bishop)
on Feb 13, 2018 at 10:29 UTC ( #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 (Acolyte) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1209052]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2018-03-21 23:10 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (272 votes). Check out past polls.