T
Tihana
How to check E-mail in POP3 mailbox,
if there have world "Congratulation" in subject.
TNX
if there have world "Congratulation" in subject.
TNX
wana said:This might work. I modified the example from Mail:OP3Client docs. I
did
not test so it may be wrong.
#! /usr/bin/perl
use strict;
use warnings;
my @message = ();
my $flag = 0;
use Mail:OP3Client;
my $pop = new Mail:OP3Client( USER => "username",
PASSWORD => "password",
HOST => "pop3.yourserver.net" );
for(my $i = 1; $i <= $pop->Count(); $i++ )
{
$flag = 0;
@message = ();
foreach( $pop->Head( $i ) )
{
/^(From|Subject|Date):\s+/i
&& push @message, "$_\n";
if (/^Subject:.*Congratulation.*/i)
{
flag = 1;
}
}
foreach( $pop->Body( $i ) )
{
push @message, "$_\n";
}
if (flag)
This might work. I modified the example from Mail:OP3Client docs.
I did not test so it may be wrong.
#! /usr/bin/perl
use strict;
use warnings;
my @message = ();
my $flag = 0;
Ditto.
use Mail:OP3Client;
my $pop = new Mail:OP3Client( USER => "username",
PASSWORD => "password",
HOST => "pop3.yourserver.net" );
for(my $i = 1; $i <= $pop->Count(); $i++ )
{
$flag = 0;
@message = ();
Tihana said:How to check E-mail in POP3 mailbox,
if there have world "Congratulation" in subject.
TNX
A. Sinan Unur said:Why post it then?
There is no need to explictly initialize my variables.
....
How about for resetting purposes in mod_perl?
if( $h =~ /^Subject:\s+Congratulation/ ) {
print print "$h\n", join "\n", $pop->Body( $i );
Quoth A. Sinan Unur said:There is no need to explictly initialize my variables.
David said:Quoth A. Sinan Unur:
Nor does it hurt to do so, and is a good habit to get into, in case
you're ever in an environment when you can't choose which language to
program in, and have to use something (say, C) which does not
implicitly initialize variables.
Of course, I always initialize my variables (in any language) simply
because I'm a control freak, and want to be darn certain I know
what's in there. ;-)
wana said:I believe that declaring a scalar in Perl automatically sets it to a
false value.
Yes...
I don't know if it is '' or 0
but it will become the appropriate one when you use it.
Also, I did have the mod_perl thing in mind too. Apparently mod_perl
scripts will stay loaded in memory after running and variables may
retain their values, requiring the implicit initialization.
Gunnar said:Not sure what you guys are talking about now.
Does anything really get *initialized* by saying
my @array = ();
or
my %hash = ();
? I thought that was only in order to ensure that the array or hash is
*empty* (which isn't necessary since my() takes care of it).
Do you actually initialize anything but scalars?
David said:Nor does it hurt to do so, and is a good habit to get into, in case you're
ever in an environment when you can't choose which language to program in,
and have to use something (say, C) which does not implicitly initialize
variables.
According to the C FAQ:
Variables with static duration (that is, those declared outside of functions,
and those declared with the storage class static), are guaranteed initialized
(just once, at program startup) to zero, as if the programmer had typed ``=
0''. Therefore, such variables are initialized to the null pointer (of the
correct type; see also section 5) if they are pointers, and to 0.0 if they are
floating-point.
Quoth John W. Krahn said:According to the C FAQ:
Variables with static duration (that is, those declared outside of
functions, and those declared with the storage class static), are
guaranteed initialized (just once, at program startup) to zero, as if
the programmer had typed ``= 0''. Therefore, such variables are
initialized to the null pointer (of the correct type; see also
section 5) if they are pointers, and to 0.0 if they are
floating-point.
Not sure what you guys are talking about now.
Does anything really get *initialized* by saying
my @array = ();
A. Sinan Unur said:(e-mail address removed) (krakle) wrote in
Care to show what you mean by giving us some code?
Please note that I have a pretty good idea what you might be referring to,
but it is your job to actually _make_ an argument (using code, since this
is a programming newsgroup) for the point you are trying to make.
A. Sinan Unur said:(e-mail address removed) (krakle) wrote in
Care to show what you mean by giving us some code?
Please note that I have a pretty good idea what you might be referring to,
but it is your job to actually _make_ an argument (using code, since this
is a programming newsgroup) for the point you are trying to make.
krakle said:Since you insist on seeing code for whatever unknown reason before
you answer my question (ignorance). I'll show you some...
_WITHOUT resetting variable_
use CGI;
my $cgi = new CGI;
my @message;
if (some_other_yada) {
push (@message, "This is message #1: $cgi->param('msg1')");
}
if (some_other_yada) {
push (@message, "Now this is message 2: $cgi->param('msg2')");
}
if (@message) {
foreach (@message) { print "$_\n" }
} else {
print "No messages";
}
If ran as a CGI everything works fine... HOWEVER, if ran as mod_perl
@message retains the previous users data then the new users data adds
to the array then the next users data will retain the last 2 users
and so on... So Even if the current users session never had any
"messages" to add @message will not be empty. BUT if you used
my @message = ();
just like the original poster used the array woudl be reset at the
start of the script emptying any data left over from the previous
session.
arguement. mod_perl scripts stay in memory. Unless you reset the
values of a variable at the beginning of the script or before that
variable is used it may contain the previous users data...
Gunnar said:Global variables retain their values in mod_perl, but I don't think
that's true for lexically scoped variables.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.