in reply to querying a range of values
In order to get your code to print "Yes", I set $frequency = 10. This winds up meaning: "if ($frequency == 10 ...some not understandable stuff, hence the error message)".
The "==" operator means exactly "equal to".
I recommend always enabling warnings, either by the "shebang line" #!/usr/bin/perl -w or the statement "use warnings;". "use strict" is also an extremely good idea.
You would have seen immediately that Perl didn't like your "if" statement.
#!/usr/bin/perl -w use strict; my $frequency = 10; if ($frequency == 10 .. 15) #this is line 5 {print "Yes freq 10 is ok!(or maybe not quite right!)"} print "\n"; $frequency = 12; if ( (10 <= $frequency) && ($frequency <=15 ) ) { print "Yes $frequency is ok!\n"; } __END__ prints: Use of uninitialized value $frequency in range (or flop) at C:\TEMP\compare.pl line 5. Yes freq 10 is ok!(or maybe not quite right!) Yes 12 is ok!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: querying a range of values
by plendid (Sexton) on Jan 13, 2010 at 12:24 UTC |