in reply to Looping in a Loop

You should chomp $list before the "if" statement:
chomp $list;

See also the Basic debugging checklist