Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: key value pair or simply a regexp

by duff (Parson)
on May 18, 2007 at 18:40 UTC ( #616251=note: print w/replies, xml ) Need Help??


in reply to key value pair or simply a regexp

It sounds like you just want to change your split() to also split on commas like so:

($key,$value) = split /[=,]/;

Replies are listed 'Best First'.
Re^2: key value pair or simply a regexp
by mikejones (Scribe) on May 18, 2007 at 19:26 UTC
    Close but no cigar. Output is
    KEY: msgagt VALUE: ESM_WMB_AIX KEY: _id VALUE: severity KEY: e VALUE: AEM001 KEY: SM_Integrator.InsertToSYSLOG Use of uninitialized value in print at parse_4_ovo.plx line 22, <$out> + line 7. VALUE: KEY: /DataFlowEngine/ImbRdl/ImbRdlThrowExceptionStatements.cpp: 158 +: SqlThrowExceptionStatement::execute: ComIbmComputeNode: MS_Alert_ES +M_Integrato Use of uninitialized value in print at parse_4_ovo.plx line 22, <$out> + line 9. VALUE: KEY: r#FCMComposite_1_2 Use of uninitialized value in print at parse_4_ovo.plx line 22, <$out> + line 11. VALUE:
    for loop on hash output ########################
    _id -- severity e -- AEM001 msgagt -- ESM_WMB_AIX
    maybe something like this, but even this is not exactly what I need:
    my $data = qq#'msgagt=ESM_WMB_AIX,sec_id=Sec_id,severity=Low,node=test,msgnode=qw +mbap01.cardinalhealth.net,utc={2007-04-26 18:01:59.472+00:00},om={UID=3a7affd6-f420-11db-80b1-000000000000,Alert +Code=AEM001,AlertType=AEM-default,AppName=AEM-CommonService2,Message= +5004:An error has been reported by the BIPXML4C component.:XML}' #; print "$_\n" for $data =~ /((?:\w+=\w+)|(?:\w+=\{.*?\}))/g;
    __OUTPUT__
    msgagt=ESM_WMB_AIX sec_id=Sec_id severity=Low node=test msgnode=qwmbap01 UID=3a7affd6 AlertCode=AEM001 AlertType=AEM AppName=AEM Message=5004

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (1)
As of 2021-10-16 11:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (69 votes). Check out past polls.

    Notices?