[29414] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 658 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 18 03:10:08 2007

Date: Wed, 18 Jul 2007 00:09:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 18 Jul 2007     Volume: 11 Number: 658

Today's topics:
    Re: Apache Configuration using PERL <joe@inwap.com>
        catch-ing unsatisfied ``use'' <usenet+meow@aldan.algebra.com>
    Re: How do you retrieve a char from a string? <wahab@chemie.uni-halle.de>
    Re: how to put "if" within a loop <bik.mido@tiscalinet.it>
        lwp::simple get (why it would stop working along with w  rockerd@gmail.com
        lwp::simple get (why it would stop working along with w  rockerd@gmail.com
    Re: lwp::simple get (why it would stop working along wi <noreply@gunnar.cc>
        new CPAN modules on Wed Jul 18 2007 (Randal Schwartz)
        retrieving usenet messages III <zaxfuuq@invalid.net>
    Re: retrieving usenet messages III QoS@domain.invalid
    Re: retrieving usenet messages III <noreply@gunnar.cc>
    Re: retrieving usenet messages III <zaxfuuq@invalid.net>
    Re: retrieving usenet messages III <noreply@gunnar.cc>
    Re: retrieving usenet messages III <zaxfuuq@invalid.net>
    Re: Using the split function <tadmc@seesig.invalid>
    Re: Using the split function <joe@inwap.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 17 Jul 2007 19:38:18 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Apache Configuration using PERL
Message-Id: <KLidnYnHlvC-4ADbnZ2dnUVZ_vKunZ2d@comcast.com>

nicklas.bornstein@gmail.com wrote:

> Im trying to use PERL, generating some of the Apache Configuration.
> I have loaded the module mod_perl, and then do something like;
> 
> <Perl>
> print 'ErrorDocument 404 http://www.google.dk';
> </Perl>

http://perl.apache.org/docs/1.0/guide/config.html#Apache_Configuration_in_Perl
has examples that set variables, they do not use print().  I interpret that
to be something like this:

   <Perl>
   push @ErrorDocument, "404", "http://www.google.dk";
   </Perl>


	-Joe


------------------------------

Date: Wed, 18 Jul 2007 00:12:45 -0400
From: Mikhail Teterin <usenet+meow@aldan.algebra.com>
Subject: catch-ing unsatisfied ``use''
Message-Id: <11025386.LHzVKzhTHH@aldan.algebra.com>

Hello!

I'm trying to modify a script, that uses ImageMagick bindings, to also work
with those of GraphicsMagick.

The script currently does simply:

        use Image::Magick;

For GraphicsMagick one would say:

        use Graphics::Magick;

I tried the following

        use Image::Magick or use Graphics::Magick;
        (syntax error)

And

        try {
                use Image::Magick;
        } catch Error {
                use GraphicsMagick;
        };

The second one does not cause syntax errors, but the script still fails with
an error about being unable to find Image/Magick.pm. The `try/catch' does
not seem to have any effect...

What's the proper way of doing this? Thanks!

        -mi


------------------------------

Date: Tue, 17 Jul 2007 22:10:31 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: How do you retrieve a char from a string?
Message-Id: <f7j7nn$1487$1@nserver.hrz.tu-freiberg.de>

Thierry wrote:
> I have the following string:
> 
> my $greet = "hello";
> print $greet[0]."\n";
> 
> The above clearly doesn't work since $greet is not an array. Is there
> an easy way to access characters at specific index in a string without
> losing $greet as a String?

The canonical method is the one Sherm already mentioned,
but(!):

  ...
  my $greet = 'hello';

  #0
  print substr($greet, 0, 1), "\n";

  #1
  print $greet =~ /.(.)/, "\n";

  #2
  print +(split //, $greet)[2], "\n";

  #3 (only 8bit chars)
  print chr( vec $greet, 3, 8 ), "\n";

  #4 (trounce and print last char)
  print chop $greet, "\n"

Regards

M.




------------------------------

Date: Wed, 18 Jul 2007 00:20:17 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: how to put "if" within a loop
Message-Id: <43eq93pdk3gfuli91odnmnsh04sl7a7tqp@4ax.com>

On Tue, 17 Jul 2007 19:01:19 -0000, Jie <jiehuang001@gmail.com> wrote:

>@lists = ("A", "B", "C");

  use strict;
  use warnings;

>foreach $list (@lists) {

  my $list

>	%{$list} = ();
>	open IN, " < $list.txt";
  
  # possibly better:
  open my $in, '<', "$list.txt"
    or die "something that includes $list and $!\n"

>	while (<IN>) {
>		$_ =~ /(rs\d+)\t([^\t]+)/;

  # either
  $var =~ /$rx/;
  # or
  /$rx/;

>foreach $SNP (%{$lists[0]}) {

Are you sure you don't want keys() there?

>	if ( exists ${$lists[1]}{$SNP} && exists ${$lists[2]}{$SNP}) {
>		print OUT "$SNP\t${$lists[0]}{$SNP}\t${$lists[1]}{$SNP}\t${$lists[2]}
>{$SNP}\n";
>	}
>}

You can make your code slightly more agile:

# untested
my @lists = qw/A B C/;
for (@lists) {
    open my $in, '<',  "$_.txt"
      or die "Can't open `$_.txt': $!\n";
    /(rs\d+)\t([^\t]+)/ and ${$list}{$1}=$2 while <$in>;
}

for my $snp (keys %{$lists[0]}) {
    print $out (join "\t", $snp, map ${$lists[$_]}{$snp}, 0..2), "\n"
      if 2 == grep exists ${$lists[$_]}{$snp}, 1,2;
}


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Tue, 17 Jul 2007 19:17:01 -0700
From:  rockerd@gmail.com
Subject: lwp::simple get (why it would stop working along with wget when fetch still works)
Message-Id: <1184725021.891418.287940@x35g2000prf.googlegroups.com>

Hi Perl People,
Something recently changed on a site that I was fetching and parsing
from with lwp::simple.
Here is the thing: For the longest time I was using get() to grab a
http: site and store it in a scalar which I parsed later. Suddenly I
get an empty but defined scalar with: $html = get($url);

More: when I use fetch on a freebsd system it pulls the page to text
without any problems but when I use wget on a linux system I get a
blank file. Everything used to work. I tried changing my user-agent
headers and have had no luck. The only thing I can see is that the
file has an unknown length.. but I don't know what to do.

Thanks for the advice,
Rocker



------------------------------

Date: Tue, 17 Jul 2007 19:17:04 -0700
From:  rockerd@gmail.com
Subject: lwp::simple get (why it would stop working along with wget when fetch still works)
Message-Id: <1184725024.520457.283820@j4g2000prf.googlegroups.com>

Hi Perl People,
Something recently changed on a site that I was fetching and parsing
from with lwp::simple.
Here is the thing: For the longest time I was using get() to grab a
http: site and store it in a scalar which I parsed later. Suddenly I
get an empty but defined scalar with: $html = get($url);

More: when I use fetch on a freebsd system it pulls the page to text
without any problems but when I use wget on a linux system I get a
blank file. Everything used to work. I tried changing my user-agent
headers and have had no luck. The only thing I can see is that the
file has an unknown length.. but I don't know what to do.

Thanks for the advice,
Rocker



------------------------------

Date: Wed, 18 Jul 2007 04:57:16 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: lwp::simple get (why it would stop working along with wget when fetch still works)
Message-Id: <5g5e2iF3f7qn5U1@mid.individual.net>

rockerd@gmail.com wrote:
> Something recently changed on a site that I was fetching and parsing
> from with lwp::simple.
> Here is the thing: For the longest time I was using get() to grab a
> http: site and store it in a scalar which I parsed later. Suddenly I
> get an empty but defined scalar with: $html = get($url);

Maybe the web server doesn't like requests that are generated by Perl. 
:(  You may want to try without sending a client identifier:

     use LWP::UserAgent;
     my $ua = LWP::UserAgent->new;
     $ua->agent(''); # <- This line may make a difference
     my $response = $ua->get('http://www.perl.org/');
     print $response->content;

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Wed, 18 Jul 2007 04:42:15 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Jul 18 2007
Message-Id: <JLCyEF.18nK@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Acme-SOAP-Dodger-0.001
http://search.cpan.org/~strytoast/Acme-SOAP-Dodger-0.001/
be a hippy 
----
Amazon-SQS-Simple-0.3
http://search.cpan.org/~swhitaker/Amazon-SQS-Simple-0.3/
OO API for accessing the Amazon Simple Queue Service 
----
Amazon-SQS-Simple-0.4
http://search.cpan.org/~swhitaker/Amazon-SQS-Simple-0.4/
OO API for accessing the Amazon Simple Queue Service 
----
App-Bootstrap-0.01
http://search.cpan.org/~skud/App-Bootstrap-0.01/
Bootstrap, stub, or install applications 
----
Barcode-Code128-2.01
http://search.cpan.org/~wrw/Barcode-Code128-2.01/
Generate CODE 128 bar codes 
----
Cache-Memcached-1.24
http://search.cpan.org/~bradfitz/Cache-Memcached-1.24/
client library for memcached (memory cache daemon) 
----
Catalyst-Action-RenderView-ErrorHandler-0.0101
http://search.cpan.org/~andremar/Catalyst-Action-RenderView-ErrorHandler-0.0101/
Custom errorhandling in deployed applications 
----
Catalyst-Plugin-Authentication-0.10001
http://search.cpan.org/~jayk/Catalyst-Plugin-Authentication-0.10001/
Infrastructure plugin for the Catalyst authentication framework. 
----
CrowdControl-0.01
http://search.cpan.org/~skud/CrowdControl-0.01/
User Management Framework for Web Applications 
----
DBD-ODBC-1.14
http://search.cpan.org/~mjevans/DBD-ODBC-1.14/
ODBC Driver for DBI 
----
DBIx-Class-Validation-0.02001
http://search.cpan.org/~claco/DBIx-Class-Validation-0.02001/
Validate all data before submitting to your database. 
----
DateTime-0.39
http://search.cpan.org/~drolsky/DateTime-0.39/
A date and time object 
----
Devel-Fail-Make-1.010
http://search.cpan.org/~mthurn/Devel-Fail-Make-1.010/
a distro that always fails the `make` stage 
----
File-BSED-0.6
http://search.cpan.org/~asksh/File-BSED-0.6/
Search/Replace in Binary Files. 
----
Flickr-License-0.01
http://search.cpan.org/~cowfish/Flickr-License-0.01/
Represents the license of a photo from Flickr 
----
Geo-OGC-Geometry-0.01
http://search.cpan.org/~ajolma/Geo-OGC-Geometry-0.01/
Simple feature geometry classes 
----
Geo-OGC-Geometry-0.02
http://search.cpan.org/~ajolma/Geo-OGC-Geometry-0.02/
Simple feature geometry classes 
----
Gtk2-Ex-Geo-0.54
http://search.cpan.org/~ajolma/Gtk2-Ex-Geo-0.54/
A widget and other classes for geospatial applications 
----
Gtk2-Ex-Geo-0.55
http://search.cpan.org/~ajolma/Gtk2-Ex-Geo-0.55/
A widget and other classes for geospatial applications 
----
HTML-ReplaceForm-0.52
http://search.cpan.org/~markstos/HTML-ReplaceForm-0.52/
easily replace HTML form fields with corresponding values 
----
HTML-Tiny-0.11
http://search.cpan.org/~andya/HTML-Tiny-0.11/
Lightweight, dependency free HTML/XML generation 
----
HTML-Tiny-0.901
http://search.cpan.org/~andya/HTML-Tiny-0.901/
Lightweight, dependency free HTML/XML generation 
----
Linux-loadavg-0.01
http://search.cpan.org/~perlboy/Linux-loadavg-0.01/
get system load averages 
----
Linux-loadavg-0.02
http://search.cpan.org/~perlboy/Linux-loadavg-0.02/
get system load averages 
----
Linux-loadavg-0.03
http://search.cpan.org/~perlboy/Linux-loadavg-0.03/
get system load averages 
----
Module-Finder-v0.1.5
http://search.cpan.org/~ewilhelm/Module-Finder-v0.1.5/
find and query modules in @INC and/or elsewhere 
----
Module-MultiConf-0.0100_05
http://search.cpan.org/~oliver/Module-MultiConf-0.0100_05/
Configure and validate your app modules in one go 
----
MooseX-Method-0.34
http://search.cpan.org/~berle/MooseX-Method-0.34/
Method declaration with type checking 
----
MooseX-Method-0.35
http://search.cpan.org/~berle/MooseX-Method-0.35/
Method declaration with type checking 
----
Nagios-Plugins-Memcached-0.01
http://search.cpan.org/~zigorou/Nagios-Plugins-Memcached-0.01/
Nagios plugin to observe memcached. 
----
Net-LDAP-HTMLWidget-0.02
http://search.cpan.org/~andremar/Net-LDAP-HTMLWidget-0.02/
Like FromForm but with Net::LDAP and HTML::Widget 
----
Net-RawIP-0.22_01
http://search.cpan.org/~sbonds/Net-RawIP-0.22_01/
Perl extension for manipulate raw ip packets with interface to libpcap 
----
Parse-Apache-ServerStatus-Extended-0.02
http://search.cpan.org/~mizzy/Parse-Apache-ServerStatus-Extended-0.02/
Simple module to parse apache's extended server-status. 
----
Pod-Manual-0.06
http://search.cpan.org/~yanick/Pod-Manual-0.06/
Aggregates several PODs into a single manual 
----
SSN-Validate-0.16
http://search.cpan.org/~kmeltz/SSN-Validate-0.16/
Perl extension to do SSN Validation 
----
SVK-v2.0.1_91
http://search.cpan.org/~clkao/SVK-v2.0.1_91/
A Distributed Version Control System 
----
Set-IntSpan-Fast-1.0.1
http://search.cpan.org/~andya/Set-IntSpan-Fast-1.0.1/
Fast handling of sets containing integer spans. 
----
Test-Config-System-0.60
http://search.cpan.org/~iank/Test-Config-System-0.60/
System configuration related unit tests 
----
Text-CSV-Unicode-0.01
http://search.cpan.org/~rmbarker/Text-CSV-Unicode-0.01/
comma-separated values manipulation routines with potentially wide character data 
----
Text-Restructured-0.003033
http://search.cpan.org/~nodine/Text-Restructured-0.003033/
Perl implementation of reStructuredText parser 
----
Text-Starfish-1.07
http://search.cpan.org/~vlado/Text-Starfish-1.07/
and starfish - A Perl-based System for Text-Embedded Programming and Preprocessing 
----
WWW-Myspace-Data-0.13
http://search.cpan.org/~oalders/WWW-Myspace-Data-0.13/
WWW::Myspace database interaction 
----
WebService-30Boxes-API-event-0.02
http://search.cpan.org/~chitoiup/WebService-30Boxes-API-event-0.02/
Perl accessor interface for the hash returned by WebService::30Boxes::API::call("events.Get) 
----
WebService-CRUST-0.7
http://search.cpan.org/~heschong/WebService-CRUST-0.7/
A lightweight Client for making REST calls 
----
ack-1.64
http://search.cpan.org/~petdance/ack-1.64/
grep-like text finder 
----
parrot-0.4.14
http://search.cpan.org/~particle/parrot-0.4.14/
----
re-engine-Plan9-0.14
http://search.cpan.org/~avar/re-engine-Plan9-0.14/
Plan 9 regular expression engine 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Tue, 17 Jul 2007 20:24:03 -0700
From: "merl the perl" <zaxfuuq@invalid.net>
Subject: retrieving usenet messages III
Message-Id: <AcednX7A-f0vwADbnZ2dnUVZ_jWdnZ2d@comcast.com>

I've been trying to herd usenet messages into files on my machine.  The 
latest setback I had was that I had to do a clean sweep on my machine (not 
perl related, itunes with bundled Quicktime killed my primary identity with 
a script that would make it a virus by any other name).  Unfortunately, I 
didn't save my last version of this script:
#!/usr/bin/env perl
use strict;
use warnings;
use Net::NNTP;

my $nntp = Net::NNTP->new('newsgroups.comcast.net', ( Debug => 1) );
my $USER = 'zaxfuuq@invalid.net';
my $PASS = '';
my $SERVER = 'newsgroups.comcast.net';
my $PORT = 119;

#$nntp->authinfo($USER,$PASS) or die $!;
$nntp->group('comp.lang.perl.misc')
   or die "failed to set group c.l.p.m.\n";
my $msg_ids_ref = $nntp->newnews(time() - 24*60*60);
die "Failed to retrieve message ids\n" unless @{$msg_ids_ref};

open my $ofh, '>', 'articles.txt'
   or die "Cannot open articles.txt: $!";
for my $msg_id (@{$msg_ids_ref}) {
   $nntp->article($msg_id, $ofh)
      or die "Failed to retrieve article $msg_id\n";
}
close $ofh;
__END__
With a semantically-acceptable constructor I get:
Net::NNTP>>> Net::NNTP(2.22)
Net::NNTP>>>   Net::Cmd(2.24)
Net::NNTP>>>     Exporter(5.562)
Net::NNTP>>>   IO::Socket::INET(1.25)
Net::NNTP>>>     IO::Socket(1.26)
Net::NNTP>>>       IO::Handle(1.21)
Net::NNTP=GLOB(0x1832958)<<< 200 News.GigaNews.Com
Net::NNTP=GLOB(0x1832958)>>> MODE READER
Net::NNTP=GLOB(0x1832958)<<< 480 authentication required
Net::NNTP=GLOB(0x1832958)>>> GROUP comp.lang.perl.misc
Net::NNTP=GLOB(0x1832958)<<< 480 authentication required
failed to set group c.l.p.m.
Net::NNTP=GLOB(0x1832958)>>> QUIT
Net::NNTP=GLOB(0x1832958)<<< 205 goodbye
, so it looks like there's trouble with:
$nntp->group('comp.lang.perl.misc')
   or die "failed to set group c.l.p.m.\n";
, and I seek comment on it.  I've read cpan's net::nntp 4 times.  Here's 
what the group method shows:
group ( [ GROUP ] )
Set and/or get the current group. If GROUP is not given then information is 
returned on the current group
In a scalar context it returns the group name.
In an array context the return value is a list containing, the number of 
articles in the group, the number of the first article, the number of the 
last article and the group name.
I seem to be stuck again.  Thanks in advance.
-- 
merl the perl 




------------------------------

Date: Wed, 18 Jul 2007 01:22:22 GMT
From: QoS@domain.invalid
Subject: Re: retrieving usenet messages III
Message-Id: <iXdni.7979$fj5.4837@trnddc08>


"merl the perl" <zaxfuuq@invalid.net> wrote in message-id:  <AcednX7A-f0vwADbnZ2dnUVZ_jWdnZ2d@comcast.com>

> 
> I've been trying to herd usenet messages into files on my machine.  The 
> latest setback I had was that I had to do a clean sweep on my machine (not 
> perl related, itunes with bundled Quicktime killed my primary identity with 
> a script that would make it a virus by any other name).  Unfortunately, I 
> didn't save my last version of this script:
> #!/usr/bin/env perl
> use strict;
> use warnings;
> use Net::NNTP;
> 
> my $nntp = Net::NNTP->new('newsgroups.comcast.net', ( Debug => 1) );
> my $USER = 'zaxfuuq@invalid.net';
> my $PASS = '';
> my $SERVER = 'newsgroups.comcast.net';
> my $PORT = 119;
> 
> #$nntp->authinfo($USER,$PASS) or die $!;
> $nntp->group('comp.lang.perl.misc')
>    or die "failed to set group c.l.p.m.\n";
> my $msg_ids_ref = $nntp->newnews(time() - 24*60*60);

According to new emerging NNTP standards XOVER is the preferred method
of gathering new headers moving forward; although it would be a good idea
to fall back to newnews <since> in the case that XOVER is not supported.

> die "Failed to retrieve message ids\n" unless @{$msg_ids_ref};
> 
> open my $ofh, '>', 'articles.txt'
>    or die "Cannot open articles.txt: $!";
> for my $msg_id (@{$msg_ids_ref}) {
>    $nntp->article($msg_id, $ofh)
>       or die "Failed to retrieve article $msg_id\n";
> }
> close $ofh;
> __END__
> With a semantically-acceptable constructor I get:
> Net::NNTP>>> Net::NNTP(2.22)
> Net::NNTP>>>   Net::Cmd(2.24)
> Net::NNTP>>>     Exporter(5.562)
> Net::NNTP>>>   IO::Socket::INET(1.25)
> Net::NNTP>>>     IO::Socket(1.26)
> Net::NNTP>>>       IO::Handle(1.21)
> Net::NNTP=GLOB(0x1832958)<<< 200 News.GigaNews.Com
> Net::NNTP=GLOB(0x1832958)>>> MODE READER
> Net::NNTP=GLOB(0x1832958)<<< 480 authentication required
> Net::NNTP=GLOB(0x1832958)>>> GROUP comp.lang.perl.misc

You are not logged into the server.  The group and most other commands
will not work untill you log on, since this server requires authentication.

> Net::NNTP=GLOB(0x1832958)<<< 480 authentication required
> failed to set group c.l.p.m.
> Net::NNTP=GLOB(0x1832958)>>> QUIT
> Net::NNTP=GLOB(0x1832958)<<< 205 goodbye
> , so it looks like there's trouble with:
> $nntp->group('comp.lang.perl.misc')
>    or die "failed to set group c.l.p.m.\n";
> , and I seek comment on it.  I've read cpan's net::nntp 4 times.  Here's 
> what the group method shows:
> group ( [ GROUP ] )
> Set and/or get the current group. If GROUP is not given then information is 
> returned on the current group
> In a scalar context it returns the group name.
> In an array context the return value is a list containing, the number of 
> articles in the group, the number of the first article, the number of the 
> last article and the group name.
> I seem to be stuck again.  Thanks in advance.
> -- 
> merl the perl 

It would be best if you carefully parsed anything that the server sends
back to your client, if you study the Net::NNTP debug information, you
will notice that the messages coming from the server are denoted with
a '<<< '.

J




------------------------------

Date: Wed, 18 Jul 2007 04:01:18 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: retrieving usenet messages III
Message-Id: <5g5aplF3feh6jU1@mid.individual.net>

merl the perl wrote:
>  
> #!/usr/bin/env perl
> use strict;
> use warnings;
> use Net::NNTP;
> 
> my $nntp = Net::NNTP->new('newsgroups.comcast.net', ( Debug => 1) );
> my $USER = 'zaxfuuq@invalid.net';
> my $PASS = '';
> my $SERVER = 'newsgroups.comcast.net';
> my $PORT = 119;
> 
> #$nntp->authinfo($USER,$PASS) or die $!;
--^
Wake up! Be more careful before posting.

> $nntp->group('comp.lang.perl.misc')
>    or die "failed to set group c.l.p.m.\n";
> my $msg_ids_ref = $nntp->newnews(time() - 24*60*60);
> die "Failed to retrieve message ids\n" unless @{$msg_ids_ref};
> 
> open my $ofh, '>', 'articles.txt'
>    or die "Cannot open articles.txt: $!";
> for my $msg_id (@{$msg_ids_ref}) {
>    $nntp->article($msg_id, $ofh)
>       or die "Failed to retrieve article $msg_id\n";
> }
> close $ofh;
> __END__
> With a semantically-acceptable constructor I get:

In other words you were using some other script but the one above. 
Please copy and paste the script you used yourself, with the username 
and password as the _only_ exceptions.

> Net::NNTP>>> Net::NNTP(2.22)
> Net::NNTP>>>   Net::Cmd(2.24)
> Net::NNTP>>>     Exporter(5.562)
> Net::NNTP>>>   IO::Socket::INET(1.25)
> Net::NNTP>>>     IO::Socket(1.26)
> Net::NNTP>>>       IO::Handle(1.21)
> Net::NNTP=GLOB(0x1832958)<<< 200 News.GigaNews.Com
> Net::NNTP=GLOB(0x1832958)>>> MODE READER
> Net::NNTP=GLOB(0x1832958)<<< 480 authentication required
> Net::NNTP=GLOB(0x1832958)>>> GROUP comp.lang.perl.misc
> Net::NNTP=GLOB(0x1832958)<<< 480 authentication required
> failed to set group c.l.p.m.
> Net::NNTP=GLOB(0x1832958)>>> QUIT
> Net::NNTP=GLOB(0x1832958)<<< 205 goodbye

That's the info you are supposed to study when debugging. From that it's 
clear that the script didn't attempt to authenticate.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Wed, 18 Jul 2007 00:47:46 -0700
From: "merl the perl" <zaxfuuq@invalid.net>
Subject: Re: retrieving usenet messages III
Message-Id: <9b6dnfVLmK0YBgDbnZ2dnUVZ_rSinZ2d@comcast.com>


"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message 
news:5g5aplF3feh6jU1@mid.individual.net...
> merl the perl wrote:

>> #$nntp->authinfo($USER,$PASS) or die $!;
> --^
> Wake up! Be more careful before posting.
I missed it!

>> With a semantically-acceptable constructor I get:
>
> In other words you were using some other script but the one above. Please 
> copy and paste the script you used yourself, with the username and 
> password as the _only_ exceptions.
> That's the info you are supposed to study when debugging. From that it's 
> clear that the script didn't attempt to authenticate.
That's what this is:
#!/usr/bin/env perl
use strict;
use warnings;
use Net::NNTP;

my $nntp = Net::NNTP->new('newsgroups.comcast.net', ( Debug => 1) );
my $USER = '';
my $PASS = '';
my $SERVER = 'newsgroups.comcast.net';
my $PORT = 119;

$nntp->authinfo($USER,$PASS) or die $!;
$nntp->group('comp.lang.perl.misc')
   or die "failed to set group c.l.p.m.\n";
my $msg_ids_ref = $nntp->newnews(time() - 24*60*60);
die "Failed to retrieve message ids\n" unless @{$msg_ids_ref};

open my $ofh, '>', 'articles.txt'
   or die "Cannot open articles.txt: $!";
for my $msg_id (@{$msg_ids_ref}) {
   $nntp->article($msg_id, $ofh)
      or die "Failed to retrieve article $msg_id\n";
}
close $ofh;
__END__
This gives the following debug info:
Net::NNTP>>> Net::NNTP(2.22)
Net::NNTP>>>   Net::Cmd(2.24)
Net::NNTP>>>     Exporter(5.562)
Net::NNTP>>>   IO::Socket::INET(1.25)
Net::NNTP>>>     IO::Socket(1.26)
Net::NNTP>>>       IO::Handle(1.21)
Net::NNTP=GLOB(0x18329d0)<<< 200 News.GigaNews.Com
Net::NNTP=GLOB(0x18329d0)>>> MODE READER

Net::NNTP=GLOB(0x18329d0)<<< 480 authentication required
Net::NNTP=GLOB(0x18329d0)>>> AUTHINFO USER zax

Net::NNTP=GLOB(0x18329d0)<<< 381 more authentication required
Net::NNTP=GLOB(0x18329d0)>>> AUTHINFO PASS ....
Net::NNTP=GLOB(0x18329d0)<<< 281 News.GigaNews.Com
Net::NNTP=GLOB(0x18329d0)>>> GROUP comp.lang.perl.misc

Net::NNTP=GLOB(0x18329d0)<<< 211 132595 501456 634050 comp.lang.perl.misc
Net::NNTP=GLOB(0x18329d0)>>> NEWNEWS comp.lang.perl.misc 070717 073757 GMT

Net::NNTP=GLOB(0x18329d0)<<< 502 NEWNEWS permission denied (command 
disabled)
Can't use an undefined value as an ARRAY reference at perl2.pl line 16.
Net::NNTP=GLOB(0x18329d0)>>> QUIT

Net::NNTP=GLOB(0x18329d0)<<< 205 goodbye
It looks like I got a step farther.  I'll need some time before I can 
address the other response.  Thanks.
-- 
merl the perl





------------------------------

Date: Wed, 18 Jul 2007 07:08:19 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: retrieving usenet messages III
Message-Id: <5g5lo9F3fjg6oU1@mid.individual.net>

merl the perl wrote:
> "Gunnar Hjalmarsson" wrote:
>> merl the perl wrote:
>>> With a semantically-acceptable constructor I get:
>>
>> In other words you were using some other script but the one above. Please 
>> copy and paste the script you used yourself, with the username and 
>> password as the _only_ exceptions.
>
> That's what this is:
> #!/usr/bin/env perl
> use strict;
> use warnings;
> use Net::NNTP;
> 
> my $nntp = Net::NNTP->new('newsgroups.comcast.net', ( Debug => 1) );

<snip>

I thought that the Debug argument was still surrounded by curly braces. 
Sorry, my mistake.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Wed, 18 Jul 2007 02:34:54 -0700
From: "merl the perl" <zaxfuuq@invalid.net>
Subject: Re: retrieving usenet messages III
Message-Id: <mu6dnZWZLJ8DKQDbnZ2dnUVZ_uKknZ2d@comcast.com>


"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message 
news:5g5lo9F3fjg6oU1@mid.individual.net...
> merl the perl wrote:
>> "Gunnar Hjalmarsson" wrote:
>>> merl the perl wrote:
>>>> With a semantically-acceptable constructor I get:
>>>
>>> In other words you were using some other script but the one above. 
>>> Please copy and paste the script you used yourself, with the username 
>>> and password as the _only_ exceptions.
>>
>> That's what this is:
>> #!/usr/bin/env perl
>> use strict;
>> use warnings;
>> use Net::NNTP;
>>
>> my $nntp = Net::NNTP->new('newsgroups.comcast.net', ( Debug => 1) );
>
> <snip>
>
> I thought that the Debug argument was still surrounded by curly braces. 
> Sorry, my mistake.
IIRC, you were the first to mention that the braces were a problem.  I read 
aloud the names of every perl function tonight.  IIRC, abs is the first and 
write is the last.
--
merl the perl 




------------------------------

Date: Tue, 17 Jul 2007 17:36:34 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Using the split function
Message-Id: <slrnf9qh3i.ofn.tadmc@tadmc30.sbcglobal.net>

Simon <shmh@bigpond.net.au> wrote:

> "Lars Eighner" <usenet@larseighner.com> wrote in message 
> news:slrnf9pb0h.ek7.usenet@goodwill.larseighner.com...
>> In our last episode,
>> <Ih1ni.8443$4A1.1652@news-server.bigpond.net.au>,
>> the lovely and talented Simon
>> broadcast on comp.lang.perl.misc:

>>> Im 
>>> having
>>> problems with the split function. Please see below..
>>
>> Sounds suspiciously like homework.
>>
>>> Ive deliberately left out the split function 


> Eighner sounds suspiciously like "a.....s"
                                    ^^^^^^^
                                    ^^^^^^^

"abducts" ?

"abscess" ?

"assumes" ?

"accuses"?




Anyway, shmh@bigpond.net.au sounds suspiciously like "killfile me please".

As you wish.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Tue, 17 Jul 2007 20:16:09 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Using the split function
Message-Id: <F5WdnXfL34mfGwDbnZ2dnUVZ_qq3nZ2d@comcast.com>

Simon wrote:

> open H,">6.11.txt" or die "6.11.txt $!";
> open S,">6.7.txt" or die "6.7.txt $!";
> open L,">6.5.txt" or die "6.5.txt $!";
> open C,">6.2.txt" or die "6.2.txt $!";

Here's a hint on how to avoid that ugliness:
   Open a new output file only when a new version is detected.
	-Joe

P.S. Note how I used split() for you.

C:\TEMP>type test-sys.pl
#!/usr/bin/perl
# Purpose: Shows how to deal multiple files based in value from input

use strict; use warnings;

my %files;      # Hash of file handles
my $system;     # Name of current system

while (my $line = <DATA>) {
   $system = $1 if $line =~ /^(\S+)$/;
   my($name,$type,$ver) = split ' ',$line or next;
   next unless $name eq 'BuildVersion' and $type eq 'REG_SZ';
   my $fh = $files{$ver};        # File handles, indexed by version number
   unless ($fh) {                # If first time for this version
     my $out_file = "test-sys-$ver.txt";
     open $fh,'>',$out_file or die "Cannot write to $out_file - $!\n";
     $files{$ver} = $fh;
   }
   print $fh "$system: $ver\n" or warn "Can't write '$system: $ver': $!\n";
}
print "Read $. lines; created files for ",join(' ',sort keys %files),"\n";

__DATA__
alpha
     BuildVersion        REG_SZ  6.11
bravo
     BuildVersion        REG_SZ  6.10
delta
     BuildVersion        REG_SZ  6.7
gamma
     BuildVersion        REG_SZ  6.11

C:\TEMP>perl test-sys.pl
Read 8 lines; created files for 6.10 6.11 6.7

C:\TEMP>dir test-sys*
  Volume in drive C is DRIVE_C
  Volume Serial Number is 090E-3069

  Directory of C:\TEMP

07/17/2007  08:11 PM                13 test-sys-6.10.txt
07/17/2007  08:11 PM                26 test-sys-6.11.txt
07/17/2007  08:11 PM                12 test-sys-6.7.txt
07/17/2007  08:10 PM               983 test-sys.pl
                4 File(s)          1,034 bytes
                0 Dir(s)  36,839,247,872 bytes free

C:\TEMP>type test-sys*.txt

test-sys-6.10.txt


bravo: 6.10

test-sys-6.11.txt


alpha: 6.11
gamma: 6.11

test-sys-6.7.txt


delta: 6.7

C:\TEMP>


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 658
**************************************


home help back first fref pref prev next nref lref last post