- or download this
$chapter =~ s/\D+//g; # remove all non-digit characters
# or perhaps to avoid the /g flag, (I wouldn't code it this way
...
# before or after the digits
# try the above with "XX546YYY", just "453ZZ" and "AAA123ZZZ77548" as
# cases to probe the limits... what happens if it is not just "11VI"?
- or download this
my $x = "3";
if ($x > 3){...}
- or download this
my $x = "chapter 5";
print "chap 5 ok!" if $x == 5;
...
# chapter 5 is ok now!
# The string got "fixed" to be completely numeric
# Then when Perl made it into binary number to compare against 5, it w
+orked!
- or download this
$x = "00005";
print "$x\n"; #yields "00005"
$x += 0; #adding zero forces numeric conversion
print "$x\n"; #yields "5"