I have a question which is an extension of the solution that I got for my previous problem.
Extracting specific text info from the config file ouput
I have a string as specified in the code below. I need a mechanisam to extract the authentication information.
For me the right authentication information are
1. authentication open <and/or followed by something>
eg1: authentication open network-eap
eg2: authentication open
2. authentication shared <and/or followed by something>
That means I should pick only the ones that start with authentication. Not the one starting with 'aaa' in the example below.
Also when I am looping I should strip of the part which I extracted from the original string.
Could some one tell me how to do it?
my $str = "aaa authentication login\x0d\n ssid Rich\x0d\n authentic
+ation open\x0d\n authentication shared \x0d\n";
my $authentication;
while ($str =~/authentication (\S+)/){
$authentication = $authentiction. $1. " ";
}
# At the end of the while loop
# $authentication should have the value
# $authentication = open shared
Any input provided will be much appreciated! Thanks.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.