[28948] in Perl-Users-Digest
Perl-Users Digest, Issue: 192 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 4 14:09:56 2007
Date: Sun, 4 Mar 2007 11:09:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 4 Mar 2007 Volume: 11 Number: 192
Today's topics:
<INPUT> <gabyr@yahoo.co.uk>
Re: <INPUT> anno4000@radom.zrz.tu-berlin.de
Re: <INPUT> <no@email.com>
Re: <INPUT> <wahab-mail@gmx.de>
Calling a module style question <sigzero@gmail.com>
Re: Calling a module style question <uri@stemsystems.com>
convert wikipedia to html? <ppc@cheapbooks.com>
Re: Expressing AND, OR, and NOT in a Single Pattern <nobull67@gmail.com>
Re: IP in range? <stoupa@practisoft.cz>
Is it ok to change $ENV{'QUERY_STRING'} before "use CGI <gypark@gmail.com>
Re: Is it ok to change $ENV{'QUERY_STRING'} before "use anno4000@radom.zrz.tu-berlin.de
Re: need perl tutor, will PAY <hjp-usenet2@hjp.at>
new CPAN modules on Sun Mar 4 2007 (Randal Schwartz)
Re: opendir function. <klaus03@gmail.com>
Re: pattern serach over many files <tadmc@augustmail.com>
Posting to nntp newsgroup with Perl (Net::NNTP) <sadie001@nopsam.plannet.nl>
Re: Posting to nntp newsgroup with Perl (Net::NNTP) <hjp-usenet2@hjp.at>
Re: Q on regex of LWP::Simple data <tadmc@augustmail.com>
Re: Q on regex of LWP::Simple data anno4000@radom.zrz.tu-berlin.de
Re: quick scope question <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 04 Mar 2007 17:19:33 +0100
From: Gabriel <gabyr@yahoo.co.uk>
Subject: <INPUT>
Message-Id: <eseriq$4b3$1@cormoran.emeteo.local>
How can I do a program that receive a file or any string, and count its
\t, \n or anything that I want?
perl miprogram jjjj.txt
\n ---> 12
\t ---> 7
or
perl miprogram bla blablba bal balb balba
\n ---> 1
\t ---> 0
Thanks.
------------------------------
Date: 4 Mar 2007 16:59:13 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: <INPUT>
Message-Id: <550c71F22rth8U2@mid.dfncis.de>
Gabriel <gabyr@yahoo.co.uk> wrote in comp.lang.perl.misc:
> How can I do a program that receive a file or any string, and count its
> \t, \n or anything that I want?
>
> perl miprogram jjjj.txt
> \n ---> 12
> \t ---> 7
>
> or
>
> perl miprogram bla blablba bal balb balba
> \n ---> 1
> \t ---> 0
How would your program know that the first text is a file name and
the second a literal text to run the count on? You'll have to specify
that somehow.
Apart from that, Perl's tool for character counting id tr///. Look it
up in perlop.
Anno
------------------------------
Date: Sun, 04 Mar 2007 16:59:48 +0000
From: Brian Wakem <no@email.com>
Subject: Re: <INPUT>
Message-Id: <550c84F22rh3vU1@mid.individual.net>
Gabriel wrote:
> How can I do a program that receive a file or any string, and count its
> \t, \n or anything that I want?
>
> perl miprogram jjjj.txt
> \n ---> 12
> \t ---> 7
>
> or
>
> perl miprogram bla blablba bal balb balba
> \n ---> 1
> \t ---> 0
perldoc -q count
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: Sun, 04 Mar 2007 18:14:13 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: <INPUT>
Message-Id: <esev4g$4lj$1@mlucom4.urz.uni-halle.de>
Gabriel wrote:
> How can I do a program that receive a file or any string, and count its
> \t, \n or anything that I want?
>
> perl miprogram jjjj.txt
> \n ---> 12
> \t ---> 7
>
> or
>
> perl miprogram bla blablba bal balb balba
> \n ---> 1
> \t ---> 0
>
In addition to the correct ways - which were
already mentioned, you could always use
someting 'traditional' like (under *n*x) -
- count anything (eg. the string "XYZ") that
is in file "file.dat":
$ perl -0777 -ne 'print 0+@{[/XYZ/g]}' file.dat
or, count something that comes on a
string, eg. the "\n":
$ echo 'some \
text \
with \
newlines \
here ' | perl -0777 -ne 'print 0+@{[/\n/g]}'
(returns: "5" !)
But stick to the perldoc variants
(which were mentioned before) if
possible.
Regards
Mirco
------------------------------
Date: 4 Mar 2007 10:03:47 -0800
From: "Robert Hicks" <sigzero@gmail.com>
Subject: Calling a module style question
Message-Id: <1173031426.917249.128030@8g2000cwh.googlegroups.com>
I have a subroutine that will be called every now and then and only
manually. It uses a module that isn't used by anything else in my
application. Is it okay (i.e. good style) to put the "use" statement
in that subroutine so it only get loaded when that specific subroutine
is called?
Robert
------------------------------
Date: Sun, 04 Mar 2007 13:13:21 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Calling a module style question
Message-Id: <x7abysnagu.fsf@mail.sysarch.com>
>>>>> "RH" == Robert Hicks <sigzero@gmail.com> writes:
RH> I have a subroutine that will be called every now and then and only
RH> manually. It uses a module that isn't used by anything else in my
RH> application. Is it okay (i.e. good style) to put the "use" statement
RH> in that subroutine so it only get loaded when that specific subroutine
RH> is called?
that will force it to be loaded at compile time so it will be loaded
always. the require function will load a module at runtime which is what
you want.
perldoc -f use
perldoc -f require
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 4 Mar 2007 10:29:33 -0800
From: "dt" <ppc@cheapbooks.com>
Subject: convert wikipedia to html?
Message-Id: <1173032973.454043.282960@i80g2000cwc.googlegroups.com>
I have looked at all the perl modules and code for getting wikipedia
data to html and I have found nothing that does that or nothing that
works.
the WebService-SimpleAPI-Wikipedia-0.01 does not seem to be a working
distro (perl Makefile.pl does not run)
is there an easy way to convert a WIKI page to html by querying the
site, keeping all the formatting?
------------------------------
Date: 4 Mar 2007 04:56:02 -0800
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Expressing AND, OR, and NOT in a Single Pattern
Message-Id: <1173012961.944286.220260@c51g2000cwc.googlegroups.com>
On Mar 1, 10:10 pm, xhos...@gmail.com wrote:
> "usaims" <usa...@yahoo.com> wrote:
> > I'm having a little problem with this example in the Perl Cookbook.
>
> > True if pattern BAD does not match, but pattern GOOD does:
> > /(?=(?:(?!BAD).)*$)GOOD/s
>
> Every character from the start of the match to the end of the string
> has to not (be the start of a) match to BAD. However, if BAD occurs before
> GOOD, the regex can still match, simply by not initiating the match until
> after the B of BAD.
>
> You want to the forced exclusion to start at the beginning of the string
> and run to the end:
>
> /^(?=(?:(?!BAD).)*$).*GOOD/;
That's exponentially (er, factorially?) ineficient!
/^(?!.*BAD).*GOOD/;
> But I'd just use two different regex.
Yes, of course, that's still the best way.
------------------------------
Date: Sun, 4 Mar 2007 05:48:41 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: IP in range?
Message-Id: <esem5o$1lej$1@ns.felk.cvut.cz>
"Mumia W." <paduille.4060.mumia.w+nospam@earthlink.net> pí¨e v diskusním
príspevku news:tlrGh.8939$tD2.3044@newsread1.news.pas.earthlink.net...
> On 03/03/2007 07:56 PM, Petr Vileta wrote:
>> I have file where IP or IP ranges are written in different allowed
>> formats like this
>>
>> 183.12.0.0/255.255.0.0
>> 212.24/16
>> 42.11.
>>
>> How can I check if some unique IP is in range at some line? For example
>> 183.12.21.129 is in range at line 1 above.
>>
>
> NetAddr::IP will do this for you.
>
> use strict;
> use warnings;
> require NetAddr::IP;
>
> my $ip = new NetAddr::IP ('183.12.21.129');
> my $netaddr = new NetAddr::IP ('183.12.0.0','16');
>
> if ($netaddr->contains($ip)) {
> print "$ip is inside $netaddr\n";
> }
>
Thank you, this helped me.
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
------------------------------
Date: 4 Mar 2007 06:31:21 -0800
From: "Raymundo" <gypark@gmail.com>
Subject: Is it ok to change $ENV{'QUERY_STRING'} before "use CGI;" is called..?
Message-Id: <1173018681.500818.201390@c51g2000cwc.googlegroups.com>
Dear,
When a web-broswer sends a GET request, I can get "keywords" or
"param"eters using CGI module, as you know:
$q = new CGI;
$name = $q->param('name');
However, when browser's request includes multi-byte characters, they
can be encoded using UTF-8 or EUC-KR(in Korea, for example) according
to the option in the browswer. ("Send URL in UTF-8" in IE,
"network.standard-url.encode-utf8" in FF, etc.)
At first, I tried to check the value which I got from $q->param() like
this:
$name = $q->param("name");
$name = check_and_convert($name);
...
sub check_and_convert {
# this subroutine guesses the encoding of parameter using
Encode::Guess
# if not UTF-8, it converts the parameter to UTF-8 encoded string and
return it
}
But there are so many parameters and also so many codes using them. I
found that it's almost impossible, or so inconvenient to check
whenever the parameters are fetched.
Second, I tried to "check and convert" $ENV{QUERY_STRING} value before
a CGI object is created:
# convert QUERY_STRING to UTF-8 here
$ENV{QUERY_STRING} = check_and_convert($ENV{QUERY_STRING});
# then create CGI object
$q = new CGI;
# I can get name=XXX and XXX is encoded in UTF-8
$name $q->param("name")
In this case, I think, I don't need to check each parameter in any
other following codes... All the values are now UTF-8 encoded.
As far as I had tested, it looked successful. But I'm not sure that
such approach is good(?) and safe. (I think it's somewhat tricky to
change the environment variable in script..)
Is there any other environment variable or anything else that I should
check before "new CGI;" is called? Can I be sure that I'll not lose
any information when I change QUERY_STRING?
Any advices would be appreciated. I'm soryy I'm not good at English.
Raymundo at South Korea.
------------------------------
Date: 4 Mar 2007 16:53:59 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Is it ok to change $ENV{'QUERY_STRING'} before "use CGI;" is called..?
Message-Id: <550bt7F22rth8U1@mid.dfncis.de>
Raymundo <gypark@gmail.com> wrote in comp.lang.perl.misc:
> Dear,
>
> When a web-broswer sends a GET request, I can get "keywords" or
> "param"eters using CGI module, as you know:
> $q = new CGI;
> $name = $q->param('name');
>
> However, when browser's request includes multi-byte characters, they
> can be encoded using UTF-8 or EUC-KR(in Korea, for example) according
> to the option in the browswer. ("Send URL in UTF-8" in IE,
> "network.standard-url.encode-utf8" in FF, etc.)
>
> At first, I tried to check the value which I got from $q->param() like
> this:
>
> $name = $q->param("name");
> $name = check_and_convert($name);
> ...
>
> sub check_and_convert {
> # this subroutine guesses the encoding of parameter using
> Encode::Guess
> # if not UTF-8, it converts the parameter to UTF-8 encoded string and
> return it
> }
>
>
> But there are so many parameters and also so many codes using them. I
> found that it's almost impossible, or so inconvenient to check
> whenever the parameters are fetched.
>
>
> Second, I tried to "check and convert" $ENV{QUERY_STRING} value before
> a CGI object is created:
>
> # convert QUERY_STRING to UTF-8 here
> $ENV{QUERY_STRING} = check_and_convert($ENV{QUERY_STRING});
> # then create CGI object
> $q = new CGI;
> # I can get name=XXX and XXX is encoded in UTF-8
> $name $q->param("name")
>
> In this case, I think, I don't need to check each parameter in any
> other following codes... All the values are now UTF-8 encoded.
>
> As far as I had tested, it looked successful. But I'm not sure that
> such approach is good(?) and safe. (I think it's somewhat tricky to
> change the environment variable in script..)
>
> Is there any other environment variable or anything else that I should
> check before "new CGI;" is called? Can I be sure that I'll not lose
> any information when I change QUERY_STRING?
>
> Any advices would be appreciated. I'm soryy I'm not good at English.
> Raymundo at South Korea.
You should avoid changing the environment like that. Use the interface
that CGI provides. The ->Vars method gives you a hash that contains
the parameter values keyed by their names. Convert it as follows
(untested):
my $param = $q->Vars;
$_ = check_and_convert( $_) for values %$param;
This supposes that check_and_convert() leaves null bytes alone. If
that isn't sure, use
$_ = join( "\0", map check_and_convert( $_), split /\0/, $_) for
values %$param;
See perldoc CGI for the significance of null bytes in the values.
Either way you will convert all values in one go. Use the converted
hash instead of the ->param method for parameter access.
Anno
------------------------------
Date: Sun, 4 Mar 2007 12:00:49 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: need perl tutor, will PAY
Message-Id: <slrneul9n1.ejc.hjp-usenet2@yoyo.hjp.at>
On 2007-03-04 00:22, HighRiskMommy@gmail.com <HighRiskMommy@gmail.com> wrote:
> i need a perl tutor, preferably one with bioinformatics
> knowledge..preferably in the NY area, but if you are not, we can still
> talk on the phone.
>
> i will pay you. please contact me.
This newsgroup isn't intended for job offers. A better place to search
for perl programmers, tutors, etc. is http://jobs.perl.org/
hp
--
_ | Peter J. Holzer | Es ist ganz einfach ihn zu verstehen, wenn
|_|_) | Sysadmin WSR | man nur alle wichtigen Worte im Satz durch
| | | hjp@hjp.at | andere ersetzt.
__/ | http://www.hjp.at/ | -- Nils Ketelsen in danr
------------------------------
Date: Sun, 4 Mar 2007 05:42:13 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Mar 4 2007
Message-Id: <JED6ID.t7M@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.
Compress-Raw-Bzip2-2.004
http://search.cpan.org/~pmqs/Compress-Raw-Bzip2-2.004/
Low-Level Interface to bzip2 compression library
----
Compress-Raw-Zlib-2.004
http://search.cpan.org/~pmqs/Compress-Raw-Zlib-2.004/
Low-Level Interface to zlib compression library
----
Compress-Zlib-2.004
http://search.cpan.org/~pmqs/Compress-Zlib-2.004/
Interface to zlib compression library
----
Config-XPath-0.07
http://search.cpan.org/~pevans/Config-XPath-0.07/
a module for retrieving configuration data from XML files by using XPath queries
----
DBIx-SearchBuilder-1.47
http://search.cpan.org/~ruz/DBIx-SearchBuilder-1.47/
Encapsulate SQL queries and rows in simple perl objects
----
Egg-Plugin-SessionKit-0.07
http://search.cpan.org/~lushe/Egg-Plugin-SessionKit-0.07/
Session plugin for Egg.
----
Egg-Plugin-SessionKit-Auth-0.06
http://search.cpan.org/~lushe/Egg-Plugin-SessionKit-Auth-0.06/
The authentication function is offered by using the session.
----
Egg-Release-1.14
http://search.cpan.org/~lushe/Egg-Release-1.14/
WEB application framework release version.
----
File-FilterFuncs-0.521
http://search.cpan.org/~mumiaw/File-FilterFuncs-0.521/
specify filter functions for files
----
File-Iterator-0.13
http://search.cpan.org/~swhitaker/File-Iterator-0.13/
an object-oriented Perl module for iterating across files in a directory tree.
----
Filter-1.33
http://search.cpan.org/~pmqs/Filter-1.33/
----
Getopt-Param-v0.0.1
http://search.cpan.org/~dmuey/Getopt-Param-v0.0.1/
param() style opt handling
----
Google-Data-JSON-v0.0.4
http://search.cpan.org/~takeru/Google-Data-JSON-v0.0.4/
General XML-JSON converter based on Google Data APIs
----
HTML-Tested-ClassDBI-0.10
http://search.cpan.org/~bosu/HTML-Tested-ClassDBI-0.10/
Enhances HTML::Tested to work with Class::DBI
----
IO-Compress-Base-2.004
http://search.cpan.org/~pmqs/IO-Compress-Base-2.004/
Base Class for IO::Compress modules
----
IO-Compress-Bzip2-2.004
http://search.cpan.org/~pmqs/IO-Compress-Bzip2-2.004/
Write bzip2 files/buffers
----
IO-Compress-Lzf-2.004
http://search.cpan.org/~pmqs/IO-Compress-Lzf-2.004/
Write lzf files/buffers
----
IO-Compress-Lzop-2.004
http://search.cpan.org/~pmqs/IO-Compress-Lzop-2.004/
Write lzop files/buffers
----
IO-Compress-Zlib-2.004
http://search.cpan.org/~pmqs/IO-Compress-Zlib-2.004/
----
MSDOS-Attrib-1.03
http://search.cpan.org/~cjm/MSDOS-Attrib-1.03/
Get or set MS-DOS file attributes
----
Mail-DomainKeys-1.0
http://search.cpan.org/~anthonyu/Mail-DomainKeys-1.0/
A perl implementation of DomainKeys
----
Makefile-GraphViz-0.12
http://search.cpan.org/~agent/Makefile-GraphViz-0.12/
Plot the Detailed Structure of Makefiles Using GraphViz
----
Makefile-GraphViz-0.13
http://search.cpan.org/~agent/Makefile-GraphViz-0.13/
Plot the Detailed Structure of Makefiles Using GraphViz
----
Math-BigInt-FastCalc-0.12
http://search.cpan.org/~tels/Math-BigInt-FastCalc-0.12/
Math::BigInt::Calc with some XS for more speed
----
Module-Build-Convert-0.47_06
http://search.cpan.org/~schubiger/Module-Build-Convert-0.47_06/
Makefile.PL to Build.PL converter
----
Pod-Simple-3.05
http://search.cpan.org/~arandal/Pod-Simple-3.05/
framework for parsing Pod
----
Statistics-Lite-3.0
http://search.cpan.org/~brianl/Statistics-Lite-3.0/
Small stats stuff.
----
Template-Declare-0.06
http://search.cpan.org/~jesse/Template-Declare-0.06/
Perlish declarative templates
----
Template-Plugin-Perl-0.03
http://search.cpan.org/~agent/Template-Plugin-Perl-0.03/
TT2 plugin to import Perl built-in functions
----
XML-MyXML-0.081
http://search.cpan.org/~karjala/XML-MyXML-0.081/
A simple XML module
----
XML-MyXML-0.082
http://search.cpan.org/~karjala/XML-MyXML-0.082/
A simple XML module
----
XML-MyXML-0.083
http://search.cpan.org/~karjala/XML-MyXML-0.083/
A simple XML module
----
XML-MyXML-0.09
http://search.cpan.org/~karjala/XML-MyXML-0.09/
A simple XML module
----
mediawiki-pod-0.02
http://search.cpan.org/~tels/mediawiki-pod-0.02/
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: 4 Mar 2007 04:45:11 -0800
From: "Klaus" <klaus03@gmail.com>
Subject: Re: opendir function.
Message-Id: <1173012311.344637.186760@c51g2000cwc.googlegroups.com>
On Mar 2, 5:16 am, "rajendra" <rajendra.pra...@in.bosch.com> wrote:
> Hello All,
> In a script I use opendir() and readdir() functions to read the content of
> directory.
> I have observed one thing with this.The time taken to read the content get
> on better(lesser) with the successive execution of the script
> Is there a way I can reduce the time taken to read the content faster using
> the above two functions?.
readdir() in list context should be slightly faster than in scalar
context.
But TIMTOWTDI, you should also look at other functions/modules to read
the content of a directory.
If your overall algorithm calls opendir() multiple times to descend
into subdirectories, then using File::Find will not only be easier to
code, but might also be more efficient.
=======================
use strict;
use warnings;
my $dirname = '.';
print "\n\nMethod 1: readdir() in scalar context:\n"; {
opendir my $dh, $dirname or die "Error 0010: opendir $dirname,
reason: $!";
while (defined (my $item = readdir $dh)) {
print " Method 1 - found '$item'\n";
}
closedir $dh;
}
print "\n\nMethod 2: use glob() in scalar context:\n"; {
while (defined (my $item = glob $dirname.'/*')) {
print " Method 2 - found '$item'\n";
}
}
print "\n\nMethod 3: readdir() in list context:\n"; {
opendir my $dh, $dirname or die "Error 0020: opendir $dirname,
reason: $!";
for my $item (readdir $dh) {
print " Method 3 - found '$item'\n";
}
closedir $dh;
}
print "\n\nMethod 4: use glob() in list context:\n"; {
for my $item(glob $dirname.'/*') {
print " Method 4 - found '$item'\n";
}
}
print "\n\nMethod 5: use File::Find:\n"; {
use File::Find;
find(sub {
print " Method 5 - found '$_'\n";
}, $dirname);
}
=======================
--
Klaus
------------------------------
Date: Sun, 4 Mar 2007 07:18:54 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: pattern serach over many files
Message-Id: <slrneulhpu.k5j.tadmc@tadmc30.august.net>
anton.vandersteen@chello.nl <anton.vandersteen@chello.nl> wrote:
> open (FILE, $file);
You should always, yes *always*, check the return value from open():
open (FILE, $file) or die "could not open '$file' $!";
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 4 Mar 2007 13:05:08 +0100
From: "sadie-no-reply" <sadie001@nopsam.plannet.nl>
Subject: Posting to nntp newsgroup with Perl (Net::NNTP)
Message-Id: <45eab5fc$0$16884$ba620dc5@text.nova.planet.nl>
I am trying to post a message to a newsgroup using Net::NNTP, but I keep
getting an error message. Help!
I can read from the newsgroup without problems and $nntp->postok() gives OK.
I suspect there's something wrong with way I've constructed my message
array.
Here's the code.
use Net::NNTP;
$server="news.yourserver.com"; #replace this with your nntp server name
#connect to the nntp server (this works fine)
$nntp = Net::NNTP->new($server);
#open a newsgroup (this works fine)
$nntp->group("nl.test") or die "cannot open nl.test";
#download and print the last message (this works fine)
$articleId = $nntp->last();
@tekst = $nntp->article($articleId);
for ($i=1; $t=$tekst[0][$i]; $i++)
{print $t."<BR>\n";}
#check if I'm alowed to post (returns: ok)
if ($nntp->postok())
{print "Posting would be ok\n";}else
{print "Posting not ok\n";}
#construct a message - I'm not sure about this.
#For example, should there be \r\n at the end of each line??
@message=(
"Subject: this is test 1\r\n",
"From: cllq\@noreply.nil\r\n",
"Newsgroups: nl.test\r\n",
"Date: Sat, 3 Mar 2007 20:14:13 +0100\r\n",
"\r\n",
"This is my message\r\n",
"Yours sincerely\r\n",
"Bla\r\n");
#now post the message
$nntp->post(@message) or die "post failed"; #this one fails, but why?
$nntp->quit();
#alternative code that also fails:
$nntp->post() or die "post failed"; #this one ok
$nntp->datasend(@message) or die "datasend nok"; #this one ok
$nntp->dataend() or die "dataend nok"; #this one fails but why?
$nntp->quit();
------------------------------
Date: Sun, 4 Mar 2007 13:48:03 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Posting to nntp newsgroup with Perl (Net::NNTP)
Message-Id: <slrneulg03.hgd.hjp-usenet2@yoyo.hjp.at>
On 2007-03-04 12:05, sadie-no-reply <sadie001@nopsam.plannet.nl> wrote:
> I am trying to post a message to a newsgroup using Net::NNTP, but I keep
> getting an error message. Help!
[...]
> #now post the message
> $nntp->post(@message) or die "post failed"; #this one fails, but why?
Why ask us? Ask perl:
$nntp->post(@message) or die "post failed: " . $nntp->message();
hp
--
_ | Peter J. Holzer | Es ist ganz einfach ihn zu verstehen, wenn
|_|_) | Sysadmin WSR | man nur alle wichtigen Worte im Satz durch
| | | hjp@hjp.at | andere ersetzt.
__/ | http://www.hjp.at/ | -- Nils Ketelsen in danr
------------------------------
Date: Sun, 4 Mar 2007 07:22:58 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Q on regex of LWP::Simple data
Message-Id: <slrneuli1i.k5j.tadmc@tadmc30.august.net>
anno4000@radom.zrz.tu-berlin.de <anno4000@radom.zrz.tu-berlin.de> wrote:
> Len Philpot <len@philpot.org> wrote in comp.lang.perl.misc:
>> On Fri, 02 Mar 2007 17:39:51 +1100, Iain Chalmers wrote:
>>
>> > In article <epdxww5gfd0l.5psw3jcl6it4$.dlg@40tude.net>,
>> > Len Philpot <len@philpot.org> wrote:
>
>> At this point, I'm very low on the Perl learning cliff (oh, for the
>> simplicity and clarity of C! :-),
>
> As in chasing macros and typedefs through header files? As in
> Duff's device? :)
>
> Nah, C is a fine programming language. It is *smaller* than Perl,
> in that Perl has more constructs and concepts to learn, but taken
> individually, Perl's constructs and concepts are no more difficult
> than C's.
Except for the concept of scalar and list context. :-)
Did Larry borrow that concept from somewhere, or did it first
show up in Perl?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 4 Mar 2007 16:18:29 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Q on regex of LWP::Simple data
Message-Id: <5509qlF22st6hU1@mid.dfncis.de>
Tad McClellan <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> anno4000@radom.zrz.tu-berlin.de <anno4000@radom.zrz.tu-berlin.de> wrote:
> > Len Philpot <len@philpot.org> wrote in comp.lang.perl.misc:
> >> On Fri, 02 Mar 2007 17:39:51 +1100, Iain Chalmers wrote:
> >>
> >> > In article <epdxww5gfd0l.5psw3jcl6it4$.dlg@40tude.net>,
> >> > Len Philpot <len@philpot.org> wrote:
> >
> >> At this point, I'm very low on the Perl learning cliff (oh, for the
> >> simplicity and clarity of C! :-),
> >
> > As in chasing macros and typedefs through header files? As in
> > Duff's device? :)
> >
> > Nah, C is a fine programming language. It is *smaller* than Perl,
> > in that Perl has more constructs and concepts to learn, but taken
> > individually, Perl's constructs and concepts are no more difficult
> > than C's.
>
>
> Except for the concept of scalar and list context. :-)
>
> Did Larry borrow that concept from somewhere, or did it first
> show up in Perl?
I'm pretty sure Perl is the first major language to implement anything
similar. It's one of the few features that are original with Perl.
If anything, interpretation and propagation of context is Perl's answer
to the inflexible typing systems of other languages, but it goes far
beyond that.
Anno
------------------------------
Date: Sun, 4 Mar 2007 07:27:14 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: quick scope question
Message-Id: <slrneuli9i.k5j.tadmc@tadmc30.august.net>
1172948251@noid.net <1172948251@noid.net> wrote:
>
> I want to maintain my $version variable in a single place
> within the script and I want it available in a BEGIN block
> that is a different package from the rest of the script. Is
> this possible? Here's what I mean:
>
> ---------------
>
> #!/usr/bin/perl
>
> BEGIN {
> package Some::Package;
> my $version = '1';
^^
^^
See:
"Coping with Scoping":
http://perl.plover.com/FAQs/Namespaces.html
> print "version is $version\n";
> }
>
> my $version = $Some::Package::version;
> print ("version is $version\n"); # not initialized ???
>
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 192
**************************************