in reply to Syntax error in scritp or so?

while ( my $line = <HANDLE>) { if ( $line =~ /(no mail)/i ) { ... } close ( HANDLE ); }
You seem to close the handle inside the loop where your read from it. Please be sure that you only close a file after you finished reading it.

HTH, Rata