I also got to the point with FORTRAN (yes, I'm old) students where I'd cut them off and tell them to count the columns and make sure each line started with 6 blanks, not 5.
My favorite bug is still some piece of C code buried in a library that was like this:
if (flag == TRUE) ...
Or there's the old for loop typo (much easier to detect on today's high-DPI screens): for(float x=0.0; x < 3,4; x = x + 0.1) ...What you want varies but is probably something like:
if (flag & FLAG_VALUE) ...
if (flag) ....
if ((flag & FLAG_VALUE) == TRUE) ...
that kind of thing. if ((flag & FLAG_VALUE) == TRUE) ...
That would still check if flag is 1, right?Suggest (flag&FLAG_VALUE), or, if you need the expression to be of type bool, ((flag&FLAG_VALUE)!=0) or (!!(flag&FLAG_VALUE)).
using $a or $b for a throw-away script, but Perl uses these internally for sorting
Everything I learn about Perl just makes me hate it more. But a lot of people seem to love it -- it must have some redeeming qualities, right? our $a = 100; # using $a package variable
# then later do a sort on @list
my @sorted = sort { $a cmp $b } @list;
# @sorted worked correctly, $a = 100 had no effect on it
# and $a is still 100
And if we change our to my (so lexical variable) then script will fail to compile giving the fatal error: Can't use "my $a" in sort comparison at...For more information on sort see: http://perldoc.perl.org/functions/sort.html
PS. The OP problem may have been due to issue/bug in older version of Perl. Also using use strict; use warnings do help highlight issues with code.
First 3 lines of all perl code for me are:
#!/usr/bin/env perl
use strict;
use warnings;Answer: Yes, depends on where in the world you live.
... so she named her variable "time"
... which, when modified, would (naturally) set the system time of the computer.
I'm not sure whether they've fixed that one yet.