S
sam
Hi,
I need to parse some strings that is seperated by the "=" character
shown as below:
<message type=’Logon’ session=’SN’ status=’Status’ err_msg=’ErrMsg’/>
<message sn = ’SN’ msg_type = ’Msg’ date = ’Date’ time = ’Time’ host =
’IP’ app=’App’ severity = 'Severity' msg = 'Msg'/>
<message> <request = 'Logon' username = 'someone' password = 'pass'/>
<message session_number='SessionNumber' request='Logoff'/>
I want to extract the information my_string from
the pattern ='(my_string)'
The following is the perl script with pattern
#!/usr/bin/perl -w
use strict;
while (<DATA>) {
print "$1 $2 $3\n" if /^<message.+= ?'([^=^']+)' *[A-Za-z]+ ?=
?'([^=^']+)' *(.*)>$/; } __DATA__
<message> <request = 'Logon' username = 'someone' password = 'pass'/>
The result is:
sec@fbsd [3:52pm] [~/unpv12e/s_ipmon]> !p
perl reg_test4.pl
someone pass /
But my expect result is:
Logon someone pass
Any suggestion is very appreciated.
Thanks
Sam
I need to parse some strings that is seperated by the "=" character
shown as below:
<message type=’Logon’ session=’SN’ status=’Status’ err_msg=’ErrMsg’/>
<message sn = ’SN’ msg_type = ’Msg’ date = ’Date’ time = ’Time’ host =
’IP’ app=’App’ severity = 'Severity' msg = 'Msg'/>
<message> <request = 'Logon' username = 'someone' password = 'pass'/>
<message session_number='SessionNumber' request='Logoff'/>
I want to extract the information my_string from
the pattern ='(my_string)'
The following is the perl script with pattern
#!/usr/bin/perl -w
use strict;
while (<DATA>) {
print "$1 $2 $3\n" if /^<message.+= ?'([^=^']+)' *[A-Za-z]+ ?=
?'([^=^']+)' *(.*)>$/; } __DATA__
<message> <request = 'Logon' username = 'someone' password = 'pass'/>
The result is:
sec@fbsd [3:52pm] [~/unpv12e/s_ipmon]> !p
perl reg_test4.pl
someone pass /
But my expect result is:
Logon someone pass
Any suggestion is very appreciated.
Thanks
Sam