Here's the script.

This is what I'm seeing when I run it.  For the first test, I ran 
through ssh with 'ssh -L 993:localhost:993 192.168.1.1', and the next 
test I connect directly, and the last test is with -debug (users and 
passwords striped of course):

$ mailcheck.pl -host localhost -ssl
INBOX	3
/CRON	3
/JUNK	8

$ mailcheck.pl -host 192.168.1.1 -ssl
Use of uninitialized value in pattern match (m//) at 
/usr/lib/perl5/vendor_perl/5.8.8/Mail/IMAPClient.pm line 2163, <GEN0> 
line 3.

$ mailcheck.pl -host 192.168.1.1 -ssl -debug
Autoloading: Authuser ##############
Sending: 1 Authuser ##############
Sent 19 bytes
Read: * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE 
THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN] 
Courier-IMAP ready. Copyright 1998-2005 Double Precision, Inc.  See 
COPYING for distribution information.
Read: 1 NO Error in IMAP command received by server.
Sending literal string in two parts: 2 Login "##############" {8}
         then: ##############
Sending: 2 Login "XXXXXXXX" {8}
Sent 22 bytes
Read: + OK
Sending: ##############
Sent 10 bytes
Read: 2 OK LOGIN Ok.
Sending: 3 LIST "" *
Sent 13 bytes
Use of uninitialized value in pattern match (m//) at 
/usr/lib/perl5/vendor_perl/5.8.8/Mail/IMAPClient.pm line 2163, <GEN0> 
line 3.

The offending line in IMAPClient.pm is here:

push @folders, $1||$2
   if $list[$m] =~
   /       ^\*\s+LIST               # * LIST
           \s+\([^\)]*\)\s+         # (Flags)
           (?:"[^"]*"|NIL)\s+>- # "delimiter" or NIL
           (?:"([^"]*)"|(.*))\x0d\x0a$  # Name or "Folder name"
   /ix;

I don't know enough about perl to know if it's just the 'push' line that 
is causing the error, or if it's somewhere in the entire block.  Nothing 
inside the pattern match looks dynamic, and the only thing I can think 
of is $list[m] is undef.  But $list[m] is inside a "for ($m = 0; $m < 
scalar(@list); $m++ )" and I don't see anything that could spontaneously 
unset it.

What bugs me about this is I'm connecting to the same server every time, 
and as long as I connect to localhost, through client forwarding or 
directly on the server, it works fine.  It's seems like the LIST command 
returns something that instantly kills the socket, but why would that 
change connecting to localhost?

Thanks for the help so far, even if it was a non-answer.
Maybe you can see something that I can't.

Chris

Joshua Radke wrote:
> Perl is a deep language, and oftentimes questions are more about using the
> modules than they are about Perl in particular.  I'm sorry for the
> (non)-answer, but your next step is to open the file mentioned
> (/usr/lib/perl5/vendor_perl/5.8.8/Mail/IMAPClient.pm) and see why you
> got the error (was the calling function supposed to have supplied an
> argument?  Is there an error in the module that uninitializes the value
> for some reason?).
> 
> This is one of the simplest examples of a problem that's soooooo much
> easier to solve when the source is available.
> 
> If you'd like to send/post the script, we may be able to dig into it a
> bit more ...
> 
> 
> 
> Chris Frederick wrote:
>> Any perl gurus here?  I'm trying to write what should be a simple script 
>> that connects to an imap account, goes through all the folders and 
>> outputs a line for each folder that has unread messages with the number 
>> unread.  I can get connected, 
>> logged in, and even select the INBOX, but any time I try to access the 
>> $imap->folders() function, I get this error:
>>
>> Use of uninitialized value in pattern match (m//) at 
>> /usr/lib/perl5/vendor_perl/5.8.8/Mail/IMAPClient.pm line 2163, <GEN0> 
>> line 3.
>>
>> I can't find anything on this one.  I've looked everywhere I can think 
>> of and changed a lot of things in the code to try to step around this. 
>> I'm really new to perl (this is my first script), and all the modules 
>> have been loaded through gentoo portage.  Has anyone here run into this, 
>> or can anyone give me a hand?
>>
>> Thanks all,
>> Chris
>>
>> _______________________________________________
>> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
>> tclug-list at mn-linux.org
>> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
>>   
> 
> _______________________________________________
> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
> tclug-list at mn-linux.org
> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mailcheck.pl
Type: application/x-perl
Size: 4650 bytes
Desc: not available
Url : http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20070419/44718235/attachment.bin