What comes out but Match = k Oops. We wanted the last word, not the last letter. Here’s an approach to debugging this problem: We printed $1, which is the text saved between parentheses. We can ignore whatever else the regex contains and focus on what’s between the parens, i.e., [a-z], which we immediately recognize as a character class that hasn’t been qualified with a quantifier. Therefore it can represent only one character, which is what we got. (When saving parentheses match more than once in a regex because of a quantifier, only the last match gets saved. One might wish for a switch that would return all the matches in a list.) As with most typos, identifying it is 90% of the goal. The fix is easy to predict: /s([az]+)$/ i. Here’s a higher-level sort of transposition. Can you tell what it is before reading the explanation? #!/usr/bin/perl -w use strict; my $fmt = “%10s “x5; printf “$fmtn”, qw(Kelvin Celsius Rankine Fahrenheit Reaumur); $fmt = “%10.2f “x5; for (my $kelvin = 0; $kelvin += 10; $kelvin < 500) { my $celsius = $kelvin - 273.15; my $rankine = $kelvin * 9 / 5; my $fahrenheit = $rankine - 459.67; my $reaumur = $celsius * 4 / 5; printf "$fmtn",$kelvin,$celsius,$rankine,$fahrenheit, $reaumur; } Run this, and it does not terminate! You will be calculating temperatures beyond those experienced in the Big Bang. But the very first line of output is Useless use of numeric lt (<) in void context at temp.pl line 13. Weird. Line 13 is the printf statement, and it has no <. According to Perl of Wisdom #24, we should start scanning backwards until we find one. There it is at the beginning of the for statement: forgivably, we transposed the test and iterative clauses. If you'd like to know why Perl fingered line 13 and not line 7 (the for statement), you'll find an explanation in Chapter 10. 8.2 A Menagerie of Typos
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services