perlquestion
bowei_99
I'm trying to parse a line once to get what I need, so I do that with a regexp and try dumping to an array. But when I do, I get:
<code>Array found where operator expected at check.pl line 82, at end of line
(Missing operator before ?)
</code>
The offending line 82 is the assignment of the regexp output below:
<code>
if (@data = ($line =~ STATUS_COMPLETED_RE )) {
$stats{level} = $shift @data;
$stats{group} = $shift @data;
$stats{total} = $shift @data;
}
</code>
where the regexp is:
<code>
use constant
STATUS_COMPLETED_RE => qr{ ^string-here \s string-here: \s
\((\w+)\) \s #alarm level
([\w|\s]+) \s completed, \s #job completed
Total\s (\d+) \sclient\(s\), \s #total clients
( #Details -
(\d+) \s # number
([\w|\s\(\)]+) ,|\. # succeed,fail,etc.
)* # any number of
}xms
;
</code>
The code works if I don't output to an array, but since I don't know big the resulting match list from the regexp will be, I'd prefer to dump it to an array and process that array. In other words, the Details section from the regexp could be large, and I'm trying to make it robust.<p>
<hr>
<b>Update</b>
Thanks, yeah, I meant shift and not $shift. Knew it was something trivial. Works now.
Anyone see what I'm missing?
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-492530">
<p>
-- <a href="http://perlmonks.org/?node_id=492530">Burvil</a>
</div></div>