hotshot has asked for the wisdom of the Perl Monks concerning the following question:
Hello all!
I have a variable that can hold one of the followings strings:
I need to extract the status, exit status (if exists), and variables (if exists), and print to display a new string with placeholders for the variables taken from the output above.
How can I easily extract all I need from the string outputed by the script (a regexp or something), I need at the end an array holding the status followed by the exit status in the first entry (for example: OFF, ERROR2, WARNING1), and the variables in the next entries, for example:
I have a variable that can hold one of the followings strings:
These strings are output generated from a script I run. As you can see, the first word is the status itself, in the forst parenthesis (before the colon) is the exit status, that not always exist, and after the colon is a string with variables in parenthesis."OFF" "SUCCESS: (abc)" "ERROR(1): disk number (27) crashed at (11:03)" "WARNING(1): system is rebooting"
I need to extract the status, exit status (if exists), and variables (if exists), and print to display a new string with placeholders for the variables taken from the output above.
How can I easily extract all I need from the string outputed by the script (a regexp or something), I need at the end an array holding the status followed by the exit status in the first entry (for example: OFF, ERROR2, WARNING1), and the variables in the next entries, for example:
Anyone?@neededResultEx1 = ('OFF'); @neededResultEx2 = ('SUCCESS', 'abc'); @neededResultEx3 = ('ERROR1', '27', '11:03');
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: String parsing
by Abigail-II (Bishop) on Jan 05, 2004 at 10:54 UTC | |
Re: String parsing
by Zaxo (Archbishop) on Jan 05, 2004 at 10:54 UTC | |
by Abigail-II (Bishop) on Jan 05, 2004 at 12:35 UTC | |
Re: String parsing
by tachyon (Chancellor) on Jan 05, 2004 at 11:07 UTC | |
by BrowserUk (Patriarch) on Jan 05, 2004 at 12:42 UTC | |
Re: String parsing
by ysth (Canon) on Jan 05, 2004 at 12:10 UTC | |
Re: String parsing
by Hena (Friar) on Jan 05, 2004 at 10:57 UTC | |
by bart (Canon) on Jan 05, 2004 at 17:21 UTC | |
Re: String parsing
by Anonymous Monk on Jan 05, 2004 at 10:54 UTC |
Back to
Seekers of Perl Wisdom