in reply to Format statement and 'if' loop

"What is the mistake here?"

Again, no:

use strict; use warnings;

See Use strict and warnings, Use strict warnings and diagnostics or die and How do I post a question effectively?. Didn't you post this already as Question on the format statement?