[16874] in Perl-Users-Digest
Perl-Users Digest, Issue: 4286 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 11 14:10:43 2000
Date: Mon, 11 Sep 2000 11:10:28 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968695827-v9-i4286@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 11 Sep 2000 Volume: 9 Number: 4286
Today's topics:
how to match the hole string by first word? (need help) <a-kogan@nwu.edu>
Re: how to match the hole string by first word? (need h (Andrew J. Perrin)
Re: how to match the hole string by first word? (need h <aqumsieh@hyperchip.com>
Re: how to match the hole string by first word? (need h <undergronk@my-deja.com>
Re: how to match the hole string by first word? (need h <red_orc@my-deja.com>
Re: how to match the hole string by first word? (need h <a-kogan@nwu.edu>
Re: how to match the hole string by first word? (need h <randy_734@my-deja.com>
Re: Howto debug a perl cgi script yossariancomputing@my-deja.com
Re: Howto debug a perl cgi scriptB yossariancomputing@my-deja.com
Ideas on writing a bot/parser for grabbing prices bluearchtop@my-deja.com
Including Files rathmore@tierceron.com
Re: Including Files wrathmolten@my-deja.com
Re: Is there a file rename function? <sariq@texas.net>
Re: Is there a file rename function? <russ_jones@rac.ray.com>
Re: Is there a file rename function? (Tom Christiansen)
Re: LDAP web searches (Abigail)
Re: LittleProblem (Kai Diefenbach)
Re: LittleProblem (Gwyn Judd)
Re: LittleProblem <mcnultya@nortelnetworks.com>
Re: Need Help! OK Who wants to laugh at my first perl a <sysnovice@my-deja.com>
Network Workgroop <mtveerman_nospam@mindless.com>
Re: Obtaining a list of installed modules & their versi (David Wall)
Perl substraction weird result karabot@canada.com
Perl substraction weird result karabot@canada.com
Re: Perl substraction weird result <red_orc@my-deja.com>
Re: Perl substraction weird result <randy_734@my-deja.com>
perl:sort & store hash subbudeja@my-deja.com
Re: Qualifications for new Perl programmer????? (brian d foy)
Reference to a Function!! houseofpain@my-deja.com
Re: Reference to a Function!! (Randal L. Schwartz)
Re: regular expression syntax (Andrew Johnson)
Re: regular expression syntax <ren.maddox@tivoli.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 11 Sep 2000 10:51:16 -0500
From: Alexandr Kogan <a-kogan@nwu.edu>
Subject: how to match the hole string by first word? (need help)
Message-Id: <39BCFF74.9762CE52@nwu.edu>
Hello,
after many years I'm returning to PERL and I have a problem.
I need to go through a huge text file find strings that start with
the same word and convert the whole line to lowercase. I'm having
problems getiing a hold of a whole string, that's what I'm doing:
while (<INPUT>) {
if ($s =~ /^objectclass: /i) {
chop $_;
$_ = lc($_);
print OUTPUT $_;}
else {print OUTPUT $_;}
}
Could someone tell me what is wrong and how to do it right?
Thank you very much, Alex.
--
Alexandr Kogan
------------------------------
Date: 11 Sep 2000 12:07:07 -0400
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: how to match the hole string by first word? (need help)
Message-Id: <u8zsyq5ec.fsf@demog.berkeley.edu>
Alexandr Kogan <a-kogan@nwu.edu> writes:
> Hello,
> after many years I'm returning to PERL and I have a problem.
> I need to go through a huge text file find strings that start with
> the same word and convert the whole line to lowercase. I'm having
> problems getiing a hold of a whole string, that's what I'm doing:
>
> while (<INPUT>) {
> if ($s =~ /^objectclass: /i) {
> chop $_;
> $_ = lc($_);
> print OUTPUT $_;}
> else {print OUTPUT $_;}
> }
>
> Could someone tell me what is wrong and how to do it right?
> Thank you very much, Alex.
You don't tell us what problems you're having, which makes it hard to
help in depth. However the following seems to meet your needs (tested
with 5.005_03 under NT):
#!perl -w
use strict;
while (<STDIN>) {
$_ = lc $_ if /^objectclass: /i;
print STDOUT $_;
}
>
> --
> Alexandr Kogan
--
----------------------------------------------------------------------
Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
----------------------------------------------------------------------
------------------------------
Date: Mon, 11 Sep 2000 16:33:02 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: how to match the hole string by first word? (need help)
Message-Id: <7absxu28jk.fsf@merlin.hyperchip.com>
Alexandr Kogan <a-kogan@nwu.edu> writes:
> Hello,
> after many years I'm returning to PERL and I have a problem.
> I need to go through a huge text file find strings that start with
> the same word and convert the whole line to lowercase. I'm having
> problems getiing a hold of a whole string, that's what I'm doing:
What exactly are your problems?
> while (<INPUT>) {
> if ($s =~ /^objectclass: /i) {
what is $s? Shouldn't it be $_?
> chop $_;
> $_ = lc($_);
> print OUTPUT $_;}
> else {print OUTPUT $_;}
> }
--Ala
------------------------------
Date: Mon, 11 Sep 2000 16:28:24 GMT
From: Scott Kirk <undergronk@my-deja.com>
Subject: Re: how to match the hole string by first word? (need help)
Message-Id: <8pj16c$m4m$1@nnrp1.deja.com>
In article <39BCFF74.9762CE52@nwu.edu>,
Alexandr Kogan <a-kogan@nwu.edu> wrote:
> I need to go through a huge text file find strings that start with
> the same word and convert the whole line to lowercase. I'm having
> problems getiing a hold of a whole string, that's what I'm doing:
>
> while (<INPUT>) {
> if ($s =~ /^objectclass: /i) {
> chop $_;
> $_ = lc($_);
> print OUTPUT $_;}
> else {print OUTPUT $_;}
> }
Your nearly there, but I think you have a syntax error in the second
line. How does $s get assigned? Do you mean $_?
If you say:
while (<INPUT>) {
if (/^objectclass: /i) {
chomp;
$_ = lc($_);
print OUTPUT $_;
} else {
print OUTPUT $_;
}
}
this seems to do what you want. Also use chomp to remove newlines,
chop() munces the last character, whatever it is.
HTH
--
Scott Kirk
My deja.com mailbox is full of spam. Use this instead:
perl -e '$_ = "znvygb: haqretebax\@lnubb.pbz";
tr/A-Za-z/N-ZA-Mn-za-m/; print;'
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 11 Sep 2000 16:26:06 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: how to match the hole string by first word? (need help)
Message-Id: <8pj123$m2q$1@nnrp1.deja.com>
In article <39BCFF74.9762CE52@nwu.edu>,
Alexandr Kogan <a-kogan@nwu.edu> wrote:
> Hello,
> after many years I'm returning to PERL and I have a problem.
> I need to go through a huge text file find strings that start with
> the same word and convert the whole line to lowercase. I'm having
> problems getiing a hold of a whole string, that's what I'm doing:
>
> while (<INPUT>) {
> if ($s =~ /^objectclass: /i) {
where do you set $s ?
> chop $_;
do you really want to eliminate the last character, or do you only want
to use chomp to eliminate any final newline?
> $_ = lc($_);
> print OUTPUT $_;}
> else {print OUTPUT $_;}
do you really only want to eliminate that final character for lines that
match the conditional? or do you want to put that character back when
you write it back out?
> }
>
> Could someone tell me what is wrong and how to do it right?
> Thank you very much, Alex.
>
> --
> Alexandr Kogan
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 11 Sep 2000 11:36:33 -0500
From: Alexandr Kogan <a-kogan@nwu.edu>
Subject: Re: how to match the hole string by first word? (need help)
Message-Id: <39BD0A11.CFDE5FB@nwu.edu>
Andrew,
thank you very much. That worked.
Sorry about poor explanation, I'll give more details next time.
Thanks again, Alex.
"Andrew J. Perrin" wrote:
>
> Alexandr Kogan <a-kogan@nwu.edu> writes:
>
> > Hello,
> > after many years I'm returning to PERL and I have a problem.
> > I need to go through a huge text file find strings that start with
> > the same word and convert the whole line to lowercase. I'm having
> > problems getiing a hold of a whole string, that's what I'm doing:
> >
> > while (<INPUT>) {
> > if ($s =~ /^objectclass: /i) {
> > chop $_;
> > $_ = lc($_);
> > print OUTPUT $_;}
> > else {print OUTPUT $_;}
> > }
> >
> > Could someone tell me what is wrong and how to do it right?
> > Thank you very much, Alex.
>
> You don't tell us what problems you're having, which makes it hard to
> help in depth. However the following seems to meet your needs (tested
> with 5.005_03 under NT):
>
> #!perl -w
>
> use strict;
>
> while (<STDIN>) {
> $_ = lc $_ if /^objectclass: /i;
> print STDOUT $_;
> }
>
> >
> > --
> > Alexandr Kogan
>
> --
> ----------------------------------------------------------------------
> Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
> aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
> ----------------------------------------------------------------------
--
Alexandr Kogan
------------------------------
Date: Mon, 11 Sep 2000 17:44:23 GMT
From: Randy <randy_734@my-deja.com>
Subject: Re: how to match the hole string by first word? (need help)
Message-Id: <39bd184f.14745875@207.126.101.100>
I noticed that you included the shebang line in your listing and also
mentioned that you are using NT. I'm using 5.006 on NT and find that
#!perl -w
doesn't work. It doesn't do anything.
use warnings; # this does work
Is this different from what you are experiencing? If so, could it be
the version? Any ideas?
Randy Harris
aperrin@demog.berkeley.edu (Andrew J. Perrin) wrote:
>[snipped]
>
>#!perl -w
>
>use strict;
>
>while (<STDIN>) {
> $_ = lc $_ if /^objectclass: /i;
> print STDOUT $_;
>}
>
>
>>
>> --
>> Alexandr Kogan
>
>--
>----------------------------------------------------------------------
>Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
> aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
>----------------------------------------------------------------------
------------------------------
Date: Mon, 11 Sep 2000 15:07:04 GMT
From: yossariancomputing@my-deja.com
Subject: Re: Howto debug a perl cgi script
Message-Id: <8pise4$g2i$1@nnrp1.deja.com>
Hi,
I don't know if I'll find the error from what you say, but everything
you give is good advice....thnx v.much.
BTW I use ssh to update my live server, so ftp bin/ascii issues are not
a problem....and I get a level of security too ;-)
Rgds,
Steve H
> You could insert the following near the beginning of your script so
errors
> will hopefully go to the browser. This assumes that you test any open
()
> statements and have a die error including the reason $! if they fail.
>
> If that gets you nothing on a Unix system you could try making a
wrapper
> to get all errors (2>&1 redirects stderr to stdout):
>
> #!/bin/sh
> echo "Content-type: text/plain
> echo
> ./other.cgi 2>&1
>
> If that fails, make sure that you are ftp uploading scripts as ASCII
text,
> and NOT binary mode.
>
> >I'll pick this up tomorrow...the script that's not working is at
least
> >flagged as such (see www.yossarian-
music.com/content/content.html)...so
> >it'll have to wait as I'm off to my pit to get some rest ;)
> >
> >Thnx for your help,
> >
> >Steve H
>
> --
> David Efflandt efflandt@xnet.com http://www.de-srv.com/
> http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
> http://hammer.prohosting.com/~cgi-wiz/ http://cgi-
help.virtualave.net/
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 11 Sep 2000 14:57:57 GMT
From: yossariancomputing@my-deja.com
Subject: Re: Howto debug a perl cgi scriptB
Message-Id: <8pirt7$fah$1@nnrp1.deja.com>
> Another interesting way is to get yourself a teddy bear, or
> voodoo doll, or whatever, and explain the problem to it. You
> would be suprised how many times the bear will tell you the answer.
> I did not make this up, I got the idea from "The Practice of
> Programming" (page 123) by Brian Kernighan and Robert Pike. It has
> saved me from asking embarassing questions to others , now if
> only it could help me with the foot-in-mouth syndrome I have here.
>
> :-)
Yeah...good advice...I have many non-technical friends who regularly
serve such a purpose 4 me ;)
..good luck with the foot in mouth syndrome too...I also have the
uncanny ability of saying things I shouldn't...but what the hell, what
do they expect from an overly emotional techy?
Steve H
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 11 Sep 2000 15:47:07 GMT
From: bluearchtop@my-deja.com
Subject: Ideas on writing a bot/parser for grabbing prices
Message-Id: <8piupj$j30$1@nnrp1.deja.com>
I am going to write a Perl script that will fetch and traverse sites
like http://electronics.cnet.com/cgi/crunch/pcompare2.asp?
ptable=Television_Sets&sortby=Brand,Model to get the lowest price on
consumer electronics. So, it should be able to pull out a brand/model
and lowest price, then on next 15, etc, etc.
I'm sure this has been done before, so I'm looking for a starting point
and some modules that might help?
Thanks!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 11 Sep 2000 17:29:26 GMT
From: rathmore@tierceron.com
Subject: Including Files
Message-Id: <8pj4on$qli$1@nnrp1.deja.com>
I've got a C++ background and I'm on a crash course to learn Perl for a
project at work. I can't seem to figure out how to include a file
within my main file. Here's what I've done:
I've got a file called Order_Methods.pm that includes all my variable
declarations and functions. My main() function in in a file called
OrderMan.pl.
How do I include the file Order_Methods.pm within OrderMan.pl when I
compile? In C++ it would look like this:
#include "Order_Methods.cpp" or #include <stdio.h>
I've reviewed and tried both the require and use commands but get the
following error when I do:
C:\Projects\Web_Order_Automation>perl OrderMan.pl
Can't locate Projects/Web_Order_Automation/NNIorder_methods.pm in @INC
(@INC contains: C:/Perl/lib C:/Perl/site/lib .) at OrderMan.pl line 8.
Your assistance is greatly appreciated!
(BTW, I bought a copy of O'Reilly's "Perl Cookbook" and "Learning Perl"
to learn the language.)
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 11 Sep 2000 17:34:11 GMT
From: wrathmolten@my-deja.com
Subject: Re: Including Files
Message-Id: <8pj52h$r21$1@nnrp1.deja.com>
> I've got a file called Order_Methods.pm that includes all my variable
> declarations and functions. My main() function in in a file called
> OrderMan.pl.
I really am using the correct file name. I just realized that in my
post I used a different file name above than what you see in my error
message. Order_Methods.pm is not the file name it is
NNIorder_methods.pm. I just typed the wrong one above so my problem
isn't the file name and my question still stands.
Thanks!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 11 Sep 2000 10:46:09 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Is there a file rename function?
Message-Id: <39BCFE41.A25791C4@texas.net>
Gwyn Judd wrote:
>
> I was shocked! How could Ken <kenn_mar@hotmail.com>
> say such a terrible thing:
> >Hi all,
> >The subject title says it all. Any doc on how file rename can be done? I
> ^^^^^^
> >know I did come across it somewhere but just couldn't recall.
>
> And today's winner for the prize for a self answering question is Ken!
> What's he won Bob?
1500 pages of *free* Perl documentation! Installed directly on his
harddrive!
- Bob
------------------------------
Date: Mon, 11 Sep 2000 11:18:09 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Is there a file rename function?
Message-Id: <39BD05C1.D0B2FC12@rac.ray.com>
Gwyn Judd wrote:
>
> >Hi all,
> >The subject title says it all. Any doc on how file rename can be done? I
> ^^^^^^
> >know I did come across it somewhere but just couldn't recall.
>
> And today's winner for the prize for a self answering question is Ken!
> What's he won Bob?
>
Well, Monty, lucky Ken's just won himself an absolutely FREE copy of
the Perl documentation, and (hold on to your hat, Ken) and, for being
the first caller today, he also gets the Perl FAQ and a lovely little
search engine to go with it. Now, would you like to take a chance,
Ken, and go for what Jay's got on his table? Just ask how to delete a
file and it could all be YOURS!!! The snake knives, the trip to China,
the year's supply of Ersatz Brother's Coffee, the autographed picture
of Porgy and Mudhead...
--
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
Quae narravi, nullo modo negabo. - Catullus
------------------------------
Date: 11 Sep 2000 10:33:48 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Is there a file rename function?
Message-Id: <39bd096c@cs.colorado.edu>
In article <39BB22FC.A929D601@hotmail.com>, Ken <kenn_mar@hotmail.com> wrote:
>Hi all,
>The subject title says it all. Any doc on how file rename can be done? I
>know I did come across it somewhere but just couldn't recall.
The answer, of course, is to grep the fine manual. If it's a function
you want, it's in perlfunc.
% man perlfunc | grep rename
or, using the new perlman tool,
% perlfunc rename
or
% perlhelp rename
--tom
------------------------------
Date: 11 Sep 2000 16:05:05 GMT
From: abigail@foad.org (Abigail)
Subject: Re: LDAP web searches
Message-Id: <slrn8rq0jk.b1k.abigail@alexandra.foad.org>
peter furmonavicius (PETER@YaleVM.YCC.Yale.edu) wrote on MMDLXVIII
September MCMXCIII in <URL:news:FF93C2S86.PETER@YaleVM.YCC.Yale.edu>:
|| Hello. I was wondering if someone might be able to point me to some code
|| that could be used as a web interface to an LDAP directory for the
|| purposes of doing searches. I would like to set up a web page that
|| would be used to search our LDAP directory. Thanks.
search.cpan.org
Abigail
--
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT
# A pair of lovers fight
# under a she-oak tree.
# Two wolves. Two bears eat.
------------------------------
Date: Mon, 11 Sep 2000 15:04:10 GMT
From: k.diefenbach@tpp24.net (Kai Diefenbach)
Subject: Re: LittleProblem
Message-Id: <39bcf33a.35786548@news.talknet.de>
Hi Nez,
nezarite wrote:
> $\ = "\n";
> print for aaaa..zzzz;
unfortunately i can't improve this
maybe next time ...
until then ...
best regards
Kai
__
come to the team
kai.diefenbach@tsg-handball.de
http://www.tsg-handball.de
------------------------------
Date: Mon, 11 Sep 2000 15:09:46 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: LittleProblem
Message-Id: <slrn8rptkk.383.tjla@thislove.dyndns.org>
I was shocked! How could nezarite <mcnultya@nortelnetworks.com>
say such a terrible thing:
>Hey there,
>
>I'm trying to do an algorithm to cycle through all possible combinations of
>a number of letters in a string.
>
>I'm not very good at making myself clear, but this should help:
>
>I want to print the following:
>
>aaaa
>aaab
>aaac
>...
>...
>zzzz
$\ = "\n";
print for (aaaa..zzzz);
>Can anyone suggest an idea ?
>The closest I have got is :
>
>my $string = "aaaa";
>my $length = length($string);
>
>my @alphabet = (a..z);
so close :)
<snip>
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
War is menstruation envy.
------------------------------
Date: Mon, 11 Sep 2000 16:51:24 +0100
From: "nezarite" <mcnultya@nortelnetworks.com>
Subject: Re: LittleProblem
Message-Id: <8piv02$qlh$1@qnsgh006.europe.nortel.com>
Dr. Peter Dintelmann <Peter.Dintelmann@dresdner-bank.com> wrote in message
news:8pir81$sl41@intranews.bank.dresdner.net...
>
> nezarite schrieb in Nachricht
> <8piq0j$o65$1@qnsgh006.europe.nortel.com>...
> >> print "$_\n" for 'aaaa'..'zzzz';
> >>
>
> >Or even:
> >
> > $\ = "\n";
> > print for aaaa..zzzz;
>
> yepp, but does not run under 'use strict'
> and is two bytes long when you use the quotes
>
> B-)
well, if we're gonna be picky... ;o)
you've got a useless stringification in yours!
=|8-)
------------------------------
Date: Mon, 11 Sep 2000 16:04:00 GMT
From: Greg Donovan <sysnovice@my-deja.com>
Subject: Re: Need Help! OK Who wants to laugh at my first perl attempt?
Message-Id: <8pivp0$k8o$1@nnrp1.deja.com>
In this line next if $letters =~ /^\.\.?$/;
next if $letters =~ /[__]/; # This is a bug
I was trying to ignore lines like
__GENNAME__
__VALIDITY__
__deliver__
__lock__
Can you please explain why the second line is a bug?
Thanks
G.Donovan
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 11 Sep 2000 17:37:10 +0200
From: "Maarten Veerman" <mtveerman_nospam@mindless.com>
Subject: Network Workgroop
Message-Id: <8piu5t$f0d$1@news.tudelft.nl>
Win32 question
What module(s) do I need to do the following:
Get the list of computers in a workgroop and a list of all workgroops....
I need this so I can search files over a network....
Maarten
------------------------------
Date: 11 Sep 2000 13:06:38 -0400
From: darkon@one.net (David Wall)
Subject: Re: Obtaining a list of installed modules & their versions
Message-Id: <8FAC8D998darkononenet@206.112.192.118>
calle@lysator.liu.se (Calle Dybedahl) wrote in
<86its4r2ck.fsf@tezcatlipoca.algonet.se>:
>>>>>> "Juan" == Juan M Courcoul <courcoul@campus.qro.itesm.mx> writes:
>
>> How can I determine what a Perl installation has and its versions ?
>
>Check the autobundle function in the CPAN module documentation.
Well, phooey, I never noticed that, or I wouldn't have wasted my time
writing a little function that uses File::Find to get module names.
Oh well, it was still a fun thing to do, even if it was unnecessary.
--
David Wall
darkon@one.net
------------------------------
Date: Mon, 11 Sep 2000 17:09:39 GMT
From: karabot@canada.com
Subject: Perl substraction weird result
Message-Id: <8pj3k0$p4s$1@nnrp1.deja.com>
We are running version 5.005_03 built for i386-linux on a slackware 7.0
server. Check out the following calculation:
% perl -e 'print(30.4 - 30 . "\n")'
0.399999999999999
Does anybody know why the result is NOT 0.4 ?
Thank you in advance,
George
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 11 Sep 2000 17:08:54 GMT
From: karabot@canada.com
Subject: Perl substraction weird result
Message-Id: <8pj3ik$p48$1@nnrp1.deja.com>
We are running version 5.005_03 built for i386-linux on a slackware 7.0
server. Check out the following calculation:
% perl -e 'print(30.4 - 30 . "\n")'
0.399999999999999
Does anybody know why the result is NOT 0.4 ?
Thank you in advance,
George
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 11 Sep 2000 17:15:08 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Perl substraction weird result
Message-Id: <8pj3u5$pol$1@nnrp1.deja.com>
In article <8pj3ik$p48$1@nnrp1.deja.com>,
karabot@canada.com wrote:
> We are running version 5.005_03 built for i386-linux on a slackware
7.0
> server. Check out the following calculation:
>
> % perl -e 'print(30.4 - 30 . "\n")'
> 0.399999999999999
>
> Does anybody know why the result is NOT 0.4 ?
consult perlfaq4 for more details, but:
your computer represents floating point numbers in binary. 0.4 cannot be
exactly represented as a binary floating point number.
you may want to look into printf.
>
> Thank you in advance,
>
> George
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 11 Sep 2000 17:53:18 GMT
From: Randy <randy_734@my-deja.com>
Subject: Re: Perl substraction weird result
Message-Id: <39bd1b78.15554046@207.126.101.100>
This doesn't have anything to do with Perl, any computer language
would do the same. It is a result of how the data is stored in the
computer.
Try:
% perl -e 'printf("%.1f", 30.4 - 30 . "\n")'
That should format it to a single decimal place.
karabot@canada.com wrote:
>We are running version 5.005_03 built for i386-linux on a slackware 7.0
>server. Check out the following calculation:
>
>% perl -e 'print(30.4 - 30 . "\n")'
>0.399999999999999
>
>Does anybody know why the result is NOT 0.4 ?
>
>Thank you in advance,
>
>George
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
------------------------------
Date: Mon, 11 Sep 2000 17:20:04 GMT
From: subbudeja@my-deja.com
Subject: perl:sort & store hash
Message-Id: <8pj47b$ptu$1@nnrp1.deja.com>
Plese help me out:
I have to sort a hash by value in perl and store the sorted in another
hash. Can somebody send me a code how to do this?
I appreciate ur help
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 11 Sep 2000 12:06:58 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <brian-ya02408000R1109001206580001@news.panix.com>
In article <slrn8rpoua.383.tjla@thislove.dyndns.org>, tjla@guvfybir.qlaqaf.bet (Gwyn Judd) posted:
> This reminds me of the guy who used the 'delete' compression software.
> Everytime he wanted to "uncompress" a file he would use the 'undelete'
> command. By the way she said a minimum of 500 lines so yours fails. ;)
any specification which includes a minimum line count must have
been written by a moron or someone who gets paid by the line.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Mon, 11 Sep 2000 16:35:09 GMT
From: houseofpain@my-deja.com
Subject: Reference to a Function!!
Message-Id: <8pj1jr$mq0$1@nnrp1.deja.com>
How do a store a reference to a function in oop.
$function = \&foo works but what if the function is
$this->foo() how do i store that in a var.
thanx
josh
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 11 Sep 2000 09:53:40 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Reference to a Function!!
Message-Id: <m1aedevpij.fsf@halfdome.holdit.com>
>>>>> "houseofpain" == houseofpain <houseofpain@my-deja.com> writes:
houseofpain> How do a store a reference to a function in oop.
houseofpain> $function = \&foo works but what if the function is
houseofpain> $this->foo() how do i store that in a var.
my $function = sub { $this->foo(@_) };
:-)
Just be sure that $this is a lexical variable, and doesn't get changed
by the time you need to call it.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 11 Sep 2000 15:40:35 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: regular expression syntax
Message-Id: <T17v5.15199$a5.214641@news1.rdc1.mb.home.com>
In article <slrn8rpt49.383.tjla@thislove.dyndns.org>,
Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
[snip]
> That is quite simple.
Perhaps -- but your regex doesn't fit the OP's requirements. Test it
again on this content:
$content = <<END_OF_THE_WORLD;
this is the pre stuff
<ul>
<li>this is the list stuff
</ul>
this is the last stuff
<ul>
<li> more last stuff
</ul>
the end
END_OF_THE_WORLD
regards,
andrew
--
Andrew L. Johnson http://members.home.net/perl-epwp/
They're not soaking, they're rusting!
-- my wife on my dishwashing habits
------------------------------
Date: 11 Sep 2000 10:55:06 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: regular expression syntax
Message-Id: <m37l8i3ov9.fsf@dhcp11-177.support.tivoli.com>
tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:
> ($precontent, $alist, $postcontent) =
> ($content =~ m; # a regex
> ( # start recording 1
> (?: # a group
> <(?!ul>) # match a '<' that is not
> # followed by 'ul>'
> | # OR failing that
> .* # match anything else
> ) # end of that group
> * # zero or more times
> ) # stop recording 1
> <ul> # match a literal '<ul>'
> ( # start recording 2
> (?: # a group
> <(?!/ul>) # match a '<' that is not
> # followed by '/ul>'
> | # OR failing that
> .* # anything else
> ) # end of that group
> * # zero or more times
> ) # stop recording 2
> </ul> # a literal '</ul>'
> (.*) # match anything till the end
> ;xs); # the end
Hmm... when you alternate "<(?!ul>)" with ".*", that still matches
anything.
Your example works because you only have one occurrence of "<ul>", but
add another and the first one will be included in $precontent. The
same thing holds for the "<(?!/ul>)|.*", which will include all but
the last "</ul>" in $alist. (Well, after the last <ul> that is -- any
"</ul>" before the last "<ul>" will be in $precontent. This is
probably not a problem unless you have nested "<ul>...</ul>"
structures, as otherwise there will not be more than one "</ul>" after
the last "<ul>". And if there is nesting, then that presents a whole
new set of problems.)
So, without nesting, and as long as all "<ul>"s are paired with a
"</ul>" (and vice-versa), your RE will find the *last* such pair. The
OP wanted the *first*. To get that, simply change the ".*" in your
alternations to "[^<]*".
And as a bonus, if you change the "(.*)" at the end to
"((?:<(?!ul)|[^<]*)*)" (and add a "g" modifier), then you can use this
RE to match multiple "<ul>...</ul>" pairs. Of course, that isn't what
the OP asked for.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4286
**************************************