This morning I was in a code review and typed in a code that was incorrect, but I could not understand why.
$line =~ /^[1-C]/;
This line was supposed to calculate the hexadecimal character between 1and C, but I guess this line does not. The question is not what corresponds, but what does it mean? Can I print all characters in a character class? Something like below?
say join(', ', [1-C]);
Alas,
say join(', ', 1..9);
say join(', ', 'A'..'C');
say join(', ', 1..'C');
Argument "C" isn't numeric in range (or flop) at X:\developers\PERL\Test.pl line 33.
1, 2, 3, 4, 5, 6, 7, 8, 9
A, B, C
source
share