To the Perl gurus,
It seems to me it should work (although looking in perldoc perlop I can't
seen an exact example), but I get:-
====start quote======
Argument "" isn't numeric in array element at
D:\perl\scripts\DAMS\modules\RANGECHK.plx line 31, <TEST> line 2
(#1)
(W numeric) The indicated string was fed as an argument to an operator
that expected a numeric value instead. If you're fortunate the message
will identify which operator was so unfortunate.
23:40:47.9 12:13:22.5 ---------- ----------
---------- ---------- 18:36:11.0 ----------
---------- ---------- ---------- 06:02:26.2
Use of uninitialized value in pattern match (m//) at
D:\perl\scripts\DAMS\modules\RANGECHK.plx line 31, <TEST> line 7
(#2)
(W uninitialized) An undefined value was used as if it were already
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign a defined value to your variables.
00:45:39.7 ---------- ---------- ----------
Use of uninitialized value in pattern match (m//) at
D:\perl\scripts\DAMS\modules\RANGECHK.plx line 31, <TEST> line 8
(#2)
---------- ---------- 03:18:30.0 ----------
Use of uninitialized value in pattern match (m//) at
D:\perl\scripts\DAMS\modules\RANGECHK.plx line 31, <TEST> line 9
(#2)
---------- ---------- ---------- 05:58:41.3
Use of uninitialized value in pattern match (m//) at
D:\perl\scripts\DAMS\modules\RANGECHK.plx line 31, <TEST> line 10
(#2)
05:21:55.7 ---------- ---------- ----------
====== end quote ================
a snippet of code follows.
#!/usr/bin/perl -w
use strict;
use diagnostics;
use warnings;
--> snipped for brevity
#
# $state comes in as 0, 1, 2 or 3 - if each element from $state's value
to the last
# matches an "empty" element, then it's ok to plug it in, else we need
to print
# as much as we have on the line, "empty" it, and plug the new value in
the correct slot
#
if ($printLine[$state..3] =~ /^----/) { # line 31 is the
issue, can I match each element? <<<========?
$printLine[$state] = "$time ";
} else {
print @printLine, "\n";
@printLine = @emptyLine;
$printLine[$state] = "$time ";
}
} # <--- end of while (<DATA>) loop
__DATA__
0 23:40:47.9
1 12:13:22.5
2 18:36:11.0
3 06:02:26.2
0 00:45:39.7
2 03:18:30.0
3 05:58:41.3
0 05:21:55.7
1 15:34:01.8
2 10:43:28.5
3 15:15:12.4
2 04:34:15.1
3 09:52:56.5
0 00:56:23.0
__END__
Am I getting stomped on by scalar context within the if condition? Is there
a way I can "elegantly" test for matches within ranges of array elements?
Thanks for any help.
Murray Webster
Database Administrator
EDS Australia
Adelaide Solution Centre