Hello, Please help me investigate what's wrong, I have an Perl script, which check email and post result in IRC. Here is the code:
#! /usr/bin/env perl use strict; use warnings; use IO::Socket; my $true = 1; sub exec_module { #enable formatting options my ( %colors , %format ); # Color Codes $colors{blue} = chr(3) . "02"; $colors{green} = chr(3) . "03"; $colors{red} = chr(3) . "04"; $colors{brown} = chr(3) . "05"; $colors{purple}= chr(3) . "06"; $colors{olive} = chr(3) . "07"; $colors{teal} = chr(3) . "10"; $colors{royal} = chr(3) . "12"; $colors{pink} = chr(3) . "13"; $colors{dgrey} = chr(3) . "14"; #formatting $format{bold} = chr(2); $format{underline} = chr(31); $format{italics} = chr(22); # Logging options: # If debug = 1, all messeges are shown # If debug = 0, only messeges sent with 2 flag are shown my $debug = 1; #logit ( $debug , 1 , "MODULE Generic: error messege" ); my $sock = shift; # io::sockets referenct to socket info in me +mory; my $channel = shift; # channel bot is opperating in my $client = shift; # connection string from IRC (ex: nick!~us +ername@hostname (ident)) my $mailcheck = "/usr/bin/env perl /home/tool/imap-connect.pl| +"; # Pointer to data array use like so: # $data->[0] = name of module called # $data->[1] = fields 1 and above are data after module call sepereat +ed by spaces. # ie (!generic field1 field2) would be $data->[0] = generic, $data->[1 +] = field1 $data->[2] = field2 my $data = shift; while (1) { open (HANDLE, $mailcheck); while ( my $line = <HANDLE>) { if ( $line =~ /(no mail)/i ) { sleep(1); }else{ print $sock "PRIVMSG " . $channel . " +:" . $format{bold} . $colors{red} . "[mail] " . $line . "\n"; } close ( HANDLE ); } sleep(20); } }
It works, but in log I see this error: readline() on closed filehandle HANDLE at modules/alert.pl line 48.

In reply to Syntax error in scritp or so? by streametch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.