in reply to If Problem!!!

Howdy!

I'd guess that $ag is " " (or something like that -- a string of blanks). That non-empty value will evaluate to true, but will be - surprise - blank.

Something like

$ag =~ s/\s+//; if ($ag) . . .
ought to have useful effects by stripping out the blanks in $ag before you test it.

yours,
Michael