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:
little parser-script does not work any more - plz advice

 



dilbert
User

Oct 24, 2017, 4:16 PM

Post #1 of 4 (1302 views)
little parser-script does not work any more - plz advice Can't Post

hello dear perl-experts, good evening dear community,


have a little parser that some earlier times worked propperly - but not now.

this script spits out lots of errrors..



Code
 
#!/usr/bin/perl
use Parse::CPAN::Authors;
# must have downloaded
my $p = Parse::CPAN::Authors->new("01mailrc.txt.gz");
# either a filename as above or pass in the contents of the file
my $p = Parse::CPAN::Authors->new($mailrc_contents);

my $authors = $p->authors('A');
# $a is a Parse::CPAN::Authors::Author object
# ... objects are returned by Parse::CPAN::Authors
print $author->email, "\n"; # leon@astray.com
print $author->name, "\n"; # Leon Brocard
print $author->pauseid, "\n"; # LBROCARD

# all the author objects
my @authors = $p->authors;



see - what i get back...


Code
martin@linux-jnmx:~/perl> perl -w c1.pl 
"my" variable $p masks earlier declaration in same scope at c1.pl line 6.
Name "main::mailrc_contents" used only once: possible typo at c1.pl line 6.
Can't call method "email" on an undefined value at c1.pl line 11.
martin@linux-jnmx:~/perl> perl -w c2.pl
"my" variable $p masks earlier declaration in same scope at c2.pl line 6.
Name "main::mailrc_contents" used only once: possible typo at c2.pl line 6.
acme@astray.com
Leon Brocard
LBROCARD
martin@linux-jnmx:~/perl> perl c2.pl
acme@astray.com
Leon Brocard
LBROCARD
martin@linux-jnmx:~/perl> perl c1.pl
Can't call method "email" on an undefined value at c1.pl line 11.
martin@linux-jnmx:~/perl> perl c1.pl
Can't locate object method "email" via package "13275" (perhaps you forgot to load "13275"?) at c1.pl line 11.
martin@linux-jnmx:~/perl> perl c1.pl
Can't locate object method "email" via package "13275" (perhaps you forgot to load "13275"?) at c1.pl line 11.
martin@linux-jnmx:~/perl> perl c1.pl
Can't call method "email" on an undefined value at c1.pl line 11.
martin@linux-jnmx:~/perl>



Laurent_R
Veteran / Moderator

Oct 25, 2017, 9:28 AM

Post #2 of 4 (1294 views)
Re: [dilbert] little parser-script does not work any more - plz advice [In reply to] Can't Post

Hi Dilbert,

I don't know this module, but a couple of ideas:

1. you're declaring $p twice
2. you're declaring $authors (plural) and use $author (singular).


dilbert
User

Oct 25, 2017, 10:34 AM

Post #3 of 4 (1290 views)
Re: [Laurent_R] little parser-script does not work any more - plz advice [In reply to] Can't Post

hello dear Laurent

first of all - many many thanks for the quick reply.

I will check all your ideas and tipps.


In Reply To
Hi Dilbert,

I don't know this module, but a couple of ideas:

1. you're declaring $p twice
2. you're declaring $authors (plural) and use $author (singular).


Many many thanks - this helps alot.

Greetings
dilbert


dilbert
User

Oct 25, 2017, 1:10 PM

Post #4 of 4 (1284 views)
Re: [dilbert] little parser-script does not work any more - plz advice [In reply to] Can't Post

hello dear all

i run in troubles with the parser ... :



Code
#!/usr/bin/perl 
use Parse::CPAN::Authors;

# must have downloaded
my $p = Parse::CPAN::Authors->new("01mailrc.txt.gz");
# either a filename as above or pass in the contents of the file

my $authors = $p->authors('A');
# $a is a Parse::CPAN::Authors::Author object
# ... objects are returned by Parse::CPAN::Authors
print $authors->email, "\n"; # leon@astray.com
print $authors->name, "\n"; # Leon Brocard
print $authors->pauseid, "\n"; # LBROCARD

# all the author objects
my @authors = $p->authors;





i get back the following error;:


Quote
Can't locate object method "email" via package "2613" (perhaps you forgot to load "2613"?) at c3.pl line 10.
martin@linux-jnmx:~/perl>


hmm - i will try to find out what is wrong here ....?

 
 


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

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