On Wed, 3 Oct 2001, Matthew Blacklow wrote:

> stuff i dont care about
> Error: 4
> more stuff that doesn't matter
>
> what i need to do is store the number 4 in a variable. Using index i am able
> to search through the string and find how many characters into the array the
> word error begins. The error however can be more than just one character and
> so i need to know how i would capture the next x characters into a variable.

Use a regular expression.  Since you know the text to scan is in a
specific pattern (the text 'Error: ', followed by a number of 1 or more
digits), it's easy to create a regular expression for this.

Assuming your program's output is captured into an array by whatever
method you have chosen (piped output into a filehandle, backticks, etc):

my $error_num;

while(@output_arr) {

        if(/Error: (\d*)/) { $error_num = $1 }
}

-- Brett
                                          http://www.chapelperilous.net/
------------------------------------------------------------------------
Fortune finishes the great quotations, #6

        "But, soft!  What light through yonder window breaks?"
        It's nothing, honey.  Go back to sleep.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to