Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: String matching and Regular Expressions

by kallol.chakra (Initiate)
on Aug 29, 2009 at 20:44 UTC ( #792112=note: print w/replies, xml ) Need Help??


in reply to String matching and Regular Expressions

Hi, I have a doubt about this. Lets take this scenario. The Input data is as follows: header { subheader1 { field1 : value field2 : value field3: value } subheader2 { subheader3 { field4 : value field5 : value field6: value } subheader4 { field7 : value field8 : value field9: value } } } header { subheader1 { field1 : value1 field2 : value1 field3: value1 } subheader2 { subheader3 { field4 : value1 field5 : value1 field6: value1 } subheader4 { field7 : value1 field8 : value1 field9: value1 } } } The output will be : field1,field2,field3,field4,field5,field6,field7,field8,field9 value,value,value,value,value,value,value,value,value value1,value1,value1,value1,value1,value1,value1,value1,value1 Here main problem is that: The value os field2 or field3 may be missing then the output may be: field1,field2,field3,field4,field5,field6,field7,field8,field9 value,value,value,,value,value,value,value,value value1,value1,value1,value1,value1,value1,,value1,value1 In the above output The first line field4 is missing and in the second line field7 is missing How Can I get the output can you please help me.
  • Comment on Re: String matching and Regular Expressions

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://792112]
help
Chatterbox?
[Eily]: It can also be used to force a copy, and remove magic from a variable
[Eily]: there was a post some time ago about variable coming from regex taking more space than the same string defined directly IIRC
[Eily]: and if there's XS, make sure the scalar holds a string representation, that sounds like bad practice though (forcing that on the call side)
[choroba]: You should never pass $1 without double quotes to a sub
[choroba]: or "I should never", at least
[choroba]: that's not the sub's business

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2018-02-22 17:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (296 votes). Check out past polls.

    Notices?