Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl cookbook and compile error

Status
Not open for further replies.

awingnut

Programmer
Feb 24, 2003
759
US
I am trying to use the perl cookbook to write a script to process POP mail (Recipe 18.5) and getting a compile error. The problem code is:
Code:
use strict:
use Net::POP3;

my $pop=Net::POP3->new("mail.mydomain.com")
   or die "Mail server not responding: ",$!,"\n";
defined ($pop->login("username","password"))
   or die "Login failed: ",$!,"\n";
The error I'm getting on the second statement is : Global symbol "$pop" requires explicit package name ...

Why does it think $pop is global when I've already declared it as local? Is the cookbook wrong or am I missing something basic that the cookbook assumes? TIA.
 
You have a colon after `use strict'. It should be a semicolon. Change that and see if that helps.
 
Thanks for the reply. That was a copy and paste error. The script has a semicolon.
 
With that fixed and an appropriate shebang line that compiles perfectly well for me:
Code:
$ perl -c test2.pl
test2.pl syntax OK
$ perl -v

This is perl, v5.8.7 built for i486-linux-gnu-thread-multi
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2005, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at [URL unfurl="true"]http://www.perl.org/,[/URL] the Perl Home Page.
 
Not good. Some kind of perl implementation problem maybe? This was under OS X (10.4.5).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top