[23733] in Perl-Users-Digest
Perl-Users Digest, Issue: 5939 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 14 18:10:39 2003
Date: Sun, 14 Dec 2003 15:10:14 -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, 14 Dec 2003 Volume: 10 Number: 5939
Today's topics:
Re: Newsgroup Searching Program <gerardlanois@netscape.net>
Re: Newsgroup Searching Program <seawolf@attglobal.net>
Re: Passing a hash by reference (Niall Macpherson)
Planning for maintenance <derek.moody@clara.net>
Re: Planning for maintenance <tassilo.parseval@rwth-aachen.de>
Re: Planning for maintenance <REMOVEsdnCAPS@comcast.net>
Re: Planning for maintenance <flavell@ph.gla.ac.uk>
Re: redo undefines loop variable (Peter Scott)
Re: redo undefines loop variable (Tad McClellan)
Re: redo undefines loop variable <REMOVEsdnCAPS@comcast.net>
Re: redo undefines loop variable <REMOVEsdnCAPS@comcast.net>
Re: redo undefines loop variable <zentara@highstream.net>
regexp question (John Oliver)
Re: regexp question (Sam Holden)
Re: regexp question <matthew.garrish@sympatico.ca>
Re: regexp question (John Oliver)
Re: regexp question <asu1@c-o-r-n-e-l-l.edu>
Re: regexp question <go@away.spam>
Re: regexp question <geoffroy.braem@skynet.be>
Re: regexp question <abigail@abigail.nl>
Re: regexp question <REMOVEsdnCAPS@comcast.net>
Regular Expression (Lars Nilsson)
Re: Regular Expression <lord-jacob@comcast.net>
Re: Regular Expression <lord-jacob@comcast.net>
Re: Regular Expression <krahnj@acm.org>
Re: REQUEST: Problem with Perl (Win32) on Windows98SE a (David Jackson)
Re: REQUEST: Problem with Perl (Win32) on Windows98SE a <matthew.garrish@sympatico.ca>
Re: REQUEST: Problem with Perl (Win32) on Windows98SE a (Tad McClellan)
Russian to Windows-1252 (htmlencode) (Bart Van der Donck)
Re: Russian to Windows-1252 (htmlencode) <noreply@gunnar.cc>
Re: Russian to Windows-1252 (htmlencode) <flavell@ph.gla.ac.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 14 Dec 2003 05:08:07 GMT
From: Gerard Lanois <gerardlanois@netscape.net>
Subject: Re: Newsgroup Searching Program
Message-Id: <usmjodm11.fsf@netscape.net>
Les Hazelton <seawolf@attglobal.net> writes:
> On Sat, 13 Dec 2003 07:01:32 +0000, Gerard Lanois wrote:
> > What happens if you telnet into port 563 on the server?
> >
> > You should be able to speak raw NNTP commands to it. And you might get
> > some useful error messages.
> >
> > -Gerard
>
> I gave it a try. It made the connection and then hung until I escaped and
> closed the connection. Without the port number the connection never
> completed.
>
> ---------
> Farpoint:/home/lrh # telnet inetnews.worldnet.att.net 563
> Trying 204.127.161.11...
> Connected to inetnews.worldnet.att.net.
> Escape character is '^]'.
> ^]
> telnet> q
> Connection closed.
> Farpoint:/home/lrh #
> -------------
>
> Also, if I run the perl script on a system where stunnel is active, it
> works. Then, the $SERVER is set to "localhost" and a default port number.
> Stunnel intercepts the call to localhost:119 and converts it to an ssl
> connection on inetnews.worldnet.att.net:563. Applications like Pan or
> Kmail which allow you to specify both hostname and port number connect
> correctly.
OK, I understand the situation now. These other two newsreaders support
NNTP over an SSL connection. Net::NNTP does not (as far as I can tell).
I can't currently find any references (Google, search.cpan.org) to SSL
being directly available with Net::NNTP.
The Net::NNTP module uses IO::Socket::INET.
Maybe you could try hacking NNTP.pm to use IO::Socket::SSL instead?
(Look for the @ISA().)
LWP::Protocol::NNTP might be another avenue for you to investigate.
Maybe there is a way to request that the NNTP connection should use
SSL. However, this NNTP implementation doesn't look to be
particular robust.
I don't see any mention of SSL in News::NNTPClient. Oh well.
Let me know what you find out. I'm interested to learn more about this
myself.
-Gerard
------------------------------
Date: Sun, 14 Dec 2003 18:10:37 GMT
From: Les Hazelton <seawolf@attglobal.net>
Subject: Re: Newsgroup Searching Program
Message-Id: <pan.2003.12.14.18.10.28.308401@attglobal.net>
On Sun, 14 Dec 2003 05:08:07 +0000, Gerard Lanois wrote:
> OK, I understand the situation now. These other two newsreaders support
> NNTP over an SSL connection. Net::NNTP does not (as far as I can tell).
>
> I can't currently find any references (Google, search.cpan.org) to SSL
> being directly available with Net::NNTP.
>
> The Net::NNTP module uses IO::Socket::INET.
>
> Maybe you could try hacking NNTP.pm to use IO::Socket::SSL instead?
> (Look for the @ISA().)
>
> LWP::Protocol::NNTP might be another avenue for you to investigate.
> Maybe there is a way to request that the NNTP connection should use
> SSL. However, this NNTP implementation doesn't look to be
> particular robust.
>
> I don't see any mention of SSL in News::NNTPClient. Oh well.
>
> Let me know what you find out. I'm interested to learn more about this
> myself.
>
> -Gerard
I had been reaching the conclusion that Net::NNTP would not support SSL,
but was not sure. The thing that got me into this swamp in the first place
is the fact that the target system is an old (8.0) release of Mandrake and
none of the currently available releases of stunnel will run there. I had
resisted upgrading to a newer Linux release.
I am going to upgrade the target system to MDK 9.1 this afternoon. That
will get me going for now. Once that is out of the way I will look into
implementing the Perl news reader program using something that will
support SSL. If I make any progress with that effort, I will post the
results here.
Thanks again for all the help.
--
Les Hazelton
--- Registered Linux user # 272996 ---
If the aborigine drafted an IQ test, all of Western civilization would
presumably flunk it.
-- Stanley Garn
------------------------------
Date: 14 Dec 2003 12:34:45 -0800
From: niall.macpherson@moneyline.com (Niall Macpherson)
Subject: Re: Passing a hash by reference
Message-Id: <a3376e0d.0312141234.37549652@posting.google.com>
Thanks for your help everyone - I will try this out !
------------------------------
Date: Sun, 14 Dec 2003 14:41:09 +0000
From: "Derek.Moody" <derek.moody@clara.net>
Subject: Planning for maintenance
Message-Id: <ant141409bc8BxcK@half-baked-idea.co.uk>
Background:
I have a couple of dozen perl scripts to reconcile. It seems they grew on
an ad-hoc basis and there is a good deal of duplicated content some of which
has been allowed to get out of step. For ease of maintenance I am
extracting these into two or three modules. I anticipate future
developments requiring at least as many new scripts and another three or
four modules so that no one script will require more than two, or
perhaps three of these modules.
The question:
For ease of future maintenance, especially for (s)he who may come after me -
* Do I import all subroutines and data so that the call might be
&dosomething($parameter);
* Or do I use full references
&Foo::dosomething($Bar::parameter);
Especially as some variable names will be duplicated in alternate packages.
Opinions solicited:
If you were hired to maintain my legacy (say 50 scripts, 8 modules) which
form would you prefer?
As you may guess I favour the second version - am I overlooking any
potential pitfalls?
Tia. Cheerio,
--
>> derek.moody@clara.net
------------------------------
Date: 14 Dec 2003 15:51:41 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Planning for maintenance
Message-Id: <bri0ud$q4f$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Derek.Moody:
> I have a couple of dozen perl scripts to reconcile. It seems they grew on
> an ad-hoc basis and there is a good deal of duplicated content some of which
> has been allowed to get out of step. For ease of maintenance I am
> extracting these into two or three modules. I anticipate future
> developments requiring at least as many new scripts and another three or
> four modules so that no one script will require more than two, or
> perhaps three of these modules.
>
> The question:
> For ease of future maintenance, especially for (s)he who may come after me -
> * Do I import all subroutines and data so that the call might be
> &dosomething($parameter);
> * Or do I use full references
> &Foo::dosomething($Bar::parameter);
> Especially as some variable names will be duplicated in alternate packages.
>
> Opinions solicited:
> If you were hired to maintain my legacy (say 50 scripts, 8 modules) which
> form would you prefer?
I suggest putting all the symnbols into the package's @EXPORT_OK so that
you can import them on demand:
package Your::Module;
use base qw(Exporter);
@EXPORT_OK = qw(dosomething);
sub dosomething { ... }
And when you include the module, you can either do
use Your::Module; # nothing is imported
Your::Module::dosomething();
or
use Your::Module qw(dosomething);
dosomething();
See 'perldoc Exporter' for details.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sun, 14 Dec 2003 11:06:49 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Planning for maintenance
Message-Id: <Xns94517B265C1A1sdn.comcast@216.196.97.136>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"Derek.Moody" <derek.moody@clara.net> wrote in
news:ant141409bc8BxcK@half-baked-idea.co.uk:
> The question:
> For ease of future maintenance, especially for (s)he who may come
> after me - * Do I import all subroutines and data so that the call
> might be
> &dosomething($parameter);
> * Or do I use full references
> &Foo::dosomething($Bar::parameter);
> Especially as some variable names will be duplicated in alternate
> packages.
>
> Opinions solicited:
> If you were hired to maintain my legacy (say 50 scripts, 8
modules)
> which form would you prefer?
> As you may guess I favour the second version - am I overlooking
any
> potential pitfalls?
First of all, you wouldn't (or shouldn't, anyhow) invoke subroutines
with an ampersand (&) unless you have a good reason for doing so.
Second, imho, by fully-qualifying all of the function calls, you're
making a lot of extra typing for yourself, and limiting future
flexibility. If you choose to move half of the function calls to a
different module someday, you'll have to edit all of the function
call invocations to have the new module name, as opposed to simply
changing a declaration or two at the top of each program.
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13
iD8DBQE/3JiLY96i4h5M0egRAifLAKCSA4pVmVuAIU6le4VUayyh+6XSlQCeIDPf
bl0pjLCG3+3LYKBQZON7fiE=
=M4GZ
-----END PGP SIGNATURE-----
------------------------------
Date: Sun, 14 Dec 2003 17:17:27 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Planning for maintenance
Message-Id: <Pine.LNX.4.53.0312141713340.8334@ppepc56.ph.gla.ac.uk>
On Sun, 14 Dec 2003, Eric J. Roode wrote:
> Second, imho, by fully-qualifying all of the function calls, you're
> making a lot of extra typing for yourself, and limiting future
> flexibility. If you choose to move half of the function calls to a
> different module someday, you'll have to edit all of the function
> call invocations to have the new module name, as opposed to simply
> changing a declaration or two at the top of each program.
Indeed. On the other hand, if you'd had the bad-fortune to choose a
function name which later turned out to clash with some other needed
module...
------------------------------
Date: Sun, 14 Dec 2003 16:17:04 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: redo undefines loop variable
Message-Id: <420Db.700423$6C4.135248@pd7tw1no>
In article <3fdbab97.588960710@news.erols.com>,
tiltonj@erols.com (Jay Tilton) writes:
>
>You might first check the bug tracker at http://rt.perl.org/perlbug/ to see
>if it was submitted back then and what its disposition was.
I perlbugged it in June, #22699. See
http://groups.google.com/groups?selm=rt-22699-59397.2.06916605568907%40rt.perl.org
--
Peter Scott
http://www.perldebugged.com/
*** NEW *** http//www.perlmedic.com/
------------------------------
Date: Sun, 14 Dec 2003 10:37:34 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: redo undefines loop variable
Message-Id: <slrnbtp4ee.a7j.tadmc@magna.augustmail.com>
zentara <zentara@highstream.net> wrote:
> 1.) Wouldn't you need to chomp $data? Otherwise $data will
> never == 2.
Run this...
--------------------------------
#!/usr/bin/perl
use strict;
use warnings;
my $data = "2\n";
if ( $data == 2 )
{ print "data is two\n" }
else
{ print "data is NOT two\n" }
--------------------------------
... to see that the answer to your question is "no". :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 14 Dec 2003 10:46:12 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: redo undefines loop variable
Message-Id: <Xns945177A7CEA1Bsdn.comcast@216.196.97.136>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
zentara <zentara@highstream.net> wrote in
news:3dqotvg397562jucv38f3foodt6g918lul@4ax.com:
> I don't think it's a bug.
> I'm no expert on Perl internals, but when I first looked at this,
> I had these thoughts.
> 1.) Wouldn't you need to chomp $data? Otherwise $data will
> never == 2.
Try it:
my $var = "2\n";
print $var==2? "Equals 2!\n" : "Isn't 2!\n";
$var = "2foofoolalala";
print $var==2? "Equals 2!\n" : "Isn't 2!\n";
(The latter does issue a warning, however).
> 2. This seems to work as I would expect since data is a
filehandle.
> When I run the code with a chomp $data, it prints 1234. It
> prints 12, then with the redo, it prints 34. I think you
are
> assuming
> that redo resets the DATA filehandle?
Did you expect the "Use of uninitialized value" warnings? The OP
didn't say (shame on him), but I think that's the "bug" he was
referring to.
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13
iD8DBQE/3JO2Y96i4h5M0egRAtKlAJ91StgHeT7RN58TaIWlopzsLMB8KQCfXuM9
+UkS6rzLHTG0PFcc+sxmfE4=
=bqWv
-----END PGP SIGNATURE-----
------------------------------
Date: Sun, 14 Dec 2003 10:47:58 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: redo undefines loop variable
Message-Id: <Xns945177F491D16sdn.comcast@216.196.97.136>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in
news:Xns945177A7CEA1Bsdn.comcast@216.196.97.136:
> Did you expect the "Use of uninitialized value" warnings? The OP
> didn't say (shame on him), but I think that's the "bug" he was
> referring to.
My mistake -- Chris *did* state that that was the unexpected
behavior. Shame on me for not re-reading it before posting.
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13
iD8DBQE/3JQgY96i4h5M0egRAmvAAKDqB+gYtQ4C7iH6vik/UnzfEAhz6wCfWFIY
eVqm0SsZXFmEvX85fLahKkk=
=EawU
-----END PGP SIGNATURE-----
------------------------------
Date: Sun, 14 Dec 2003 09:02:18 -0500
From: zentara <zentara@highstream.net>
Subject: Re: redo undefines loop variable
Message-Id: <3dqotvg397562jucv38f3foodt6g918lul@4ax.com>
On 13 Dec 2003 15:56:11 -0800, charley@pulsenet.com (Chris Charley)
wrote:
>A small piece of code (below) to demonstrate the bug.
>If the code would run without a bug, it would be an infinite loop.
>But the bug produces warnings about the use of an uninitialized value. . .
>
>#####################################################################
>################### code #######################################
>
>#!/usr/bin/perl
>use strict;
>use warnings;
>
>while (my $data = <DATA>) {
> print $data;
> redo if $data == 2;
>}
>__DATA__
>1
>2
>3
>4
I don't think it's a bug.
I'm no expert on Perl internals, but when I first looked at this,
I had these thoughts.
1.) Wouldn't you need to chomp $data? Otherwise $data will
never == 2.
2. This seems to work as I would expect since data is a filehandle.
When I run the code with a chomp $data, it prints 1234. It prints
12, then with the redo, it prints 34. I think you are assuming
that redo resets the DATA filehandle?
If I change redo to "seek DATA,0,0" you get an infinite loop.
#!/usr/bin/perl
use strict;
use warnings;
while (my $data = <DATA>) {
chomp $data;
print $data;
#redo if $data == 2;
seek DATA, 0, 0 if $data == 2;
}
__DATA__
1
2
3
4
--
When life conspires against you, and no longer floats your boat,
Don't waste your time with crying, just get on your back and float.
------------------------------
Date: 13 Dec 2003 21:10:42 -0600
From: joliver@john-oliver.net (John Oliver)
Subject: regexp question
Message-Id: <slrnbtnl52.9ne.joliver@ns.sdsitehosting.net>
I'm trying to come up with a regexp that will match a line that starts
with a certain amount of whitespace and then only numbers, and
failing...
--
************************************************************************
* John Oliver http://www.john-oliver.net/ *
* "For the wages of spam is death!" http://www.spamcon.org/legalfund/ *
************************************************************************
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
------------------------------
Date: 14 Dec 2003 03:21:41 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: regexp question
Message-Id: <slrnbtnlq5.38q.sholden@flexal.cs.usyd.edu.au>
On 13 Dec 2003 21:10:42 -0600, John Oliver <joliver@john-oliver.net> wrote:
> I'm trying to come up with a regexp that will match a line that starts
> with a certain amount of whitespace and then only numbers, and
> failing...
Post what you have tried, what you expect it to do, and what it
actually did.
--
Sam Holden
------------------------------
Date: Sat, 13 Dec 2003 22:44:49 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: regexp question
Message-Id: <G0RCb.21692$aF2.2449176@news20.bellglobal.com>
"John Oliver" <joliver@john-oliver.net> wrote in message
news:slrnbtnl52.9ne.joliver@ns.sdsitehosting.net...
> I'm trying to come up with a regexp that will match a line that starts
> with a certain amount of whitespace and then only numbers, and
> failing...
>
What are you having difficulty with?
print "Found me!\n" if $line =~ /^\s{5}\d+/;
Would find 5 whitespace characters at the start of a line followed by one or
more numbers...
Matt
------------------------------
Date: 13 Dec 2003 22:17:47 -0600
From: joliver@john-oliver.net (John Oliver)
Subject: Re: regexp question
Message-Id: <slrnbtnp2r.bvu.joliver@ns.sdsitehosting.net>
On Sat, 13 Dec 2003 22:44:49 -0500, Matt Garrish wrote:
>
> What are you having difficulty with?
>
> print "Found me!\n" if $line =~ /^\s{5}\d+/;
>
> Would find 5 whitespace characters at the start of a line followed by one or
> more numbers...
OK, here's the scoop... I get a file that file have four lines in it
which will be just numbers, like:
311432679
The file, if it makes any difference, is HTML that's been wgetted from a
router, and the numbers are interface stats.
I try:
sed -n -e '/^\s{20}\d+/p' st_stats.html
and that returns nothing. I've tried various combinations of []
enclosed ranges, the ^ character, etc. Sorry, but any but the simplest
regexp statement still looks like a monkey pounded on the keyboard to
me... :-)
--
************************************************************************
* John Oliver http://www.john-oliver.net/ *
* "For the wages of spam is death!" http://www.spamcon.org/legalfund/ *
************************************************************************
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
------------------------------
Date: 14 Dec 2003 05:17:10 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: regexp question
Message-Id: <Xns94512E8AAEACasu1cornelledu@132.236.56.8>
joliver@john-oliver.net (John Oliver) wrote in
news:slrnbtnp2r.bvu.joliver@ns.sdsitehosting.net:
> I try:
>
> sed -n -e '/^\s{20}\d+/p' st_stats.html
did you notice that this is a Perl group?
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Sun, 14 Dec 2003 06:56:43 GMT
From: LaDainian Tomlinson <go@away.spam>
Subject: Re: regexp question
Message-Id: <Xns945113E10136Ebclennoxeosncsuedu@24.25.9.41>
On 13 Dec 2003, "John Oliver" <joliver@john-oliver.net> wrote in
comp.lang.perl.misc:
> On Sat, 13 Dec 2003 22:44:49 -0500, Matt Garrish wrote:
>>
>> What are you having difficulty with?
>>
>> print "Found me!\n" if $line =~ /^\s{5}\d+/;
>>
>> Would find 5 whitespace characters at the start of a line followed by
>> one or more numbers...
>
> OK, here's the scoop... I get a file that file have four lines in it
> which will be just numbers, like:
>
> 311432679
>
> The file, if it makes any difference, is HTML that's been wgetted from
> a router, and the numbers are interface stats.
>
> I try:
>
> sed -n -e '/^\s{20}\d+/p' st_stats.html
>
> and that returns nothing. I've tried various combinations of []
> enclosed ranges, the ^ character, etc. Sorry, but any but the
> simplest regexp statement still looks like a monkey pounded on the
> keyboard to me... :-)
>
If you were to do it in Perl:
my @nums;
while (defined(my $line = <DATA>)){
push @nums => $1 if ($line =~ /^\s{20}(\d+)/);
}
print "@nums\n";
__DATA__
311432679
824993757
983247834
346345767
If you didn't know exactly how many spaces were at the front, you could
replace the \s{20} with \s* and it would still be fine. Not familiar
enough with sed to tell you what was wrong with your syntax.
Brandan L.
--
bclennox AT eos DOT ncsu DOT edu
------------------------------
Date: Sun, 14 Dec 2003 11:39:54 -0500
From: geoffroy <geoffroy.braem@skynet.be>
Subject: Re: regexp question
Message-Id: <3fdc3df0$0$2879$ba620e4c@reader1.news.skynet.be>
John Oliver wrote:
> I'm trying to come up with a regexp that will match a line that starts
> with a certain amount of whitespace and then only numbers, and
> failing...
>
/^\s+\d+$/
Geoffroy
------------------------------
Date: 14 Dec 2003 11:05:01 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: regexp question
Message-Id: <slrnbtogut.les.abigail@alexandra.abigail.nl>
John Oliver (joliver@john-oliver.net) wrote on MMMDCCLVII September
MCMXCIII in <URL:news:slrnbtnl52.9ne.joliver@ns.sdsitehosting.net>:
}} I'm trying to come up with a regexp that will match a line that starts
}} with a certain amount of whitespace and then only numbers, and
}} failing...
What did you try so far?
Abigail
--
sub A::TIESCALAR{bless\my$x=>A};package B;@q[0..3]=qw/Hacker Perl
Another Just/;use overload'""'=>sub{pop @q};sub A::FETCH{bless\my
$y=>B}; tie my $shoe => qq 'A';print "$shoe $shoe $shoe $shoe\n";
------------------------------
Date: Sun, 14 Dec 2003 10:52:32 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: regexp question
Message-Id: <Xns945178BA6A373sdn.comcast@216.196.97.136>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
joliver@john-oliver.net (John Oliver) wrote in
news:slrnbtnp2r.bvu.joliver@ns.sdsitehosting.net:
> I try:
>
> sed -n -e '/^\s{20}\d+/p' st_stats.html
Perhaps you should ask in a group that deals with sed regexps.
<sarcasm>
Except that ALL regular expression syntaxes and capabilities are the
same, no matter whether you're doing things in Perl, sed, awk, emacs,
grep, pcre, or your uncle's hacked-up copy of EDLIN.COM, right?
And ALL html, cgi, and other web technologies are sort of the same
thing as Perl, right?
</sarcasm>
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13
iD8DBQE/3JUxY96i4h5M0egRAo6CAJsEfRenGZjxx9osyKkJq4zL+KuBMQCg7jb8
8LOwE/SdbxhqqRaqlv0mid0=
=5vKr
-----END PGP SIGNATURE-----
------------------------------
Date: 14 Dec 2003 03:34:57 -0800
From: laguni@bredband.net (Lars Nilsson)
Subject: Regular Expression
Message-Id: <c875fb35.0312140334.6d7adf0d@posting.google.com>
I need to check that the user as put in at least one character between
a-z upper or lowercase in a name field. They can put in whatever they
like but there as to be a character a-z in the string. How shall the
test expression look like?
/Lars
------------------------------
Date: Sun, 14 Dec 2003 11:35:15 GMT
From: Jacob Heider <lord-jacob@comcast.net>
Subject: Re: Regular Expression
Message-Id: <abc175909fa0db586ea9ffe7f353ca09@news.teranews.com>
On Sun, 14 Dec 2003 03:34:57 -0800, Lars Nilsson wrote:
> I need to check that the user as put in at least one character between a-z
> upper or lowercase in a name field. They can put in whatever they like but
> there as to be a character a-z in the string. How shall the test
> expression look like?
>
> /Lars
You mean:
/[a-zA-Z/
?
Jacob
------------------------------
Date: Sun, 14 Dec 2003 11:39:19 GMT
From: Jacob Heider <lord-jacob@comcast.net>
Subject: Re: Regular Expression
Message-Id: <54a5041f590ef83b206ec435eb2ab570@news.teranews.com>
On Sun, 14 Dec 2003 11:35:15 +0000, Jacob Heider wrote:
> On Sun, 14 Dec 2003 03:34:57 -0800, Lars Nilsson wrote:
>
>> I need to check that the user as put in at least one character between
>> a-z upper or lowercase in a name field. They can put in whatever they
>> like but there as to be a character a-z in the string. How shall the
>> test expression look like?
>>
>> /Lars
>
> You mean:
>
> /[a-zA-Z/
>
> ?
>
> Jacob
That's what I get for staying up all night. Should be (of course)
/[a-zA-Z]/
^
Jacob
------------------------------
Date: Sun, 14 Dec 2003 20:30:53 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Regular Expression
Message-Id: <3FDCC870.9C9AE42@acm.org>
Lars Nilsson wrote:
>
> I need to check that the user as put in at least one character between
> a-z upper or lowercase in a name field. They can put in whatever they
> like but there as to be a character a-z in the string. How shall the
> test expression look like?
my $alpha_count = $name =~ tr/a-zA-Z//;
if ( $alpha_count >= 1 ) {
But if you really want to use a regular expression instead:
my $alpha_count = () = $name =~ /[a-zA-Z]/g;
if ( $alpha_count >= 1 ) {
John
--
use Perl;
program
fulfillment
------------------------------
Date: 13 Dec 2003 19:37:30 -0800
From: info@mustardandrelish.com (David Jackson)
Subject: Re: REQUEST: Problem with Perl (Win32) on Windows98SE and reading files
Message-Id: <28db9f57.0312131937.3a58a5c7@posting.google.com>
tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnbtm797.4ml.tadmc@magna.augustmail.com>...
> Jeff <jeffcrowtpg.com.au> wrote:
>
> > @files = readdir(OUTDOOR);
>
> > TEST READABLE
>
> > Thanks in advance for any and all for assistance provided.
>
>
> You should read the documentation for the functions that you use.
Tad --
There's only been one "perfect" person I know of and we "nailed him to
a cross"....
Jeff --
You might for check/post http://perlmonks.com, maybe they'll remember
a time when they didn't not readying every man page for every function
for every program they wrote.
Sorry I cann't be of more help.
DJJ
------------------------------
Date: Sat, 13 Dec 2003 23:09:15 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: REQUEST: Problem with Perl (Win32) on Windows98SE and reading files
Message-Id: <znRCb.21711$aF2.2460240@news20.bellglobal.com>
"Jeff" <jeffcrow(AT)tpg.com.au> wrote in message
news:3fda88a4$2@dnews.tpgi.com.au...
>
> opendir(OUTDOOR, "${autodir}") || die "Can't open the dir ${autodir}";
> @files = readdir(OUTDOOR);
> closedir(OUTDOOR);
> foreach $file (@files) {
> TEST READABLE
> IF !READABLE
> CHANGE MODE TO READABLE OR DIE WITH ERROR MESSAGE
> }
>
It would help if you hadn't left out the most important part of the code. My
guess is that you're either trying to change the permissions on '.' and
'..', or your running the script in a different directory from the files and
not prepending the full path. But unless you'd care to share the rest of
your code, there's not much anyone can do for you.
Matt
------------------------------
Date: Sat, 13 Dec 2003 23:36:31 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: REQUEST: Problem with Perl (Win32) on Windows98SE and reading files
Message-Id: <slrnbtntmv.27m.tadmc@magna.augustmail.com>
David Jackson <info@mustardandrelish.com> wrote:
> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnbtm797.4ml.tadmc@magna.augustmail.com>...
>> Jeff <jeffcrowtpg.com.au> wrote:
>>
>> > @files = readdir(OUTDOOR);
>>
>> > TEST READABLE
>>
>> > Thanks in advance for any and all for assistance provided.
>>
>>
>> You should read the documentation for the functions that you use.
^^^^^^^^^^^^
^^^^^^^^^^^^
> You might for check/post http://perlmonks.com, maybe they'll remember
> a time when they didn't not readying every man page for every function
> for every program they wrote.
We don't expect that here either. You're making shit up.
> Sorry I cann't be of more help.
If he reads the documentation for the function that he is using
then he will have the solution to his problem.
I helped him, you did not help him.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 14 Dec 2003 10:12:38 -0800
From: bart@nijlen.com (Bart Van der Donck)
Subject: Russian to Windows-1252 (htmlencode)
Message-Id: <b5884818.0312141012.2eb3f921@posting.google.com>
Hello,
I am looking for a way to convert Russian characters to their
(numeric) html entities in a Windows-1252 character set. It looks like
an easy job but it isn't.
I did a search on CPAN and tried a few modules but their output is not
OK for what I want to do. HTML::Entities apparently converts to
non-numeric html entities only. In case of Russian, this module would
not be not suitable.
Unicode::Lite has a strange output (I don't understand it, weird
characters)
I also played around with CGI.pm. It has a short paragraph about this
issue. But I believe this is not the way to go either.
Here some Russian language examples and what they should become.
I post via Google, I am not sure if these characters will get through.
My IE6 is set at utf8 + I see utf8 in my Google-URL above, so I take
my chances.
изменения
should become=
изменения
информация
should become=
информация
Освобождение
should become=
Освобождение
Background:
My application provider did not compile MySQL with support for Russian
characters. (MySQL4) And they are not going to change that. So I am
going to store my Russian data in a webfriendly Windows-1252 charset.
Is this possible? Someone of you perl sultans maybe would have a
one-liner for that? :-)
Thanks,
Bart
------------------------------
Date: Sun, 14 Dec 2003 20:42:10 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Russian to Windows-1252 (htmlencode)
Message-Id: <brif3m$3ehv5$1@ID-184292.news.uni-berlin.de>
Bart Van der Donck wrote:
> I am looking for a way to convert Russian characters to their
> (numeric) html entities in a Windows-1252 character set.
<snip>
> HTML::Entities apparently converts to non-numeric html entities
> only.
Not true. Read the docs.
> In case of Russian, this module would not be not suitable.
See below.
> Here some Russian language examples and what they should become. I
> post via Google, I am not sure if these characters will get
> through.
They did not get through. They were converted. :)
> изменения
Suppose you mean:
изменения
> should become=
> изменения
This is one way, using HTML::Entities:
use HTML::Entities;
my $russian = 'изменения';
sub convert {
my @chars = split //, shift;
for (@chars) {
$_ = HTML::Entities::encode_entities_numeric($_);
s/(\w+)/848 + hex $1/e;
}
return join '', @chars;
}
print convert($russian);
Outputs:
изменения
HTH
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 14 Dec 2003 19:28:22 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Russian to Windows-1252 (htmlencode)
Message-Id: <Pine.LNX.4.53.0312141908220.8334@ppepc56.ph.gla.ac.uk>
On Sun, 14 Dec 2003, Bart Van der Donck wrote:
> I am looking for a way to convert Russian characters to their
> (numeric) html entities in a Windows-1252 character set.
I'm having a hard time understanding your question in the form that
it's stated.
Windows-1252 is a proprietary encoding for _Western_ content, neither
an open coding for use on the web nor a coding suitable for Russian.
What you call "numeric html entities" (to be pedantic their proper
name is "numeric character references") refer to character positions
in the "HTML document character set", which by definition is always
iso-10646/Unicode, not "in a Windows-1252 character set".
> Here some Russian language examples and what they should become.
> I post via Google, I am not sure if these characters will get through.
Your suspicions were well-founded, I'm afraid. It looks as if you can
use Google to perform the conversions for you ;-))
> My IE6 is set at utf8 + I see utf8 in my Google-URL above, so I take
> my chances.
Are you hinting that your incoming data will be utf-8-encoded?
> изменения
> should become=
> изменения
>
> Background:
> My application provider did not compile MySQL with support for Russian
> characters. (MySQL4) And they are not going to change that.
I think I understood that bit...
> So I am going to store my Russian data in a webfriendly Windows-1252
> charset.
Windows-1252 (MS Western Windows encoding) can hardly be termed as
"web friendly", IMHO: even if there's a lot of it about, it's still a
propriatary encoding. It might be database-friendly.
> Is this possible?
I'm still confused about what direction you want to convert. What
coding is your Russian text provided in, and what do you really want
to put into the dataset? And then when you get it out again, what do
you need to do with it?
Then one can actually start to address the requirement. (Or maybe
someone else has a clearer crystal ball than I have, and will manage
to produce the right answer first, let's see).
------------------------------
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.
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 V10 Issue 5939
***************************************