[25314] in Perl-Users-Digest
Perl-Users Digest, Issue: 7559 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 23 06:05:52 2004
Date: Thu, 23 Dec 2004 03:05:15 -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 Thu, 23 Dec 2004 Volume: 10 Number: 7559
Today's topics:
Example of perl script downloading a web page? <annhuxtable@research.de.edu>
Re: Example of perl script downloading a web page? <spamtrap@dot-app.org>
extracting match found <mtamboli@gmail.com>
Re: extracting match found <uri@stemsystems.com>
Re: extracting match found <abigail@abigail.nl>
Re: extracting match found <abigail@abigail.nl>
Re: extracting match found <uri@stemsystems.com>
Re: extracting match found (Anno Siegel)
Re: generating a session id <lawshouse.public@btconnect.com>
Re: generating a session id <lawshouse.public@btconnect.com>
Re: Good practice to detect empty string? (Anno Siegel)
Re: Is zero even or odd? (John Savard)
Re: Is zero even or odd? (John Savard)
Re: Is zero even or odd? <john@spamless.usa>
Re: Is zero even or odd? <tim@wescottnospamdesign.com>
Re: Is zero even or odd? <jmw@jmwa.demon.contraspam.yuk>
Re: Is zero even or odd? <salesEXTRACT@anasoft.co.uk>
Re: Is zero even or odd? <invalid@msgid.michael.mendelsohn.de>
Re: Is zero even or odd? jmfbahciv@aol.com
Re: need help in programming linux with perl <lie_huo@hotmail.com>
Re: need help in programming linux with perl <noreply@gunnar.cc>
Re: need help in programming linux with perl <no@email.com>
reg expression with input line <sam.wun@authtec.com>
Re: reg expression with input line <do-not-use@invalid.net>
Re: reg expression with input line (Anno Siegel)
Re: reg expression with input line (Anno Siegel)
Re: reg expression with input line <do-not-use@invalid.net>
Re: Reinitializing Size of Anonymous Array xhoster@gmail.com
Re: retrieving Hash elements <georgekinley@hotmail.com>
Re: retrieving Hash elements (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 23 Dec 2004 08:24:26 +0000 (UTC)
From: Dr Ann Huxtable <annhuxtable@research.de.edu>
Subject: Example of perl script downloading a web page?
Message-Id: <cqdvbq$n63$1@hercules.btinternet.com>
Any one know of an example of a Perl script downloading a web page
(actually a web based form), passing in parameters to contol box, user
name, password etc, refreshing the page and then saving page to a file?
I need a similar script to save data from the web. Thank you
Ann
------------------------------
Date: Thu, 23 Dec 2004 05:29:14 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Example of perl script downloading a web page?
Message-Id: <aqqdnVTRrP5mAFfcRVn-uw@adelphia.com>
Dr Ann Huxtable wrote:
> Any one know of an example of a Perl script downloading a web page
> (actually a web based form), passing in parameters to contol box, user
> name, password etc, refreshing the page and then saving page to a file?
Have a look at the WWW::Mechanize module on CPAN.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 22 Dec 2004 22:18:55 -0800
From: "tony" <mtamboli@gmail.com>
Subject: extracting match found
Message-Id: <1103782735.807286.198670@z14g2000cwz.googlegroups.com>
Hi,
I am searching for alternative patterns and had a problem w.r.t
extracting the pattern matched. Here is the code.
$string = "AAAACGTTTTTCTTGAGTTCAGTTTTTAnTC";
while ($string=~
/((GAA|GAG)(TTT|TTC)(TCT|TCC|TCA|TCG|AGT|AGC))|((CGT|CGC|CGA|CGG|AGA|AGG)(TTT|TTC)(TCT|TCC|TCA|TCG|AGT|AGC))/g){
$where = pos($string);
print $1." ".$where,"\n";
}
Ideally it should print the matched entry and the corresponding
position of occurence. However the match CGTTTTTCT is not printed
Output
13
GAGTTCAGT 23
I know it is very simple but i am not realizing where i am making the
mistake.
I would really appreciate if somebody could help me.
Thanks,
tony
------------------------------
Date: Thu, 23 Dec 2004 06:34:15 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: extracting match found
Message-Id: <x74qidbk0o.fsf@mail.sysarch.com>
>>>>> "t" == tony <mtamboli@gmail.com> writes:
t> $string = "AAAACGTTTTTCTTGAGTTCAGTTTTTAnTC";
t> while ($string=~
t> /((GAA|GAG)(TTT|TTC)(TCT|TCC|TCA|TCG|AGT|AGC))|((CGT|CGC|CGA|CGG|AGA|AGG)(TTT|TTC)(TCT|TCC|TCA|TCG|AGT|AGC))/g){
use the /x modifier to make that easier to read:
m{
(
(GAA|GAG)
(TTT|TTC)
(TCT|TCC|TCA|TCG|AGT|AGC)
)
|
(
(CGT|CGC|CGA|CGG|AGA|AGG)
(TTT|TTC)
(TCT|TCC|TCA|TCG|AGT|AGC)
)}gx ) {
t> $where = pos($string);
t> print $1." ".$where,"\n";
print "$1 $where\n" ;
much cleaner.
t> }
t> Ideally it should print the matched entry and the corresponding
t> position of occurence. However the match CGTTTTTCT is not printed
t> Output
t> 13
t> GAGTTCAGT 23
first off you are using all grabbing there when you probably want grouping
instead. use (?:) to group without grabbing (see perlre for
details).
but the real problem is that the regex is working. it tries to match the
first group in the top level alternation. and it does by finding
GAGTTCAGT. but then the cursor is past the CGTTTTTCT part of the string
so it won't match it. you can reverse the order of the alternates and
then it will find both but the problem will happen again if the matches
are found in the other order.
i don't know of any easy general way to force all matches like that in
one regex. a possible way is to use multiple regexes, one for each top
level alternation.
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: 23 Dec 2004 07:24:52 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: extracting match found
Message-Id: <slrncsksm4.non.abigail@alexandra.abigail.nl>
tony (mtamboli@gmail.com) wrote on MMMMCXXXII September MCMXCIII in
<URL:news:1103782735.807286.198670@z14g2000cwz.googlegroups.com>:
{} Hi,
{}
{} I am searching for alternative patterns and had a problem w.r.t
{} extracting the pattern matched. Here is the code.
{}
{} $string = "AAAACGTTTTTCTTGAGTTCAGTTTTTAnTC";
{}
{} while ($string=~
{} /((GAA|GAG)(TTT|TTC)(TCT|TCC|TCA|TCG|AGT|AGC))|((CGT|CGC|CGA|CGG|AGA|AGG)(TTT|TTC)(TCT|TCC|TCA|TCG|AGT|AGC))/g){
{} $where = pos($string);
{} print $1." ".$where,"\n";
{} }
{}
{} Ideally it should print the matched entry and the corresponding
{} position of occurence. However the match CGTTTTTCT is not printed
{}
{} Output
{}
{} 13
{} GAGTTCAGT 23
Turning on warnings would have helped solving the problem. If you do,
you'll notice that on the first iteration, $1 is undefined. If you
have a match 'CGTTTTTCT', it will be in $5.
Either you test for $5, or perhaps better, put in an extra set of
parenthesis (and make the existing parens non-capturing):
#!/usr/bin/perl
use strict;
use warnings;
no warnings qw /syntax/;
my $string = "AAAACGTTTTTCTTGAGTTCAGTTTTTAnTC";
while ($string =~
/((?:(?:GAA|GAG)(?:TTT|TTC)(?:TCT|TCC|TCA|TCG|AGT|AGC)) |
(?:(?:CGT|CGC|CGA|CGG|AGA|AGG)(?:TTT|TTC)(?:TCT|TCC|TCA|TCG|AGT|AGC)))
/xg){
my $where = pos $string;
print "$1 $where\n";
}
__END__
CGTTTTTCT 13
GAGTTCAGT 23
Note also the formatting.
Abigail
--
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");
------------------------------
Date: 23 Dec 2004 07:28:35 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: extracting match found
Message-Id: <slrncskst3.non.abigail@alexandra.abigail.nl>
Uri Guttman (uri@stemsystems.com) wrote on MMMMCXXXII September MCMXCIII
in <URL:news:x74qidbk0o.fsf@mail.sysarch.com>:
<>
<> but the real problem is that the regex is working. it tries to match the
<> first group in the top level alternation. and it does by finding
<> GAGTTCAGT. but then the cursor is past the CGTTTTTCT part of the string
<> so it won't match it. you can reverse the order of the alternates and
<> then it will find both but the problem will happen again if the matches
<> are found in the other order.
Rubbish. A regex always matches leftmost in the string first. So, if
both CGTTTTTCT and GAGTTCAGT match, and CGTTTTTCT is left of GAGTTCAGT,
CGTTTTTCT will be found. Regardless how they are ordered in the alternation.
And the OPs program does produce two lines of output. His problem is one
of paren placing.
<> i don't know of any easy general way to force all matches like that in
<> one regex. a possible way is to use multiple regexes, one for each top
<> level alternation.
His method is correct. It does find all the matches. They just weren't
all in $1.
Abigail
--
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'
------------------------------
Date: Thu, 23 Dec 2004 08:15:05 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: extracting match found
Message-Id: <x7oegla0s7.fsf@mail.sysarch.com>
>>>>> "A" == Abigail <abigail@abigail.nl> writes:
A> Uri Guttman (uri@stemsystems.com) wrote on MMMMCXXXII September MCMXCIII
A> in <URL:news:x74qidbk0o.fsf@mail.sysarch.com>:
A> <>
A> <> but the real problem is that the regex is working. it tries to match the
A> <> first group in the top level alternation. and it does by finding
A> <> GAGTTCAGT. but then the cursor is past the CGTTTTTCT part of the string
A> <> so it won't match it. you can reverse the order of the alternates and
A> <> then it will find both but the problem will happen again if the matches
A> <> are found in the other order.
A> Rubbish. A regex always matches leftmost in the string first. So, if
A> both CGTTTTTCT and GAGTTCAGT match, and CGTTTTTCT is left of GAGTTCAGT,
A> CGTTTTTCT will be found. Regardless how they are ordered in the alternation.
you're right.
A> And the OPs program does produce two lines of output. His problem is one
A> of paren placing.
you may not believe it but i first started to say that when i composed
my reply. then i must have thought the parens were ok (and i didn't even
study my /x version which showed it). so i went in the wrong direction
instead.
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: 23 Dec 2004 10:29:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: extracting match found
Message-Id: <cqe6lc$ge9$3@mamenchi.zrz.TU-Berlin.DE>
Abigail <abigail@abigail.nl> wrote in comp.lang.perl.misc:
[...]
> Either you test for $5, or perhaps better, put in an extra set of
> parenthesis (and make the existing parens non-capturing):
>
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> no warnings qw /syntax/;
>
> my $string = "AAAACGTTTTTCTTGAGTTCAGTTTTTAnTC";
>
> while ($string =~
> /((?:(?:GAA|GAG)(?:TTT|TTC)(?:TCT|TCC|TCA|TCG|AGT|AGC)) |
> (?:(?:CGT|CGC|CGA|CGG|AGA|AGG)(?:TTT|TTC)(?:TCT|TCC|TCA|TCG|AGT|AGC)))
> /xg){
> my $where = pos $string;
> print "$1 $where\n";
> }
>
> __END__
> CGTTTTTCT 13
> GAGTTCAGT 23
In addition, the OP may want to use $-[ 1] instead of pos(). pos()
points one character past the match, $-[ 1] is the first character
of the match.
Anno
------------------------------
Date: Thu, 23 Dec 2004 08:32:05 +0000
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: generating a session id
Message-Id: <m20ls0pdt5hb10me1bgkvai9nmrdrbujti@4ax.com>
On 21 Dec 2004 14:38:34 -0800, ioneabu@yahoo.com wrote:
>The first method is from Apache:Session:MySQL. Why is it any better
>than my version for generating a random 32 character string?
Anyone who's seen my posts in this group knows that I'm a comparative
newbie to Perl and wouldn't presume to advise you on that score. But
I'm an oldie at systems architecture and design in general and on
those subjects I will advise.
First question: why _not_ use Apache:Session:MySQL? Your only reason
to date is that you're not using the rest of it. Just because you've
coded "use Apache:Session:MySQL;" doesn't - unless I'm mistaken - mean
that perl is executing any of the stuff you don't use, so why not just
include that whole wonderful module and use the tiny bit that does
_exactly_ what you want?
Second: if there is a coherent answer to the question above, then are
you sure you're making a good trade-off, increased security (which the
Apache module will certainly give you) against whatever-it-is
(performance is what you're worried about, I guess). Performance can
be fixed; are you planning a million transactions an hour or
something?
Lastly: you're wanting the Apache module to be better than your code
before you'll use it. I suggest most strongly that it doesn't need to
be better to be worth using; it needs just to be as good. Something
someone else wrote (and - most importantly - continues to maintain),
that you can get for free, should be your _first_ choice, even if you
could write it as well yourself. (If you have to pay for the code
then there is still an trade-off but it's not as simple).
>If it's a
>big difference in 'randomness' I could just use their way to generate
>my ids. I still don't need the whole implementation of
>Apache:Session:MySQL for my current purposes. If their is no
>significant difference in the secure randomness of the generated
>strings, I prefer not to use extra modules unnecessarily.
>Thanks!
>
>wana
--
Henry Law <>< Manchester, England
------------------------------
Date: Thu, 23 Dec 2004 08:54:57 +0000
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: generating a session id
Message-Id: <et0ls0lohj8fuqupf7sks9ak1f2r3gcleo@4ax.com>
On 20 Dec 2004 15:06:34 -0800, ioneabu@yahoo.com wrote:
>'Worthless' is a strong criticism for a
>simple piece of code which works
I'll jump in here; Perl I might not be expert in but I've been around
programmers and systems people for long enough to know what asu is
going on about.
Firstly a simple rule, which applies in this group if not in other
places: all code works (absent an error in the perl interpreter). The
difference is between code that does what its author intended it to do
and code that does something unexpected.
Secondly, the worth of code is related to lots of things other than
whether it produces the desired result. The length of time it takes
to write is part of it; the degree to which some maintenance
programmer can make sense of it is a large part (so for throw-away
code the criteria are very different); but there is also an aesthetic
angle to this, understood by all who would be truly excellent at their
craft. (Many project managers and executives don't understand this.)
ASU's point is that your code was a laborious (and therefore
error-prone) way to do something that Perl can do easily and neatly,
so you failed to exploit the resources of the language. Since you're
writing non-throw-away code its worth is therefore very low.
But you must understand that he applies "worthless" to the code, not
to its author.
--
Henry Law <>< Manchester, England
------------------------------
Date: 23 Dec 2004 09:19:52 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Good practice to detect empty string?
Message-Id: <cqe2jo$f32$1@mamenchi.zrz.TU-Berlin.DE>
jl_post@hotmail.com <jl_post@hotmail.com> wrote in comp.lang.perl.misc:
> This quote is widely attributed to Donald Knuth:
>
> "Premature optimization is the root of all evil."
The origin of this popular saying is not clear. Knuth did use it in
_Structured Programming with goto Statements_: "We /should/ forget about
small efficiencies, say about 97% of the time: premature optimization
is the root of all evil."
However, when interviewed about it, Knuth attributed it to Tony
"Quicksort" Hoare. Hoare again doesn't want to own up and vaguely
blames it on Edsger "Harmful" Dijkstra. Dijkstra apparently hasn't
commented (and won't, he died in 2002).
Anno
------------------------------
Date: Thu, 23 Dec 2004 05:48:17 GMT
From: jsavard@excxn.aNOSPAMb.cdn.invalid (John Savard)
Subject: Re: Is zero even or odd?
Message-Id: <41ca59a8.821050@news.ecn.ab.ca>
On Mon, 20 Dec 2004 15:36:15 GMT, "Nicholas O. Lindan" <see@sig.com>
wrote, in part:
>"John Sefton" <john@petcom.com> wrote
>
>> 0 can't be divided by itself,
>
>Sure it can: 0 / 0 = 0 * (1 / 0) = 0 * infinity = 1
>
>It works if the only three numbers in the universe are
>0, 1, and infinity -- A number system that seems very
>suited to usenet.
It is possible to make a set of consistent rules for dividing by zero.
In general for ordinary multiplication and division, if a/b = c, then a
= b*c, and if a = b*c, then a/b = c.
We also know that 0 times any of the old-fashioned numbers we know about
makes 0.
So, if 5/0 = ?, then 5 = 0*?. ? cannot possibly be any number we know
about. Could ? possibly be positive infinity?
What about 0/0 = ?. 0 = 0 * ? is true if ? is any number, positive or
negative; ? can also be zero. Can we say that ? is any finite number?
It turns out those answers are not quite true.
0 = 0 * 0.
Also, 0 = -1 * 0.
So, if 5 = 0 * ?, it's also true that 5 = 0 * -1 * ?, and it's also true
that 5 = 0 * 0 * ?. So ? has to be either plus or minus infinity, or
infinity squared, or infinity cubed, and so on. And even that isn't
*quite* right, but it comes close.
If 5 = 0 * ?, then 0 * 0 * ? can be 0 * 5, or it can be 0 * ?, depending
on which two items you multiply by first.
This means that 0/0 has to be allowed to be plus or minus infinity as
well as any finite number, including zero.
Because the rules break down so badly for dividing by zero, including
the fact that multiplication now stops being associative, mathematicians
have chosen to concentrate on studying only the "real numbers", which
are all finite quantities. This way, they can deduce new theorems from
the properties that multiplication and division have on those numbers;
generalizing to division by zero is not normally done because it appears
that it would just create awkward exceptions in every mathematical
proof, without being fruitful, without producing new, useful results.
John Savard
http://home.ecn.ab.ca/~jsavard/index.html
------------------------------
Date: Thu, 23 Dec 2004 05:50:07 GMT
From: jsavard@excxn.aNOSPAMb.cdn.invalid (John Savard)
Subject: Re: Is zero even or odd?
Message-Id: <41ca5c5c.1513665@news.ecn.ab.ca>
On Wed, 22 Dec 2004 01:56:47 GMT, "Nicholas O. Lindan" <see@sig.com>
wrote, in part:
>Slightly OT, is there an accepted ASCII-gram for square root?
Here's an example of how I draw equations in ASCII art.
_
/ theta / psi pi \ / psi pi \
| sin | ----- + --- | + cos | ----- + --- |
| \ 2 4 / \ 2 4 /
| ------------------------------------------------- , d psi
| ____________________________
| / 2 / psi pi \
| / 1 + tan | ----- - --- |
_/ 0 \/ \ 2 4 /
John Savard
http://home.ecn.ab.ca/~jsavard/index.html
------------------------------
Date: Wed, 22 Dec 2004 22:04:25 -0800
From: John Larkin <john@spamless.usa>
Subject: Re: Is zero even or odd?
Message-Id: <fnnks0pcids29l1ts96blfq1snphd0rd34@4ax.com>
On Thu, 23 Dec 2004 05:48:17 GMT, jsavard@excxn.aNOSPAMb.cdn.invalid
(John Savard) wrote:
>Because the rules break down so badly for dividing by zero, including
>the fact that multiplication now stops being associative, mathematicians
>have chosen to concentrate on studying only the "real numbers", which
>are all finite quantities. This way, they can deduce new theorems from
>the properties that multiplication and division have on those numbers;
>generalizing to division by zero is not normally done because it appears
>that it would just create awkward exceptions in every mathematical
>proof, without being fruitful, without producing new, useful results.
>
Except that in electronic design, especially in realtime embedded
systems, the issues can't be avoided. If you digitize zero volts, and
that's the denominator in some process equation, you can't just say
"oh well, that's not defined/fruitful". Doubly so in a deep embedded
system where you have no audience to complain to.
John
------------------------------
Date: Wed, 22 Dec 2004 22:33:23 -0800
From: Tim Wescott <tim@wescottnospamdesign.com>
Subject: Re: Is zero even or odd?
Message-Id: <10skpl64odh2732@corp.supernews.com>
John Larkin wrote:
> On Thu, 23 Dec 2004 05:48:17 GMT, jsavard@excxn.aNOSPAMb.cdn.invalid
> (John Savard) wrote:
>
>
>
>>Because the rules break down so badly for dividing by zero, including
>>the fact that multiplication now stops being associative, mathematicians
>>have chosen to concentrate on studying only the "real numbers", which
>>are all finite quantities. This way, they can deduce new theorems from
>>the properties that multiplication and division have on those numbers;
>>generalizing to division by zero is not normally done because it appears
>>that it would just create awkward exceptions in every mathematical
>>proof, without being fruitful, without producing new, useful results.
>>
>
>
> Except that in electronic design, especially in realtime embedded
> systems, the issues can't be avoided. If you digitize zero volts, and
> that's the denominator in some process equation, you can't just say
> "oh well, that's not defined/fruitful". Doubly so in a deep embedded
> system where you have no audience to complain to.
>
> John
>
I have found, however, that if one has a model that leads one to a
divide by zero problem one is suffering from one of two problems: one,
an insufficient model, or two, an inaccurate measurement (which one can
sophomoricaly lump into one, if one is so inclined).
It is always necessary to ask yourself "why am I allowing a division by
something that may go to zero?" "What does it mean if my 'x' is zero
here?", etc., and code accordingly.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
------------------------------
Date: Thu, 23 Dec 2004 07:03:52 +0000
From: John Woodgate <jmw@jmwa.demon.contraspam.yuk>
Subject: Re: Is zero even or odd?
Message-Id: <n0BcrbBY3myBFwpa@jmwa.demon.co.uk>
I read in sci.electronics.design that John Savard <jsavard@excxn.aNOSPAM
b.cdn.invalid> wrote (in <41ca5c5c.1513665@news.ecn.ab.ca>) about 'Is
zero even or odd?', on Thu, 23 Dec 2004:
>On Wed, 22 Dec 2004 01:56:47 GMT, "Nicholas O. Lindan" <see@sig.com>
>wrote, in part:
>
>>Slightly OT, is there an accepted ASCII-gram for square root?
>
>Here's an example of how I draw equations in ASCII art.
>
> _
> / theta / psi pi \ / psi pi \
> | sin | ----- + --- | + cos | ----- + --- |
> | \ 2 4 / \ 2 4 /
> | ------------------------------------------------- , d psi
> | ____________________________
> | / 2 / psi pi \
> | / 1 + tan | ----- - --- |
>_/ 0 \/ \ 2 4 /
>
You obviously belong to the 'mural' school of ASCII art, like Fred
Bloggs.
--
Regards, John Woodgate, OOO - Own Opinions Only.
The good news is that nothing is compulsory.
The bad news is that everything is prohibited.
http://www.jmwa.demon.co.uk Also see http://www.isce.org.uk
------------------------------
Date: Thu, 23 Dec 2004 07:46:47 GMT
From: "Kevin Aylward" <salesEXTRACT@anasoft.co.uk>
Subject: Re: Is zero even or odd?
Message-Id: <HJuyd.3829$0W6.3603@fe2.news.blueyonder.co.uk>
Nicholas O. Lindan wrote:
> "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com> wrote
>> Nicholas O. Lindan wrote:
>>> 1 / 0 = oo
>>> n / 0 = n * oo
>>> 0 / 0 = 0 * oo = 1
>>
>> oo (infinity isn't a number) so you cannot use it this way.
>
> Yes, that's my point. Keep track of oo, don't merge it with
> numbers.
>
> j [sqrt(-1)] isn't a number but we still mix it up with numbers.
Of course it is a number, thats why we treat it as such.
> For infinity I can look in the sky. For 0 I can examine my
> bank balance. But for j I can't look anywhere,
Not really relevant. Numbers only "exist" in the mind.
>but still
> it has use. With that perspective oo + 1 may be worth
> manipulating.
>
> I will admit, I find no use for 1/0 and 1 + oo > oo.
> It's a mental itch. And here's this scratching post.
>
> As justification, j was pretty useless/undefined/don't
What do you mean by this?
Most things have no meaning if we don't know what it is.
> talk about it for till (someone famous) came up with e^jx,
> which on the face of it makes even less sense.
Not to a mathematician.
>
> So, as hobby, I am exploring the idea that if you can
> keep track of oo and 1/0 and 4*0 it might have some
> advantage.
"Keeping track" of oo is already well established in mathematics. You
seem to be implying that this idea is novel.
Kevin Aylward
salesEXTRACT@anasoft.co.uk
http://www.anasoft.co.uk
SuperSpice, a very affordable Mixed-Mode
Windows Simulator with Schematic Capture,
Waveform Display, FFT's and Filter Design.
------------------------------
Date: Thu, 23 Dec 2004 10:50:30 +0100
From: Michael Mendelsohn <invalid@msgid.michael.mendelsohn.de>
Subject: Re: Is zero even or odd?
Message-Id: <41CA94E6.D288AB9F@msgid.michael.mendelsohn.de>
Kevin Aylward schrieb:
> Nicholas O. Lindan wrote:
> > j [sqrt(-1)] isn't a number but we still mix it up with numbers.
>
> Of course it is a number, thats why we treat it as such.
>
> > For infinity I can look in the sky. For 0 I can examine my
> > bank balance. But for j I can't look anywhere,
>
> Not really relevant. Numbers only "exist" in the mind.
Weak answer.
Points on a plane are often modelled as complex numbers, so you need
only look as far as graph paper to "see" them.
Bring more popcorn!
Michael
--
Still an attentive ear he lent Her speech hath caused this pain
But could not fathom what she meant Easier I count it to explain
She was not deep, nor eloquent. The jargon of the howling main
-- from Lewis Carroll: The Three Usenet Trolls
------------------------------
Date: Thu, 23 Dec 04 10:13:35 GMT
From: jmfbahciv@aol.com
Subject: Re: Is zero even or odd?
Message-Id: <LqqdnSKC-50_PlfcRVn-1g@rcn.net>
In article <x5brcmaylr.fsf@lola.goethe.zz>,
David Kastrup <dak@gnu.org> wrote:
>John Fields <jfields@austininstruments.com> writes:
>
>> On Wed, 22 Dec 2004 09:31:53 -0800, "Alfred Z. Newmane"
>> <a.newmane.remove@eastcoastcz.com> wrote:
>>
>>
>>>Try it on a calc for starters. You just can't divide by zero.
>>
>> ---
>> Depends on the calculator.
>>
>> I have an _old_ Commodore C8, and if you divide by zero (0.0,
>> actually) the display will count up.
Are you sure that 0.0 was really 0.000000000?
>
>I had an even older calculator, and its motor would just keep spinning
>without the total ever changing.
We got an SPR (software performance report) complaining about one
of our CPU model's results when a number was divided by zero.
So JMF tried it on all three of our models. He got three different
outcomes; he chuckled about that one for three weeks.
Unfortunately, I no longer remember what the outcomes were.
/BAH
Subtract a hundred and four for e-mail.
------------------------------
Date: Thu, 23 Dec 2004 02:02:26 -0500
From: "Roll" <lie_huo@hotmail.com>
Subject: Re: need help in programming linux with perl
Message-Id: <a0d432f2a1fe4711fc3029767b48e62f@localhost.talkaboutprogramming.com>
well i need to do a project and i was not allowed to use the webmin program
so do you haf any refrence that can teach me how to use perl to program
something like webmin?
------------------------------
Date: Thu, 23 Dec 2004 07:59:26 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: need help in programming linux with perl
Message-Id: <32v90kF3q0iqaU1@individual.net>
Roll wrote:
> well i need to do a project and i was not allowed to use the webmin program
> so do you haf any refrence that can teach me how to use perl to program
> something like webmin?
http://learn.perl.org/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 23 Dec 2004 10:29:34 -0000
From: "Brian Wakem" <no@email.com>
Subject: Re: need help in programming linux with perl
Message-Id: <32vl0eF3rinl5U1@individual.net>
"Roll" <lie_huo@hotmail.com> wrote in message
news:a0d432f2a1fe4711fc3029767b48e62f@localhost.talkaboutprogramming.com...
> well i need to do a project and i was not allowed to use the webmin
program
> so do you haf any refrence that can teach me how to use perl to program
> something like webmin?
>
You could download Webmin and look at the scripts that power it.
--
Brian Wakem
------------------------------
Date: Thu, 23 Dec 2004 15:22:20 +0800
From: sam <sam.wun@authtec.com>
Subject: reg expression with input line
Message-Id: <cqdt92$2vqi$1@news.hgc.com.hk>
Hi,
I would like to write a perl script to parse each line read from a text
file.
I ended up some perl code as shown below:
($prodcode,$custname,$qty,$cost,$date,$prodname) =
/^([0-9\-]+) +([A-Za-z0-9\-]+) +([0-9]+\.[0-9][0-9])
+([0-9]+\.[0-9][0-9])([0-9]+)(.*)/,
"12031361 ABC3 567.00
5177.6620041127\xbd\xba\xa6w\xc5@\xb9\xea\xb4f\xc5\xd6\xa5\xa9(\xacX\xb2n\xb4\xd6\
xbch)\xa4\xe9\xa5\xce12x20's";
print "Result:
".$prodcode.",".$custname.",".$qty.",".$cost.",".$date.",".$prodname . "\n";
if ($prodcode eq "" or $custname eq "" or $qty eq "" or $cost eq "" or
$date eq "" or $prodname eq "") {
print "Failed to parse input file.\n";
exit;
}
But the parser failed to parse the input text, it returns empty string.
What is wrong with the above code, especially the parser I created for
parsing the $date.
Thanks
Sam
------------------------------
Date: 23 Dec 2004 10:47:27 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: reg expression with input line
Message-Id: <yzdwtv9ibww.fsf@invalid.net>
sam <sam.wun@authtec.com> writes:
>
> I would like to write a perl script to parse each line read from a
> text file.
> I ended up some perl code as shown below:
>
> ($prodcode,$custname,$qty,$cost,$date,$prodname) =
> /^([0-9\-]+) +([A-Za-z0-9\-]+) +([0-9]+\.[0-9][0-9])
> +([0-9]+\.[0-9][0-9])([0-9]+)(.*)/,
> "12031361 ABC3 567.00
> 5177.6620041127\xbd\xba\xa6w\xc5@\xb9\xea\xb4f\xc5\xd6\xa5\xa9(\xacX\xb2n\xb4\xd6\
> xbch)\xa4\xe9\xa5\xce12x20's";
>
> print "Result:
> ".$prodcode.",".$custname.",".$qty.",".$cost.",".$date.",".$prodname
> . "\n";
>
> if ($prodcode eq "" or $custname eq "" or $qty eq "" or $cost eq "" or
> $date eq "" or $prodname eq "") {
> print "Failed to parse input file.\n";
> exit;
> }
>
> But the parser failed to parse the input text, it returns empty string.
> What is wrong with the above code, especially the parser I created for
> parsing the $date.
To begin with, you should ask perl for warnings, either with the -w
option, or with the directive "use warnings;". Then it will tell you
that you get uninitialized values on the "print" line. Your test already
shows that, but you will see that in fact all variables are uninitialized
(meaning their value is 'undef').
It also tells you "Useless use of a constant in void context". It points
out the line where the statement starts, not the place where the constant
starts, but there is only one constant here anyway, and it's the data
string.
The immediate suspicion is that
($var) = /regexp/, "string";
may not be the way to ask perl to match a string with a regexp. And
it isn't. Look it up and you'll see that it is
($var) = "string" =~ /regexp/;
Now that still won't work, because you only get a list from a regexp
if you ask for all matches, which you do with the 'g' modifier. So
you want
($var) = "string" =~ /regexp/g;
The parenthesized items in your regexp match their counterpart in the
string, so after rewriting as I described, it will work.
I don't see much of a parser to parse $date. [0-9]+ seems to work here
for extracting that part of the string, as long as you're sure that
the first following character is not a digit. You can use \d instead
of [0-9], it means the same thing.
------------------------------
Date: 23 Dec 2004 10:00:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: reg expression with input line
Message-Id: <cqe4vl$ge9$1@mamenchi.zrz.TU-Berlin.DE>
sam <sam.wun@authtec.com> wrote in comp.lang.perl.misc:
> Hi,
>
> I would like to write a perl script to parse each line read from a text
> file.
> I ended up some perl code as shown below:
>
> ($prodcode,$custname,$qty,$cost,$date,$prodname) =
> /^([0-9\-]+) +([A-Za-z0-9\-]+) +([0-9]+\.[0-9][0-9])
> +([0-9]+\.[0-9][0-9])([0-9]+)(.*)/,
Up to here, it looks like a regex of sorts, but what is this:
> "12031361 ABC3 567.00
> 5177.6620041127\xbd\xba\xa6w\xc5@\xb9\xea\xb4f\xc5\xd6\xa5\xa9(\xacX\xb2n\xb4\xd6\
> xbch)\xa4\xe9\xa5\xce12x20's";
> print "Result:
> ".$prodcode.",".$custname.",".$qty.",".$cost.",".$date.",".$prodname . "\n";
Use string interpolation, not concatenation if there are lots of
variables. Better yet, collect the result in an array @data, then
say
print "Result: ", join( ',', @data), "\n";
> if ($prodcode eq "" or $custname eq "" or $qty eq "" or $cost eq "" or
> $date eq "" or $prodname eq "") {
> print "Failed to parse input file.\n";
> exit;
> }
...and this could be written
print "Failed to parse input file.\n" if grep length() == 0, @data;
> But the parser failed to parse the input text, it returns empty string.
> What is wrong with the above code, especially the parser I created for
> parsing the $date.
Which part of the regex is supposed to parse a date, and in what format?
What does the input data look like anyway? It's probably possible to
infer that from the (mangled) code you've given, but I'm not going to.
Anno
------------------------------
Date: 23 Dec 2004 10:09:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: reg expression with input line
Message-Id: <cqe5gl$ge9$2@mamenchi.zrz.TU-Berlin.DE>
Arndt Jonasson <do-not-use@invalid.net> wrote in comp.lang.perl.misc:
[...]
> ($var) = "string" =~ /regexp/;
>
> Now that still won't work, because you only get a list from a regexp
> if you ask for all matches, which you do with the 'g' modifier. So
That is not true. /g is only needed when the regex doesn't capture
anything. If it does, the captures will be delivered in list context.
Anno
------------------------------
Date: 23 Dec 2004 11:23:01 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: reg expression with input line
Message-Id: <yzdsm5xia9m.fsf@invalid.net>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> Arndt Jonasson <do-not-use@invalid.net> wrote in comp.lang.perl.misc:
>
> [...]
>
> > ($var) = "string" =~ /regexp/;
> >
> > Now that still won't work, because you only get a list from a regexp
> > if you ask for all matches, which you do with the 'g' modifier. So
>
> That is not true. /g is only needed when the regex doesn't capture
> anything. If it does, the captures will be delivered in list context.
Oops. I'm sorry for being misleading. Clearly described in the regexp
section, too...
------------------------------
Date: 23 Dec 2004 05:18:32 GMT
From: xhoster@gmail.com
Subject: Re: Reinitializing Size of Anonymous Array
Message-Id: <20041223001832.467$AB@newsreader.com>
BigDaDDY <ihatespam@hotmail.com> wrote:
> How would I reinitialize the size of an anonymous array? For example:
>
> foreach $run (@runs){
>
> push (@{$table{$country}}), $city
> }
You want to clear an array and then push something onto it?
Wouldn't that be identical to the much simpler:
@{$table{$country}}=$city;
Not that either one makes much sense in the context of your loop.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Thu, 23 Dec 2004 08:31:42 GMT
From: "George Kinley" <georgekinley@hotmail.com>
Subject: Re: retrieving Hash elements
Message-Id: <Onvyd.33266$k4.639198@news1.nokia.com>
daniel kaplan wrote:
> Hello all,
>
> Was trying to see if there is a way to retrieve hash keys in the
> order they were created? Which I have not found in any of my books
> or perldoc. I realize I could make an array for the keys, and call
> it back that way, but I dunno, seems kind of kludge like.
>
> Thought there might be a simple way, but everything I read says "..do
> not have a guaranteed order."
>
> Thanks ahead,
>
> Daniel
why not just add another key an index number and sort on index key
------------------------------
Date: 23 Dec 2004 10:40:18 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: retrieving Hash elements
Message-Id: <cqe7ai$ge9$4@mamenchi.zrz.TU-Berlin.DE>
George Kinley <georgekinley@hotmail.com> wrote in comp.lang.perl.misc:
> daniel kaplan wrote:
>
> > Hello all,
> >
> > Was trying to see if there is a way to retrieve hash keys in the
> > order they were created? Which I have not found in any of my books
> > or perldoc. I realize I could make an array for the keys, and call
> > it back that way, but I dunno, seems kind of kludge like.
> >
> > Thought there might be a simple way, but everything I read says "..do
> > not have a guaranteed order."
> >
> > Thanks ahead,
> >
> > Daniel
>
> why not just add another key an index number and sort on index key
Because it's inefficient. You *get* the keys in their desired sequence,
so why use sorting to recover that sequence?
Anno
------------------------------
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 7559
***************************************