[25775] in Perl-Users-Digest
Perl-Users Digest, Issue: 8014 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 26 03:05:35 2005
Date: Tue, 26 Apr 2005 00:05:10 -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 Tue, 26 Apr 2005 Volume: 10 Number: 8014
Today's topics:
'2 apples' + '2 oranges' == 4 <jkrugman345@yahbitoo.com>
Re: '2 apples' + '2 oranges' == 4 <yyusenet@yahoo.com>
Re: '2 apples' + '2 oranges' == 4 <tassilo.von.parseval@rwth-aachen.de>
Re: '2 apples' + '2 oranges' == 4 xhoster@gmail.com
Re: '2 apples' + '2 oranges' == 4 <john@castleamber.com>
Re: '2 apples' + '2 oranges' == 4 <jkrugman345@yahbitoo.com>
Re: '2 apples' + '2 oranges' == 4 <tassilo.von.parseval@rwth-aachen.de>
5477 monografia monografias teses =?ISO-8859-1?Q?disser <monografia@xfdgr.com>
5636 monografia =?ISO-8859-1?Q?administra=E7=E3o?= - mo <monografia@xfdgr.com>
[Q] Rec 16.21: Timing out an op (nested evals) <socyl@987jk.com.invalid>
Re: Download a HTML page with images? (Fergus McMenemie)
Re: one-time and one-line programs <groleau+news@freeshell.org>
Pls help with a Regex (David Joseph Bonnici)
Re: Pls help with a Regex <noreply@gunnar.cc>
Re: Pls help with a Regex <tadmc@augustmail.com>
Re: Pls help with a Regex <djb@global.net.mt>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 25 Apr 2005 23:40:58 +0000 (UTC)
From: J Krugman <jkrugman345@yahbitoo.com>
Subject: '2 apples' + '2 oranges' == 4
Message-Id: <d4jv6a$b1b$1@reader1.panix.com>
I can't find the documentation for the behavior illustrated in the
Subject line (i.e. in Perl arithmetic operations are defined for
strings beginning with numbers[*]). Any pointers would be appreciated.
(Also, meta-pointers on how one would go about finding this
documentation if one didn't know already would also be very welcome.)
TIA!
jill
* Actually, the format of the strings Perl will perform arithmetic
on is more compilicated than I described above. Optional leading
whitespace is permitted, for example.
--
To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.
------------------------------
Date: Mon, 25 Apr 2005 17:52:15 -0600
From: YYUsenet <yyusenet@yahoo.com>
Subject: Re: '2 apples' + '2 oranges' == 4
Message-Id: <d4jvrg$65q$1@news.xmission.com>
J Krugman wrote:
> I can't find the documentation for the behavior illustrated in the
> Subject line (i.e. in Perl arithmetic operations are defined for
> strings beginning with numbers[*]). Any pointers would be appreciated.
> (Also, meta-pointers on how one would go about finding this
> documentation if one didn't know already would also be very welcome.)
>
> TIA!
>
> jill
>
> * Actually, the format of the strings Perl will perform arithmetic
> on is more compilicated than I described above. Optional leading
> whitespace is permitted, for example.
>
>
>
Please do not put your whole message in the subject line.
I have no idea what you are trying to get at.
Please be a little bit more descriptive and provide some sample code.
--
k g a b e r t (at) x m i s s i o n (dot) c o m
*Use Mozzila/Firefox*!
http://www.spreadfirefox.com/?q=user/register&r=71209
------------------------------
Date: Tue, 26 Apr 2005 02:03:00 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: '2 apples' + '2 oranges' == 4
Message-Id: <slrnd6r19k.23f.tassilo.von.parseval@localhost.localdomain>
Also sprach J Krugman:
> I can't find the documentation for the behavior illustrated in the
> Subject line (i.e. in Perl arithmetic operations are defined for
> strings beginning with numbers[*]). Any pointers would be appreciated.
> (Also, meta-pointers on how one would go about finding this
> documentation if one didn't know already would also be very welcome.)
A string like '2 apples' and '2 oranges' in numeric context will both
become 2. So if you add them, they are both evaluated in numeric
context, so that becomes 2 + 2, and hence 4.
The rules for string to number conversion are not so hard. One simple
rule is that perl scans everything up to the first non-digit character
and throws everything beginning with this character away. So the
number-prefix remains and becomes the number.
Tassilo
--
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
------------------------------
Date: 26 Apr 2005 00:31:46 GMT
From: xhoster@gmail.com
Subject: Re: '2 apples' + '2 oranges' == 4
Message-Id: <20050425203146.250$cT@newsreader.com>
J Krugman <jkrugman345@yahbitoo.com> wrote:
> I can't find the documentation for the behavior illustrated in the
> Subject line (i.e. in Perl arithmetic operations are defined for
> strings beginning with numbers[*]). Any pointers would be appreciated.
The warnings you get if you enable warnings would be a good start.
Or perldoc perlintro:
Scalars
A scalar represents a single value:
my $animal = "camel";
my $answer = 42;
Scalar values can be strings, integers or floating point
numbers, and Perl will automatically convert between them as
required.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 26 Apr 2005 01:03:54 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: '2 apples' + '2 oranges' == 4
Message-Id: <Xns9643CC0BF6F6Dcastleamber@130.133.1.4>
Tassilo v. Parseval wrote:
> The rules for string to number conversion are not so hard. One simple
> rule is that perl scans everything up to the first non-digit character
> and throws everything beginning with this character away. So the
> number-prefix remains and becomes the number.
perl -e "print '3e4' * 4"
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Tue, 26 Apr 2005 01:38:07 +0000 (UTC)
From: J Krugman <jkrugman345@yahbitoo.com>
Subject: Re: '2 apples' + '2 oranges' == 4
Message-Id: <d4k61v$jev$1@reader1.panix.com>
In <slrnd6r19k.23f.tassilo.von.parseval@localhost.localdomain> "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de> writes:
>Also sprach J Krugman:
>> I can't find the documentation for the behavior illustrated in the
>> Subject line (i.e. in Perl arithmetic operations are defined for
>> strings beginning with numbers[*]). Any pointers would be appreciated.
>> (Also, meta-pointers on how one would go about finding this
>> documentation if one didn't know already would also be very welcome.)
>A string like '2 apples' and '2 oranges' in numeric context will both
>become 2. So if you add them, they are both evaluated in numeric
>context, so that becomes 2 + 2, and hence 4.
>The rules for string to number conversion are not so hard. One simple
>rule is that perl scans everything up to the first non-digit character
>and throws everything beginning with this character away. So the
>number-prefix remains and becomes the number.
I'm sure the rules are straightforward, but I don't understand why
they aren't documented. It is not wise to use undocumented features
even if they are extremely straightforward.
jill
--
To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.
------------------------------
Date: Tue, 26 Apr 2005 08:57:53 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: '2 apples' + '2 oranges' == 4
Message-Id: <slrnd6rpjh.pl.tassilo.von.parseval@localhost.localdomain>
Also sprach John Bokma:
> Tassilo v. Parseval wrote:
>
>> The rules for string to number conversion are not so hard. One simple
>> rule is that perl scans everything up to the first non-digit character
>> and throws everything beginning with this character away. So the
>> number-prefix remains and becomes the number.
>
> perl -e "print '3e4' * 4"
Which is why I wrote "One simple rule". It implies there are others.
Tassilo
--
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
------------------------------
Date: Tue, 26 Apr 2005 02:03:00 +0100
From: "monografia " <monografia@xfdgr.com>
Subject: 5477 monografia monografias teses =?ISO-8859-1?Q?disserta=E7=F5es?= trabalhos escolares 5477
Message-Id: <DDAC168FB5C09749AD96D27804CA35D105AC6C5C@SETUBAL>
Monografias completas a partir de 250,00 !
monografia administração direito turismo economia letras pedagogia
monografias teses tese.
Sua monografia a partir de 250,00
http://monografiadireta.rg3.net
------------------------------
Date: Tue, 26 Apr 2005 04:02:09 +0100
From: "monografia " <monografia@xfdgr.com>
Subject: 5636 monografia =?ISO-8859-1?Q?administra=E7=E3o?= - monografia direito 5636
Message-Id: <DDAC168FB5C09749AD96D27804CA35D105ACDC4F@SETUBAL>
Monografias completas a partir de 250,00 !
monografia administração direito turismo economia letras pedagogia
monografias teses tese.
Sua monografia a partir de 250,00
http://monografiadireta.rg3.net
------------------------------
Date: Tue, 26 Apr 2005 04:00:25 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: [Q] Rec 16.21: Timing out an op (nested evals)
Message-Id: <d4kecp$ojv$1@reader1.panix.com>
Recipe 16.21 of the Perl Cookbook (3rd Ed) makes absolutely no
sense to me. The authors propose a "nested-evals" strategy to
guard against a race condition:
eval {
local $SIG{ALRM} = sub { die 'timeout' };
alarm 10;
eval {
# long-runing op
}
alarm 0;
}
alarm 0; # race condition protection
die if $@ and !~ /timeout/;
The first thing that makes no sense is that no error within the
inner eval loop (including the error generated by the SIGALRM
handler) has any effect on the $@ being tested. The tested $@ will
be true only in the exceedingly unlikely event that something goes
wrong while executing any of the lines inside the outer eval block
that are not within the inner one (i.e. the assignment to $SIG{ALRM}
and two of the three to calls to alarm.) For all intents and
purposes, $@ is always undef.
The second thing I don't understand is the purpose of the inner
"alarm 0"; it seems redundant.
Any help elucidating these question would be much appreciated.
kj
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
------------------------------
Date: Tue, 26 Apr 2005 07:07:57 +0100
From: fergus@twig.demon.co.uk (Fergus McMenemie)
Subject: Re: Download a HTML page with images?
Message-Id: <1gvm5ks.sij2sk7esh6oN%fergus@twig.demon.co.uk>
David K. Wall <darkon.tdo@gmail.com> wrote:
> Fergus McMenemie <fergus@twig.demon.co.uk> wrote:
>
> > I am wanting to download or mirror a series of individual HTML
> > pages, not a whole site. How do you do this with perl? I have
> > looked at LWP mirror and w3mir neither of which seem to do this.
> > mirror does not download assocated images, w3mir insists on
> > placing everything at the root and does not have an option to
> > download a single page with images, style sheets etc.
>
> Instead of trying to reimplement this in Perl, why not use the GNU wget
> program? 'wget -p http://example.dns/page.html' should do it.
>
> (The -p option "causes Wget to download all the files that are
> necessary to properly display a given HTML page. This includes such
> things as inlined images, sounds, and referenced stylesheets.")
Thanks very much; available for UNIX and Windows as well, that will
do nicely! I guess I am so used to being able to do everything in Perl
that I did not properly consider the alternatives :-)
--
Fergus McMenemie Email:fergus@twig.demon.co.uk.
Techmore Ltd Phone:(UK) 07721 376021
Unix/Mac/Intranets Analyst Programmer
------------------------------
Date: Mon, 25 Apr 2005 23:17:43 -0500
From: Wes Groleau <groleau+news@freeshell.org>
Subject: Re: one-time and one-line programs
Message-Id: <d4kfb8$p5g$2@domitilla.aioe.org>
Michael De Tomaso wrote:
> Q:I'd like to know how many perl people keep a stash of one liners and what
> are their favorite quickie code concoctions might be ?
If it's worth keeping, it's worth keeping in a script and
adding a little bit of flexibility to it.
The only one-liners I can remember using in a long time are
search-and-replace, i.e.,
perl -p -i -e 's^old^new^g;' *
--
Wes Groleau
Answer not a fool according to his folly,
lest thou also be like unto him.
Answer a fool according to his folly,
lest he be wise according to his own conceit.
-- Solomon
Are you saying there's no good way to answer a fool?
-- Groleau
------------------------------
Date: 25 Apr 2005 16:23:44 -0700
From: djb@global.net.mt (David Joseph Bonnici)
Subject: Pls help with a Regex
Message-Id: <52e74f9f.0504251523.5d3e341c@posting.google.com>
I have this sort of information in a text file
19:00 STEPPING THE WORLD: Greek Islands - Corfu.
and I am trying to build a regex that will put
19 into backreference 1
00 into backreference 2
STEPPING THE WORLD into backreference 3
Greek Islands - Corfu into backreference 4
I have built this ^(\d{2})(?::|\.)(\d{2})\s(.*)(?::\s)(.*).$ and it works fine
but I want that if I have something like this
19:00 STEPPING THE WORLD
I would still have backreference 1,2, and 3 filled.
Any help
------------------------------
Date: Tue, 26 Apr 2005 01:49:01 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Pls help with a Regex
Message-Id: <3d5e2rF6pqfjvU1@individual.net>
David Joseph Bonnici wrote:
> I have this sort of information in a text file
>
> 19:00 STEPPING THE WORLD: Greek Islands - Corfu.
>
> and I am trying to build a regex that will put
>
> 19 into backreference 1
> 00 into backreference 2
> STEPPING THE WORLD into backreference 3
> Greek Islands - Corfu into backreference 4
>
> I have built this ^(\d{2})(?::|\.)(\d{2})\s(.*)(?::\s)(.*).$ and it works fine
>
> but I want that if I have something like this
> 19:00 STEPPING THE WORLD
>
> I would still have backreference 1,2, and 3 filled.
Then make the last part optional:
^(\d{2})(?::|\.)(\d{2})\s(.*?)(?:(?::\s)(.*).)?$
--------------------------------^-^^^-------------^
or slightly simplified:
^(\d{2})[:.](\d{2})\s(.*?)(?::\s(.*))?$
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 25 Apr 2005 19:50:41 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Pls help with a Regex
Message-Id: <slrnd6r431.tbo.tadmc@magna.augustmail.com>
David Joseph Bonnici <djb@global.net.mt> wrote:
> I have this sort of information in a text file
>
> 19:00 STEPPING THE WORLD: Greek Islands - Corfu.
^^^
^^^
That was a tab character in your post, I plan to make use of that.
> and I am trying to build a regex that will put
>
> 19 into backreference 1
> 00 into backreference 2
> STEPPING THE WORLD into backreference 3
> Greek Islands - Corfu into backreference 4
>
> I have built this ^(\d{2})(?::|\.)(\d{2})\s(.*)(?::\s)(.*).$ and it works fine
It looks like "saying what you want to keep"[1] is hard...
> but I want that if I have something like this
> 19:00 STEPPING THE WORLD
>
> I would still have backreference 1,2, and 3 filled.
"saying what you want to throw away"[2] may be easier.
If the string is already in $_, then:
my @fields = split /:\s*|\t/;
Figuring out how to get rid of the dot from the end of the last
field is left as an exercise for the reader.
Randal has a saying:
[1] If you want to say what to keep then use m// in list context.
[2] If you want to say what to throw away then use split().
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 26 Apr 2005 08:36:07 +0200
From: "David Joseph Bonnici" <djb@global.net.mt>
Subject: Re: Pls help with a Regex
Message-Id: <d4kngr$c5n$1@domitilla.aioe.org>
Thanks it works fine.
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:3d5e2rF6pqfjvU1@individual.net...
> David Joseph Bonnici wrote:
>> I have this sort of information in a text file
>>
>> 19:00 STEPPING THE WORLD: Greek Islands - Corfu.
>>
>> and I am trying to build a regex that will put 19 into
>> backreference 1
>> 00 into backreference 2
>> STEPPING THE WORLD into backreference 3
>> Greek Islands - Corfu into backreference 4
>>
>> I have built this ^(\d{2})(?::|\.)(\d{2})\s(.*)(?::\s)(.*).$ and it works
>> fine
>>
>> but I want that if I have something like this
>> 19:00 STEPPING THE WORLD
>>
>> I would still have backreference 1,2, and 3 filled.
>
> Then make the last part optional:
>
> ^(\d{2})(?::|\.)(\d{2})\s(.*?)(?:(?::\s)(.*).)?$
> --------------------------------^-^^^-------------^
>
> or slightly simplified:
>
> ^(\d{2})[:.](\d{2})\s(.*?)(?::\s(.*))?$
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
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 V10 Issue 8014
***************************************