J
Jess
Hi,
I have a subscript which keeps giving this error:
Use of uninitialized value in pattern match (m//) at test_table_tk.pl
line 408.
when trying to match a $value which is specified in a Tk Listbox or a
Tk Entry box to one of a set of operators.
A snapshot of code is:
==================
# Search for operators in query
print "\n";
foreach my $this_op (qw(> < >= <=)) {
print "\nLooking for op: $this_op\n";
print "value: $value\n";
print "defined \$value: ", defined $value, "\n";
print "defined \$this_op: ", defined $this_op, "\n";
print defined $value =~ /$this_op/ , "\n";
if ( $value =~ /$this_op/ ) { # THIS IS LINE 408
print "Found: $this_op\n";
print "Before: $value\n";
($dummy,$num) = split(/$this_op/, $value);
chomp $num;
$op = "$this_op";
print "After: op=$op, num=$num\n";
$q_op = "y";
} elsif ( $q_op !~ /y/ ) {
$q_op = "n";
}
}
==================
It only gives the error on the first cycle of the foreach loop, ie.
when searching for ">". And the error only occurs when the scalar
$value doesn't have the first of the queried operators ">" in it. Ie.
If $value is ">100" no error occurs, while if it is "100" or "<100", I
get the error.
Sorry about all the debug statements, but as you see both $value and
$this_op are defined. Here is the output:
==================
Looking for op: >
value: 100
defined $value: 1
defined $this_op: 1
1
Use of uninitialized value in pattern match (m//) at test_table_tk.pl
line 408.
Looking for op: <
value: 100
defined $value: 1
defined $this_op: 1
1
Looking for op: >=
value: 100
defined $value: 1
defined $this_op: 1
1
Looking for op: <=
value: 100
defined $value: 1
defined $this_op: 1
1
==================
Sorry, this is probably rather basic, but I have looked at this and
can't quite see why it is giving this error. Thanks in advance for your
help!
I have a subscript which keeps giving this error:
Use of uninitialized value in pattern match (m//) at test_table_tk.pl
line 408.
when trying to match a $value which is specified in a Tk Listbox or a
Tk Entry box to one of a set of operators.
A snapshot of code is:
==================
# Search for operators in query
print "\n";
foreach my $this_op (qw(> < >= <=)) {
print "\nLooking for op: $this_op\n";
print "value: $value\n";
print "defined \$value: ", defined $value, "\n";
print "defined \$this_op: ", defined $this_op, "\n";
print defined $value =~ /$this_op/ , "\n";
if ( $value =~ /$this_op/ ) { # THIS IS LINE 408
print "Found: $this_op\n";
print "Before: $value\n";
($dummy,$num) = split(/$this_op/, $value);
chomp $num;
$op = "$this_op";
print "After: op=$op, num=$num\n";
$q_op = "y";
} elsif ( $q_op !~ /y/ ) {
$q_op = "n";
}
}
==================
It only gives the error on the first cycle of the foreach loop, ie.
when searching for ">". And the error only occurs when the scalar
$value doesn't have the first of the queried operators ">" in it. Ie.
If $value is ">100" no error occurs, while if it is "100" or "<100", I
get the error.
Sorry about all the debug statements, but as you see both $value and
$this_op are defined. Here is the output:
==================
Looking for op: >
value: 100
defined $value: 1
defined $this_op: 1
1
Use of uninitialized value in pattern match (m//) at test_table_tk.pl
line 408.
Looking for op: <
value: 100
defined $value: 1
defined $this_op: 1
1
Looking for op: >=
value: 100
defined $value: 1
defined $this_op: 1
1
Looking for op: <=
value: 100
defined $value: 1
defined $this_op: 1
1
==================
Sorry, this is probably rather basic, but I have looked at this and
can't quite see why it is giving this error. Thanks in advance for your
help!