Net::NNTP, retrieving articles help please

Discussion in 'Perl Misc' started by jbl, Dec 17, 2004.

  1. jbl

    jbl Guest

    What am I overlooking?

    use Net::NNTP;

    # create a new Net::NNTP object:
    $server = Net::NNTP->new("news-server.com")
    or die "Can't connect to news server: $@\n";

    ($narticles, $first, $last, $name) =
    $server->group("comp.lang.perl.misc")
    or die "comp.lang.perl.misc\n";
    print "$narticles $first $last $name\n";

    for ($n=$first; $n<=$last; $n++)
    {
    @lines = $server->article($n);
    print map { "$_ \n" } @lines;
    }


    I want to read the article, all I am getting is a reference to the
    array

    the print map { "$_ \n" } @lines;

    this gets me

    ARRAY(0x198e0d4)

    not any text

    Thanks
    jbl
     
    jbl, Dec 17, 2004
    #1
    1. Advertising

  2. jbl wrote:

    > @lines = $server->article($n);
    > print map { "$_ \n" } @lines;


    > I want to read the article, all I am getting is a reference to the
    > array


    So, what's the problem? That's what the docs say you should get from
    article(), a reference to an array.

    Instead of storing that reference as the first element in @lines, you
    probably want something more like this instead:

    my $lines = $server->article($n);
    print map { "$_ \n" } @$lines;

    (I haven't tested this, but I have a hunch that the above will produce
    double-spaced articles, because I think the lines you get back will
    already have \ns.)

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, Dec 17, 2004
    #2
    1. Advertising

  3. jbl

    jbl Guest

    Re: Net::NNTP, retrieving articles help please.......thanks that worked

    On Fri, 17 Dec 2004 10:02:11 -0500, Sherm Pendley
    <> wrote:

    >jbl wrote:
    >
    >> @lines = $server->article($n);
    >> print map { "$_ \n" } @lines;

    >
    >> I want to read the article, all I am getting is a reference to the
    >> array

    >
    >So, what's the problem? That's what the docs say you should get from
    >article(), a reference to an array.
    >
    >Instead of storing that reference as the first element in @lines, you
    >probably want something more like this instead:
    >
    > my $lines = $server->article($n);
    > print map { "$_ \n" } @$lines;
    >
    >(I haven't tested this, but I have a hunch that the above will produce
    >double-spaced articles, because I think the lines you get back will
    >already have \ns.)
    >
    >sherm--
     
    jbl, Dec 17, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KK
    Replies:
    2
    Views:
    596
    Big Brian
    Oct 14, 2003
  2. Anton Bangratz
    Replies:
    0
    Views:
    168
    Anton Bangratz
    Jun 4, 2008
  3. alex
    Replies:
    1
    Views:
    97
    Walter Roberson
    May 24, 2004
  4. Replies:
    7
    Views:
    389
    Dr.Ruud
    Aug 9, 2006
  5. sadie-no-reply

    Posting to nntp newsgroup with Perl (Net::NNTP)

    sadie-no-reply, Mar 4, 2007, in forum: Perl Misc
    Replies:
    3
    Views:
    289
    Jamie
    Mar 5, 2007
Loading...

Share This Page