[27784] in Perl-Users-Digest
Perl-Users Digest, Issue: 9148 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 12 06:05:49 2006
Date: Wed, 12 Apr 2006 03:05:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 12 Apr 2006 Volume: 10 Number: 9148
Today's topics:
Is language Perl have stack, or I must write it? <info@perot.com>
Re: Is language Perl have stack, or I must write it? <christoph.lamprecht.no.spam@web.de>
perl MySQL using DBI - security issue <john@heathdrive.com>
POP3 Mail Client in PERL using IO::Socket module only a <bobano.265149@helpfeeds.com>
Re: tr/// broken? <zbrg@mail.invalid>
Re: XS progamming question <bol@adv.magwien.gv.at>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 12 Apr 2006 08:43:20 +0200
From: <info@perot.com>
Subject: Is language Perl have stack, or I must write it?
Message-Id: <e1i7i4$m6l$1@ss405.t-com.hr>
Is language Perl have stack, or I must write it?
------------------------------
Date: Wed, 12 Apr 2006 10:15:04 +0200
From: Ch Lamprecht <christoph.lamprecht.no.spam@web.de>
Subject: Re: Is language Perl have stack, or I must write it?
Message-Id: <e1icu8$kgr$1@online.de>
info@perot.com wrote:
> Is language Perl have stack, or I must write it?
>
>
perldoc -f push
perldoc -f pop
HTH Christoph
--
perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
------------------------------
Date: Wed, 12 Apr 2006 09:24:44 +0100
From: "John" <john@heathdrive.com>
Subject: perl MySQL using DBI - security issue
Message-Id: <SY2dnaX3jZ_aJKHZRVnyhQ@eclipse.net.uk>
Hi
When using MySql with Perl and use:DBI you need to supply username, password
and database.
My question is this.
What is now considered the *best* method to prevent those three variables
being accessed by outsiders?
Running on a Linux server.
Regards
John
------------------------------
Date: Tue, 11 Apr 2006 22:46:22 +0100
From: bobano <bobano.265149@helpfeeds.com>
Subject: POP3 Mail Client in PERL using IO::Socket module only and regular expressions
Message-Id: <bobano.265149@helpfeeds.com>
Hi everyone,
I am writing a POP3 Client program in Perl. You connect to a POP3
Server and have a running conversation with the mail server using
commands from the RFC 1939 Post Office Protocol. This program can
perform 5 options from a menu on your POP3 mail by logging in with the
correct POP3 server along with a user name and password that you use to
log in to your ISP. The user name and password as well as the server
name are all hard-coded into the program and no user input is required.
You just have to hard-code your ISP server ($host variable), user name
($username variable) and password ($mypass variable) into the program.
I can't figure out how to get the e-mail messages required in "List
Messages" in Menu Option 1 of my program to display a list of the
messages displaying ONLY the message number, who the message is from
and the subject. I am not displaying the entire text of the message in
Option 1.
I am close to getting all of the messages in the mailbox listed with
their message number, who the message is from and the subject but it is
messing up and giving me ALL the header information of the message even
though I only want the message number defined in the program as well as
the \"From\" and \"Subject\" fields. It also seems to be only displaying
the header info for one of the messages which means something is faulty
with the \"for\" loop that I created and it is not looping through the
mail message by message properly.
Can someone also tell me for Option 3 where I need to display the
header and body of the e-mail based on the message number typed in by
the user how I can differentiate between the header and body of each
message using regular expressions? I should also point out that I am
prohibted from using any of the Net::POP3 Perl modules or POP3Mail Perl
modules to complete this so I need to use regular expressions and the
IO::Socket Perl module only.
Here is the code that I have for the program up to this point:
#!/usr/bin/perl -w
use strict;
use IO::Socket qw(:DEFAULT :crlf);
my $host = shift || 'pop3.sympatico.ca';
my $port = shift || '110';
my $socket = IO::Socket::INET->new(PeerAddr => $host, PeerPort =>
$port) or die "no sock $!";
my $choice; # line 10
my $answer;
my $username;
my $mypass;
my $msgnum;
my $msgcount = 0;
$username = "x9xxxx99"; # format masks for user name and password for
$mypass = "99xxx9x9"; # ISP account
print $mypass;
$answer = <$socket>;
print "$answer\n";
# send username, pass
print $socket "user " . $username,CRLF;
$answer = <$socket>;
print $socket "pass " . $mypass,CRLF;
$answer .= <$socket>;
print "$answer\n";
#line 30
system("cls");
print "=======================================================\n";
print "POP3 Mail Client you have " . $msgcount. "messages waiting.\n";
print "=======================================================\n";
while (1) {
# menu
print " 1 List Messages\n";
print " 2 Display body\n";
print " 3 Display header and body\n";
print " 4 Write message to a file\n";
print " 5 Delete message on the server\n";
print " 6 Quit\n\n";
print "Enter choice: ";
chomp ($choice = <STDIN>);
if ($choice =~ /^1$/) {
print $socket "STAT",CRLF;
$answer = <$socket>;
print "$answer\n\n";
if ($answer =~ /^\+OK\s(\d{1,}).*/) {
$msgcount = $1;
print "You have " . $msgcount . " messages";
}
if ($msgcount > 0) {
for (my $i = 0; $i < $msgcount; $i++) {
print $socket "STAT",CRLF;
$answer = <$socket>;
print "$answer\n\n";
$msgnum = $i;
print "Message Number: " . $msgnum;
print $socket "RETR " . $msgnum,CRLF;
$answer = <$socket>;
if ($answer =~ /^\-ERR/) {
print "ERROR";
}
else {
if ( $answer =~ /^From:(.*)/ ) {
print "From: $1\n";
}
if ( $answer =~ /^Subject:(.*)/ ) {
print "Subject: $2\n";
}
}
print "\n";
}
}
else {
print "\n\nYou currently have no messages.";
<STDIN>;
next;
}
next;
}
if ($choice =~ /^2$/) {
print "\nPlease enter message number: ";
chomp($msgnum = <STDIN>);
print $socket "RETR ".$msgnum,CRLF;
$answer = <$socket>;
if ($answer =~ /^\-ERR/) {
print "Error: invalid message number";
<STDIN>;
next;
}
else {
}
next;
}
if ($choice =~ /^3$/) {
print "\nPlease enter message number: ";
chomp($msgnum = <STDIN>);
print $socket "RETR ".$msgnum,CRLF;
$answer = <$socket>;
if ($answer =~ /^\-ERR/) {
print "Error: invalid message number";
<STDIN>;
next;
}
else {
}
next;
}
if ($choice =~ /^4$/) {
print "\nPlease enter message number: ";
chomp($msgnum = <STDIN>);
print $socket "RETR ".$msgnum,CRLF;
$answer = <$socket>;
if ($answer =~ /^\-ERR/) {
print "Error: invalid message number";
<STDIN>;
next;
}
else {
}
next;
}
if ($choice =~ /^5$/) {
print "\nPlease enter message number: ";
chomp($msgnum = <STDIN>);
print $socket "RETR ".$msgnum,CRLF;
$answer = <$socket>;
if ($answer =~ /^\-ERR/) {
print "Error: invalid message number";
<STDIN>;
next;
}
else {
}
next;
}
if ($choice =~ /^6$/) {
print $socket "QUIT",CRLF;
print "exiting\n" and last;
}
}
If this is too confusing to read (my first time posting on here which
may be causing the code to look funny), I have also attached the code
in a .txt document that will need to be renamed to a .pl extension in
order to execute it as a PERL program.
If anyone can give me any assistance on this problem, it would be
greatly appreciated. Thanks.
+-------------------------------------------------------------------+
|Filename: pop3.txt |
|Download: http://helpfeeds.com/attachment.php?attachmentid=480 |
+-------------------------------------------------------------------+
--
bobano
------------------------------------------------------------------------
bobano's Profile: http://helpfeeds.com/member.php?userid=1294
View this thread: http://helpfeeds.com/showthread.php?t=290445
------------------------------
Date: Wed, 12 Apr 2006 08:44:54 +0200
From: <zbrg@mail.invalid>
Subject: Re: tr/// broken?
Message-Id: <443ca1e6$0$645$626a54ce@news.free.fr>
Ilya Zakharevich a dit le Tue, 11 Apr 2006 16:17:49 +0000 (UTC):
> Since it does not apply to the
>situation I discuss, I can hardly find your finding this message in
>the list of warnings relevant.
>
>Second, what I was discussing was not the warning, but the ACTION. Do
>you think the RESULT ('abcdefg') is "correct"?
The warning seems relevant, as avoiding the 0xD800-0xDFFF range seems to give a
good result :
$ perl -wle '$_ = q(abcdefg); tr/\x{d7ff}-\x{e0ff}/ /c; print'
------------------------------
Date: Wed, 12 Apr 2006 09:54:21 +0200
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: XS progamming question
Message-Id: <1144828463.499207@proxy.dienste.wien.at>
Ilya Zakharevich:
> Check it yourselves. Removing globs from symbol tables has no effect
> on already compiled code referencing these globs - the code tree
> already contains C pointers to the globs (I mean access to global
> vars, arrays, hashes, subroutines etc), it won't go through symbol
> tables again.
Uh, oh. This brings me to another question.
The doc says the "BEGIN blocks are compiled and executed first
in order of appearance. Well, taking your example:
perl -wle "sub aa {print 12} BEGIN{ delete $main::{aa} } aa()"
as
sub aa {
print 12;
}
BEGIN {
delete $main{aa};
}
aa();
I would expect that at the time BEGIN is compiled and then
executed, the remaining code is not yet compiled and therefore,
there is no glob *main::aa which could be deleted! Why does
this work nevertheless?
And it doesn't work when the 'sub aa...' is placed _after_ the BEGIN -
no errors, but "12" is printed when running. Does this mean that the
sequence in which subs and a BEGIN appears in a program is of
importance? The docs do not clearify this behaviour.
What exactly happens when Perl reads a script in, _before_ BEGIN
blocks are compiled? I think (and it seems so) that the lexical
analysis and parsing (tokenizing) phase must take place at this time
already - even for code outside of BEGIN blocks. Is this true?
Greetings, Ferry
--
Ing. Ferry Bolhar
Municipality of Vienna, Department 14
A-1010 Vienna / AUSTRIA
E-mail: bol@adv.magwien.gv.at
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 9148
***************************************