Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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 (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
Node Status?
node history
Node Type: note [id://1209052]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2018-06-22 21:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (124 votes). Check out past polls.

    Notices?