Gunnar Hjalmarsson wrote:

if (/.*simscan~\[\d+\]~([\w|\s]+).*?~(\d+\.\d+)s~.*?~(.*?)~(.*?)~(.*)/) {
-------------------------^^^^^^^^^^
This captures the "result", but with a trailing space. You may want to let the capturing parentheses be followed by \s to prevent that.

With "captures the result" I mean captures what's later going into the $result variable. Since a quantified subpattern such as

    ([\w|\s]+)

is greedy by default, it would capture

    "CLEAN "

or

    "SPAM REJECT "

i.e. with trailing spaces. I simply suggested that you add a \s, i.e.

    ([\w|\s]+)\s

to rather capture "CLEAN" or "SPAM REJECT".

...ahhh, I see, I see... capture the quantified result (in non-variable sense) but terminate the result at a whitespace...right? Without testing, would a '\s+' have any impact in place of your '\s'? (...I'm just being inquisitive here, before I can actually test for myself).

                $result   = $1 if $1;
                $scantime = $2 if $2;
                $ip       = $3 if $3;
                $from     = $4 if $4;
                $to       = $5 if $5;

The statement modifiers seem redundant to me.

"if $1" etc. are statement modifiers; see "perldoc perlsyn".

Thank you, I will.

I mean that since the regex returned a true value, we know already that all the dollar-digit variables are defined.

....again...ahhh :)

Sure, $3, $4, or $5 might just be the null string, but - without knowing what the rest of the program looks like - I assume that you ought to assign it to respective variable anyway.

Thank you for your feedback. It has been very informative, and I at least now know where to go look.

Steve

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to