nntp scan

R

ruud

I'm trying to write a mini stats script.
So the first thing to do is to collect the posters names:

#! /usr/bin/perl -w

use my $HOME = $ENV{HOME} || '/';
my $scan = new Group => 'nieuws.test',
Spool => "$HOME/nieuws",
From => 'nntp',
NNTPServer => 'news.nl-netwerken.com';

if (not defined $scan) {
die "Failed to create object\n";
}
elsif ($scan->error) {
die "Error: " . $scan->error . "\n";
}

##$scan->collect;
$scan->posters;
if ($scan->error) {
die "Error: " . $scan->error . "\n";
}

my $posters = $scan->posters;
print "$posters\n";


exit;

But when i run the script, it only returns this:
[ruud@localhost ruud]$ ./scan
HASH(0xa145268)

As you can see, no names.
What am i doing wrong here ?
 
S

Sherm Pendley

ruud said:
my $posters = $scan->posters;
print "$posters\n";

exit;

But when i run the script, it only returns this:
[ruud@localhost ruud]$ ./scan
HASH(0xa145268)

As you can see, no names.
What am i doing wrong here ?

The very first line of the documentation for the posters() method states
that it returns a hash reference. As the output shows, that's what you got.
Why do you think something's wrong?

sherm--
 
T

Tad McClellan

ruud said:
use News::Scan;
my $posters = $scan->posters;
print "$posters\n";

But when i run the script, it only returns this:

What am i doing wrong here ?


Failing to de-reference the reference returned by the
method.

perldoc perlreftut
perldoc perlref


To see what the method is returning to you:

use Data::Dumper;
...
my $posters = $scan->posters;
print Dumper $posters;
 
R

ruud

Sherm said:
The very first line of the documentation for the posters() method states
that it returns a hash reference. As the output shows, that's what you
got. Why do you think something's wrong?

Hmm, i was expecting real human readeble names.
Back to the drawingboard :)
 
A

A. Sinan Unur

Hmm, i was expecting real human readeble names.
Back to the drawingboard :)

Do you even know what a hash reference is, or if you don't, did you even
bother to look it up before posting here?

Please do read the posting guidelines posted here regularly. Those
guidelines serve to:

1. Help you diagnose and solve your own problems
2. Failing that, help others help you

Try to see what is in the hash:

use Data::Dumper;
print Dumper $scan->posters;

perldoc -f keys
perldoc -f values
perldoc -f each
perldoc Data::Dumper

Sinan
 
S

Sherm Pendley

ruud said:
Hmm, i was expecting real human readeble names.

The docs for the poster() method clearly state that poster() returns a
reference to a hash, whose keys are email addresses and values are
objects.

Why would you expect a method to return something other than what the docs
say it will return???

sherm--
 
T

Tad McClellan

ruud said:
Hmm, i was expecting real human readeble names.


Then you either did not read, or did not understand, the documentation
for the function that you are using.

A hashref is not "human readable".

If you de-reference the reference you are likely to find that
it contains such names.

Back to the drawingboard :)


No, back to the documentation for the module that you are using,
followed by the documentation that reveals how to dereference references.
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top