Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Broken Pipe woes

by xjar (Pilgrim)
on Jul 18, 2000 at 04:36 UTC ( #22932=perlquestion: print w/replies, xml ) Need Help??

xjar has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a POP3 client in Perl using Mail::POP3Client (mostly to better learn Perl programming) but I am running into a wierd problem. So that long messages don't scroll off the screen, I am printing the messages to more. However, if at any time you hit q to quit more, I get Broken pipe and dumped back to the command line. This however does not happen on another Linux box and a Solaris box that I have access to (the Linux box is almost identical in its software install). A working (or not working) example of the code is as follows:

#!/usr/bin/perl -w
use Mail::POP3Client;
use strict;
my $pop = new Mail::POP3Client( USER            => "(user name omitted)",
                                PASSWORD        => "(password omitted)",
                                HOST            => "localhost",
                                AUTH_MODE       => "PASS" );
my $body = $pop->Body(1);
open (MORE,"|more");
print MORE $body;
close (MORE);
$pop->Close();

I'm stumped, as it was working fine then just... stopped... I can also print the contents of a file piped through more using Perl code and quit it with q just fine. Any help?

Replies are listed 'Best First'.
Re: Broken Pipe woes
by tye (Sage) on Jul 18, 2000 at 05:40 UTC

    I doubt it is some specific part of the e-mail but rather the size of the e-mail. If the e-mail is short enough, then more will happen to read all of it (due to the buffer size it uses, etc.) before it decides to prompt you for the next screen. Then more closing the pipe doesn't cause a broken pipe.

    The "broken pipe" message is harmless in this case and you just need to declare that you know this by ignoring the signal: $SIG{PIPE}= 'IGNORE';

      Thanks... figured it was something with the size. And thanks for the tip on ignoring the signal! :)
RE: Broken Pipe woes
by xjar (Pilgrim) on Jul 18, 2000 at 05:18 UTC
    Found out the problem... turns out something in the email message itself is causing the broken pipe when q is hit. Sent a test message to myself, nothing but 30 lines of "asdf" (hehe) and it works fine with that... now the question is (totally unrelated, but what the heck?) what could cause that, textwise? or could it be the sheer size of the email message itself (a good few hundred lines long... parsed logfiles)?
      Just happened to like yer asdf - I do the exact same (hehe)
Re: Broken Pipe woes
by lhoward (Vicar) on Jul 18, 2000 at 05:36 UTC
    Have you considered using Net::POP3? I have used it for many programs that needed to do POP3 and have never had any problems with it.
      Heh, I actually was using Net::POP3 before, and moved to Mail::POP3Client because I just liked the "style" better, I guess. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://22932]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2021-09-23 20:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?