CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
How do I handle array refs in Net::POP3?

 



kencl
User

Feb 17, 2000, 5:06 PM

Post #1 of 3 (680 views)
How do I handle array refs in Net::POP3? Can't Post

Just how do I handle these array references?

Here's the code:
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


use Net::POP3;

&GrabMail();

print "number of messages is: <b>$numberofmessages</b>.<br>";
print "last message number is: <b>$lastmessagenumber</b>.<br>";
print "the header is: <b>$header</b>.<br>";
print "This should be the last message:<br>";
foreach $line (@lastmessage) {
print "<b>$line</b><br>";
}
print "The mailbox size is: <b>$boxsize</b> octets - whatever octets are\!<br>";

sub GrabMail {
$user = "mailinglist"; $pass = "yeahright"; $mailserver = "mail.pinc.com";
$pop3 = Net::POP3 -> new($mailserver) &#0124; &#0124; &dienice("Unable to establish a connection with mail.pinc.com.");
$numberofmessages = $pop3 -> login($user,$pass) &#0124; &#0124; &dienice("Login didn't work");
$boxsize = $pop3 -> popstat() &#0124; &#0124; &dienice("Ping didn't work.");
%results = $pop3 -> list();
$lastmessagenumber = $pop3 -> last();
$header = $pop3 -> top($lastmessagenumber);
@lastmessage = $pop3 -> get($lastmessagenumber);
$pop3 -> quit() &#0124; &#0124; &dienice("Connection didn't quit.");
}

sub dienice {
($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}
</pre><HR></BLOCKQUOTE>
And here's the output:

number of messages is: 2.
last message number is: 2.
the header is: ARRAY(0x81a72ac).
This should be the last message:
ARRAY(0x81a72a0)
The mailbox size is: 1607 octets - whatever octets are!


Thanks.


Cure
User

Feb 17, 2000, 7:53 PM

Post #2 of 3 (680 views)
Re: How do I handle array refs in Net::POP3? [In reply to] Can't Post

Hi

@cure = qw/perl guru com/;

$cure =\@cure;

print "$cure\n"; this will print ARRAY(0x6558e8)

print "@$cure\n"; this will print perl guru com

So to get rid of the address->ARRAY(0x81a72ac).
then deference it
@$header


kencl
User

Feb 21, 2000, 12:20 AM

Post #3 of 3 (680 views)
Re: How do I handle array refs in Net::POP3? [In reply to] Can't Post

Thanks Cure. I'd never heard of dereferencing before. For the benefit of others, dereferencing is done like this:

$Scalar = $$ReferenceToScalar
@Array = @$ReferenceToArray
%Hash = %$ReferenceToHash

To create references,

$ReferenceToScalar = \$Scalar
$ReferenceToArray = \@Array
$ReferenceToHash = \%Hash


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives