[10434] in Perl-Users-Digest
Perl-Users Digest, Issue: 4027 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 20 20:03:13 1998
Date: Tue, 20 Oct 98 17:00:25 -0700
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, 20 Oct 1998 Volume: 8 Number: 4027
Today's topics:
Re: Amputated Perl Code <rootbeer@teleport.com>
Application Requirements <gregory_guerin@hp.com>
Re: Application Requirements <rootbeer@teleport.com>
Re: Build DBD-Oracle-0.54 on Windows NT <lukep@its.washington.edu>
Re: Can't do "use lib" <rootbeer@teleport.com>
Re: Cool company has Perl jobs! <keithmur@mindspring.com>
Re: CreateObject doesn't work via my browser <keithmur@mindspring.com>
Re: curly quick question <bobn@interaccess.com>
Re: Environement variables and PATH <rootbeer@teleport.com>
Re: File locking with FNCTL.pm <rootbeer@teleport.com>
Re: Handling cookies in Perl for IE <rootbeer@teleport.com>
Help using OLE <chad@anlon.com>
Re: Help using OLE (Jan Dubois)
How to copy a 2-dimensional array to another array <tpham@ee.gatech.edu>
Re: How to copy a 2-dimensional array to another array <rick.delaney@shaw.wave.ca>
Re: How to copy a 2-dimensional array to another array <jdf@pobox.com>
Re: how to get a column from a hash? oofness <aqumsieh@tigre.matrox.com>
Re: How to link Perl script (cgi) with ready-made Windo <rootbeer@teleport.com>
Re: Installing modules on Win'95 <metcher@spider.herston.uq.edu.au>
Re: Network browsing <rootbeer@teleport.com>
Re: Off topic: is he that Larry Wall? <keithmur@mindspring.com>
Re: Perl "Packager" ?? (Statically-linked include file (Martien Verbruggen)
Perl Modulus operator unreliable? Help!! (Jason Witherspoon)
Re: Perl Modulus operator unreliable? Help!! <rick.delaney@shaw.wave.ca>
Re: Perl Modulus operator unreliable? Help!! (Larry Rosler)
Re: Perl Modulus operator unreliable? Help!! <rootbeer@teleport.com>
Perl variables and regular expressions <puyleart@netconcepts.com>
Re: Perl variables and regular expressions (Larry Rosler)
Re: Perl variables and regular expressions <jdf@pobox.com>
Re: printing array elements <rootbeer@teleport.com>
Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has regi <eashton@bbnplanet.com>
Re: Request for Perl script that emulate Remote Shell <rootbeer@teleport.com>
Re: Searching for long lines in a huge text file. (Martien Verbruggen)
Re: sequential count <rootbeer@teleport.com>
Re: Show files for download <rootbeer@teleport.com>
Socket Listner <konganda@corp.earthlink.net>
test <dpk@brainiac.egr.msu.edu>
Re: Typing something without seeing with perl / Win NT (Larry Rosler)
Where's the mailin "guru" certificate? <tturton@cowboys.anet-dfw.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 20 Oct 1998 23:21:39 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Amputated Perl Code
Message-Id: <Pine.GSO.4.02A.9810201614590.5534-100000@user2.teleport.com>
On Tue, 20 Oct 1998, Justin Wilde wrote:
> Normally these scripts run fine, but it appears that occasionally they
> are cut short, often midway through a bracketed block of code. I
> assume this is what's happening because the line of code the perl
> compiler considers to be EOF is only partway through my file.
>
> What might cause this? The scripts are used only to process STDIN and
> display html pages. Concurrency wouldn't be an issue, would it?
Is this happening "all by itself"? It sounds as if perl is seeing the end
of file before the true end of file. This could be caused by a problem in
your IO system, or mmmmmmmmmmaybe an unexpected signal coming in during
the time that Perl is parsing your program. My best guess is that your
files are on NFS or a similar system which is not delivering the whole
file every time. You may be able to "stress test" the system to see how it
behaves, but be sure to ask for permission first. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 20 Oct 1998 16:24:42 -0600
From: Greg Guerin <gregory_guerin@hp.com>
Subject: Application Requirements
Message-Id: <362D0DAA.47F8FA73@hp.com>
I'm writing to see if there is a way to copy a minimal amount of files
to a system without perl installed on it in order to make it possible to
execute scripts. The scripts will manipulate the local file directory
of that machine and communicate back with the server. Any input on this
would be most appreciated.
Greg Guerin
gregory_guerin@hp.com
------------------------------
Date: Tue, 20 Oct 1998 23:25:19 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Application Requirements
Message-Id: <Pine.GSO.4.02A.9810201624060.5534-100000@user2.teleport.com>
On Tue, 20 Oct 1998, Greg Guerin wrote:
> I'm writing to see if there is a way to copy a minimal amount of files
> to a system without perl installed on it in order to make it possible
> to execute scripts.
Yes, there is a minimum number of files needed to make Perl work. :-)
But why not simply install Perl, and be able to do more than the minimum?
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 20 Oct 1998 16:07:41 -0700
From: "Luke Pond" <lukep@its.washington.edu>
Subject: Re: Build DBD-Oracle-0.54 on Windows NT
Message-Id: <70j57u$ndk$1@nntp6.u.washington.edu>
>Also, I tried to download the binary version of it from
>www.activestate.com/packges (horrible page layout). It always tried to
connect
>localhost:4444. Anyone
>downed from this URL before?
As the page suggests, you should use the Perl Package Manager script
(ppm.pl) included in the ActiveState distribution. From the PPM> prompt,
type "install DBI" and "install DBD-Oracle". This should get everything you
need.
------------------------------
Date: Tue, 20 Oct 1998 23:07:40 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Can't do "use lib"
Message-Id: <Pine.GSO.4.02A.9810201603420.5534-100000@user2.teleport.com>
On 20 Oct 1998, Luu Tran wrote:
> My admin won't install perl5
What good is an admin who won't install software? Upgrade to a better
admin or today's will be the smallest of your problems.
> so I grabbed a bindist and put it in my directory (I couldn't build
> it.) It's working fine except I can't use any module.
> perl complains that it can't find lib.pm so I change the shebang line
You'll need to use a BEGIN block in that case. Something like this:
BEGIN { push @INC, '/where/lib/is'; }
> Now it doesn't say it can't find lib.pm but it complains
>
> use: command not found
That's not from Perl; that's probably the shell trying to run your
program. Fix your #! line.
> Please remove the underscore _ in my address when replying by email
Please remove the underscore _ in your address when you want replies by
email
Good luck - you'll need it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 20 Oct 1998 17:31:25 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: Cool company has Perl jobs!
Message-Id: <362D0F3D.1DEE3199@mindspring.com>
Adam Turoff wrote:
>
> For instance, they have documented their use of Linux internally in the
> development of IE/UNIX. Yes, Microsoft uses Linux as a software development
> platform.
>
Kind of irritating then, that they won't release IE *for* Linux! (I
mean, now that I've bastardized my Win95 with Perl, I won't be happy
until I do the same to my Linux!)
------------------------------
Date: Tue, 20 Oct 1998 17:21:22 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: CreateObject doesn't work via my browser
Message-Id: <362D0CE2.7841184E@mindspring.com>
Actually the script works fine on my system (Win95 running MS Personal
Web Server; the browser is Netscape 4.06). I take it from your previous
postings that you *CAN* run a simple CGI script from a browser. Can you
run a simple CGI script on the same *directory*, with the same *file
type* (like .pl for both) on the same *system*, with the same *browser*
that you're trying with your OLE script? Do the *scripts* have the same
permissions (check the file properties)? If so, *I'm* baffled. Let me
know.
Matt Sergeant wrote:
>
> nicolaslecart@my-dejanews.com wrote:
> >
> > Hello,
> >
> > i wrote a simple cgi script which just read the properties
> > of an Excel document.
> >
> > When i run it under a dos window ("perl scipt.pl") it works very well;
> > But when i excute it via my browser, the function
> > CreateObject can't create an Excel object instance, and i don't know why :-(((
>
> [snip]
>
> > What the cause of this trouble ?? are my browser or my web server
> > misconfigured?
>
> No. A web server can't run a GUI application - who would use the GUI?
>
> Create a CSV file instead using one of the many modules to do that from
> the CPAN.
>
> --
> <Matt/>
>
> | Fastnet Software Ltd | Perl in Active Server Pages |
> | Perl Consultancy, Web Development | Database Design | XML |
> | http://come.to/fastnet | Information Consolidation |
------------------------------
Date: Tue, 20 Oct 1998 17:43:16 -0500
From: bobn <bobn@interaccess.com>
Subject: Re: curly quick question
Message-Id: <362D1204.328676BB@interaccess.com>
Look up autoflush in the doc. I think that'll do the trick.
HTH,
- Bob N.
Arran Price wrote:
> Take the following script:
>
> #!/usr/local/bin/perl
>
> print "doing something";
> system("find /usr/* -name foo");
>
> Why does the print happen after the system call has finished?
>
> if I change it so theres a \n in the print call then it does do it first
> eg
>
> #!/usr/local/bin/perl
>
> print "doing something\n";
> system("find /usr/* -name foo");
>
> Unfortunately what I wanted to do was say what it was doing and then add
> either
> -Successful or -Failed on the same line once it had finished the
> operation.
> eg output would be
> Doing find (does the operation) - Successful (on the same line)
>
> Any help appreciated.(even if its just pointing to where in the docs
> this may be mentioned as I havent been able to find it)
>
> Arran
> My opinions are my own and do not reflect those of my employer.
------------------------------
Date: Tue, 20 Oct 1998 22:54:34 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Environement variables and PATH
Message-Id: <Pine.GSO.4.02A.9810201548060.5534-100000@user2.teleport.com>
On 20 Oct 1998, Nestor Florez wrote:
> I am runnig a html that calls a perl/cgi program.
Not to flame you for your terminology, but this is like saying, "I'm
eating a fork that digests a food." :-)
> My problem is that when I call the archiver program it can not find it.
Actually, this isn't a Perl problem. Your program, written in any other
language, would have the same trouble trying to find your files.
> If I call the archive program with a fullpath it finds it, but the
> archiver program, calls other utilities that are not found because
> certain path and environment variables are unknow when running a
> cgi/perl script because at that moment the user is "nobody".
The userid has nothing to do with this particular problem. But if you wish
to set an environment variable, check out the %ENV hash in the perlvar
manpage.
Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 20 Oct 1998 22:39:24 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: File locking with FNCTL.pm
Message-Id: <Pine.GSO.4.02A.9810201538280.5534-100000@user2.teleport.com>
On Tue, 20 Oct 1998, niki clayton wrote:
> I need to use fnctl() to lock files.
No, you can use Perl's flock function to lock files. It's more portable.
See Randal's fourth Web Techniques column, which explains how to use
flock() to avoid problems when multiple processes need to modify one file.
Hope this helps!
http://www.stonehenge.com/merlyn/WebTechniques/
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 20 Oct 1998 23:01:58 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Handling cookies in Perl for IE
Message-Id: <Pine.GSO.4.02A.9810201601430.5534-100000@user2.teleport.com>
On Tue, 20 Oct 1998, Chris Haines wrote:
> I am having problems being able to manipulate cookies for IE 4
> browsers.
If you're following the proper protocol but some browser or server doesn't
cooperate, then it's the other program's fault. If you're not following
the protocol, then it's your fault. If you aren't sure about the protocol,
you should read the protocol specification. If you've read it and you're
still not sure, you should ask in a newsgroup about the protocol.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 20 Oct 1998 18:05:52 -0500
From: Chad Moston <chad@anlon.com>
Subject: Help using OLE
Message-Id: <362D1750.F98F3317@anlon.com>
I'm fairly new at perl and I need a little help.
Do you need to install the LAOLA version in order
to use Win32::OLE?
Thanks
------------------------------
Date: Wed, 21 Oct 1998 01:32:56 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: Help using OLE
Message-Id: <363a1bb7.61848233@news3.ibm.net>
[mailed & posted]
Chad Moston <chad@anlon.com> wrote:
>I'm fairly new at perl and I need a little help.
>Do you need to install the LAOLA version in order
>to use Win32::OLE?
No, you don't. You need WinNT (or Win95/98) to run it though; it doesn't
work on UNIX. You get Win32::OLE either with libwin32-0.13 for Perl 5.004 or
with ActivePerl build 504 (Perl 5.005_02).
-Jan
------------------------------
Date: Tue, 20 Oct 1998 18:36:22 -0400
From: Tien Pham <tpham@ee.gatech.edu>
To: tpham@ee.gatech.edu
Subject: How to copy a 2-dimensional array to another array
Message-Id: <362D1066.1195CAFE@ee.gatech.edu>
Hello there,
I have a (stupid) question regarding to copying an array
to another (both are 2-dimensional).
Can we do this: @A = @B;
Or we have to copy element by element of B to A?
Thank you very much in advance,
tien pham
tpham@ee.gatech.edu
--
Plan:
To live
To enjoy
To appreciate
every opportunity and every minute here, in America!
--------------------------------------
------------------------------
Date: Tue, 20 Oct 1998 23:35:34 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: How to copy a 2-dimensional array to another array
Message-Id: <362D1FDD.8FF564CE@shaw.wave.ca>
[posted & mailed]
Tien Pham wrote:
>
> Hello there,
>
> I have a (stupid) question regarding to copying an array
>
> to another (both are 2-dimensional).
>
> Can we do this: @A = @B;
>
> Or we have to copy element by element of B to A?
WHWYTI?
Observe:
#!/usr/local/bin/perl -w
@B = ([1, 2],
[3, 4],
);
@A = @B;
$A[0][0] = 'changed in @A';
print "Output: $B[0][0]\n";
__END__
Output: changed in @A
So yes, you do need to copy element by element if you want a copy of the
whole structure. This is because a 2-dimensional array is really an
array of *references* to arrays.
perldoc perlref
perldoc perllol
Here's OWTDI:
@A = map { [ @$_ ] } @B;
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: 21 Oct 1998 01:40:50 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: Tien Pham <tpham@ee.gatech.edu>
Subject: Re: How to copy a 2-dimensional array to another array
Message-Id: <m3btn6ajjx.fsf@joshua.panix.com>
Tien Pham <tpham@ee.gatech.edu> writes:
> I have a (stupid) question regarding to copying an array
> to another (both are 2-dimensional).
>
> Can we do this: @A = @B;
That line will copy into @A the array references that are in @B, which
is not what you want. If you change an element in @A, the
corresponding element in @B will have changed.
> Or we have to copy element by element of B to A?
Well, yes and no. Here's a way to do it, though it won't work for
higher-dimensional arrays.
@A = map { [@$_] } @B;
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 20 Oct 1998 18:46:25 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: how to get a column from a hash? oofness
Message-Id: <x3y3e8ietry.fsf@tigre.matrox.com>
dtiberio6639@my-dejanews.com writes:
>
> I have a hash, and would like ot get a column from it.
>
> Here is an example:
>
> $var{$type, $subtype} = $val;
>
First of all, that is not the proper way of creating two dimentional
hashes. Consult perldsc for more details.
Perl will interpret {$type, $subtype} as a string concatenation
resulting in a single key element with value "$type$subtype" .. which
is probably not what your looking for.
The proper way to do what you want is:
$var{$type}{$subtype} = $val;
> now how do I get a variable that contains all entries where $type
> is a specific value, or how do I get a variable that contains all
> entries where $subtype equals a specific value?
>
> $var{bill, banana} = 10;
> $var{bill, soda} = 20;
> $var{jen, banana} = 5;
> $var{fred, banana} = 20;
> $var{fred, potato} = 1;
>
> now how do I get all entries for "fred"?
@keys = keys %{$var{fred}};
@values = values %{$var{fred}};
> or how do I get all entries for "banana"?
That's a bit tricky .. you have to use a loop.
>
> what I am doing right now is looping through all the values, and building
> a new hash or stack, but there must be a better way!
>
> dtiberio
> oofness
Hope this helps,
--
Ala Qumsieh email: aqumsieh@matrox.com
ASIC Design Engineer phone: (514) 822-6000 x7581
Matrox Graphics Inc. (old) webpage :
Montreal, Quebec http://www.cim.mcgill.ca/~qumsieh
------------------------------
Date: Tue, 20 Oct 1998 23:10:21 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: How to link Perl script (cgi) with ready-made Windows application ?
Message-Id: <Pine.GSO.4.02A.9810201609100.5534-100000@user2.teleport.com>
On Tue, 20 Oct 1998, Darius Jack wrote:
> how can I transfer parameters from CGI-Perl application (input from
> web page) into ready-made MS WIN application (search engine), running
> on PC, having no source code, no description do DLL files.
If you don't know how to call an external application, check that
application's docs. If you don't know how to call _any_ external
application, check the system function in the perlfunc manpage. If you
don't know how to process the parameters in a CGI script, see the CGI
module's docs. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 21 Oct 1998 08:32:16 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Installing modules on Win'95
Message-Id: <362D0F70.6173A087@spider.herston.uq.edu.au>
Yes, not necessarily true, but anything that uses the "command1 &&
command2" idiom (such as the makefile for perl) is in trouble. One day
I might cave in and buy 4DOS, but the it rankles the purist in me that I
need a commercial add-on to use a free compiler to compile a free
package. Hopefully Win98 is the end of the line for command.com. In
the meantime, I use the NT machine on the next desk for my compiling.
--
Jaime Metcher
Randy Kobes wrote:
>
> Hi,
> That's not necessarily true that makefiles bomb under Win95;
> although the READMEs certainly state that NT is preferred, people
> install modules under Win95/98 quite successfully, even ones that
> need a C compiler. Even so, and also for other reasons, one might
> want to look at the 4DOS utilities at
> http://www.jpsoft.com/
> I find it worthwhile just for the tab filename completion alone ...
------------------------------
Date: Tue, 20 Oct 1998 22:34:46 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Network browsing
Message-Id: <Pine.GSO.4.02A.9810201532420.5534-100000@user2.teleport.com>
On Tue, 20 Oct 1998, Michael Ansley wrote:
> Could somebody please direct me to a suitable reference for accessing
> the NT directory database or browser service.
The docs, FAQs, and newsgroups about NT may be useful here.
> Please return to the address above, as I do not have access to the
> newsgroup
However do you post to a newsgroup to which you have no access? Do you
have access to the web or e-mail? Those can be used to read the
newsgroup's messages. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 20 Oct 1998 18:11:02 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: Off topic: is he that Larry Wall?
Message-Id: <362D1886.671B7043@mindspring.com>
John Porter wrote:
>
> Joergen W. Lang wrote:
> >
> > Who might be the mother ?
> > Or did Perl come into this world by something like "sprouting" ?
>
> More like Athenogenesis.
>
No, for computer languages, that's "parthenogenesis". Oh, excuse my
LISP.
------------------------------
Date: Tue, 20 Oct 1998 22:53:34 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl "Packager" ?? (Statically-linked include files)
Message-Id: <Ov8X1.10$Fh4.91821@nsw.nnrp.telstra.net>
In article <70ic9s$ih3$1@news1-alterdial.uu.net>,
"Matt Kruse" <mkruse@rens.com> writes:
> I looked, but I don't think this does what I'm asking for. I only want
> included files and modules in-lined into one perl script,
Ah, sorry, I misunderstood. I thought you needed something to make
sure all dependencies were distributed.
If all the code you'll be utilising is perl code, all you have to do
is wrap it all in one file, in the right order. I can't say I would
approve of this, stylistically, though :)
If there is any XS stuff or dependencies on external C libraries, you
can't do this.
> so I don't
> have any "require" or "use" statements in my perl script.
All the code in one file will get rid of those, but again, I don't see
that as an improvement.
In your original post you said something about 'statically linked
DLLs', but that analogy would mean 'external module'. DLL means
Dynamically linked library. I suppose you meant statically linked
library, of which perl doesn't really have a concept.
I suppose you could write a simple parser, that figures out the
dependencies of your script, and wraps it all in one big gob of a
file, ready for distribution. This will not work for c dependent code,
though.
HTH,
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd. | cynical. It's perfectly easy to be
NSW, Australia | cynical.
------------------------------
Date: 20 Oct 1998 22:31:52 GMT
From: arzachel@best.spamazoid.com (Jason Witherspoon)
Subject: Perl Modulus operator unreliable? Help!!
Message-Id: <362d0f58$0$12421@nntp1.ba.best.com>
Hi all--
Here's three debugging lines from a script I'm working on:
DB<12> print 1799 % 25
24
DB<13> print $price % 25
23
DB<14> print $price
1799
It's a little backwards, but surely you can see the problem. Is the
modulus operator simply unreliable? It seems to work okay for smaller
numbers, but I have no clue how Perl explains the above w/Boolean
logic.
Please e-mail me direct if possible w/reassurance that I shouldn't just
learn C++ & forget about this language.
<><><>Remove the ".spamazoid" to reach me, unless ye be a spammer<><><>
Jason Witherspoon
--- ---
----O----
--- ---
--- ---
---------
--- ---
com/~arz
http://www.best.com/~arzachel
www.best.com/~arzachel
best.com/~a
------------------------------
Date: Tue, 20 Oct 1998 23:22:16 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Perl Modulus operator unreliable? Help!!
Message-Id: <362D1CA7.D7D98A63@shaw.wave.ca>
Jason Witherspoon wrote:
>
> Hi all--
>
> Here's three debugging lines from a script I'm working on:
>
> DB<12> print 1799 % 25
> 24
> DB<13> print $price % 25
> 23
> DB<14> print $price
> 1799
Where's the line where you set $price? You have probably assigned a
floating point number very close to 1799 to $price to get the behaviour
you describe. Perhaps $price is calculated from some other values?
I can get the same behaviour by setting
$price = 1798.999999999999;
See perlfaq4, "Why am I getting long decimals (eg, 19.9499999999999)
instead of the numbers I should be getting (eg, 19.95)?"
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Tue, 20 Oct 1998 16:31:04 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Modulus operator unreliable? Help!!
Message-Id: <MPG.1096bd112848c29898982d@nntp.hpl.hp.com>
In article <362d0f58$0$12421@nntp1.ba.best.com> on 20 Oct 1998 22:31:52
GMT, Jason Witherspoon <arzachel@best.spamazoid.com> says...
...
> DB<12> print 1799 % 25
> 24
> DB<13> print $price % 25
> 23
> DB<14> print $price
> 1799
Try the following commands:
$price = 1799
print $price
1799
print %price % 25
24 $price = 1799 - 1e-12
print $price
1799
print $price % 25
23
printf '%.14f', $price
1798.99999999999910
Get it?
> <><><>Remove the ".spamazoid" to reach me, unless ye be a spammer<><><>
Remove it yourself if you want an email response.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 20 Oct 1998 23:33:07 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Perl Modulus operator unreliable? Help!!
Message-Id: <Pine.GSO.4.02A.9810201628370.5534-100000@user2.teleport.com>
On 20 Oct 1998, Jason Witherspoon wrote:
> Here's three debugging lines from a script I'm working on:
>
> DB<12> print 1799 % 25
> 24
> DB<13> print $price % 25
> 23
> DB<14> print $price
> 1799
That's not necessarily a bug or unreliability. Remember that modulus is an
integer operation, so you're really doing a call to int() as well. Could
$price actually be 1798.999999999999?
DB<9> $price = 1798.999999999999
DB<10> print $price % 25
23
DB<11> print $price
1799
DB<12> printf "%.25f", $price
1798.9999999999990905052982271
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 20 Oct 1998 17:22:57 -0500
From: "Jason Puyleart" <puyleart@netconcepts.com>
Subject: Perl variables and regular expressions
Message-Id: <70j262$eu2$1@news2.alpha.net>
If you are using a variable in a regular expression, what steps can you take
to properly escape it so you don't run into parsing problems?
ex.
$foo = "foo\bar"
if ($foo =~ /$foo/)
or something similar to this....
Thanks in advance.
Jason
------------------------------
Date: Tue, 20 Oct 1998 15:32:36 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl variables and regular expressions
Message-Id: <MPG.1096af624b8d65b698982c@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <70j262$eu2$1@news2.alpha.net> on Tue, 20 Oct 1998 17:22:57 -
0500, Jason Puyleart <puyleart@netconcepts.com> says...
> If you are using a variable in a regular expression, what steps can you take
> to properly escape it so you don't run into parsing problems?
>
> ex.
>
> $foo = "foo\bar"
> if ($foo =~ /$foo/)
perldoc -f quotemeta, or
if ($foo =~ /\Q$foo/)
BTW, do you really want to have a backspace in the middle of your string
$foo? If not, use single quotes, or double the backslash.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 21 Oct 1998 01:29:22 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: "Jason Puyleart" <puyleart@netconcepts.com>
Subject: Re: Perl variables and regular expressions
Message-Id: <m3g1ciak31.fsf@joshua.panix.com>
"Jason Puyleart" <puyleart@netconcepts.com> writes:
> If you are using a variable in a regular expression, what steps can
> you take to properly escape it so you don't run into parsing
> problems?
> $foo = "foo\bar"
$foo now contains a backspace, and will print as "fooar". Is that
really what you meant? Perhaps you meant
$foo = 'foo\bar'
> if ($foo =~ /$foo/)
That's a weird use of metasyntactic variables. You do intend to have
two different expressions there, right?
I think you're asking "how can I keep the '\b' sequence from being
interpreted as a word boundary". If so, then see quotemeta() in
perlfunc and the \Q..\E operators in perlre.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Tue, 20 Oct 1998 22:30:42 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: printing array elements
Message-Id: <Pine.GSO.4.02A.9810201526080.5534-100000@user2.teleport.com>
On Mon, 19 Oct 1998, Marcus J. Foody wrote:
> I need to print out the record header along with the its appropriate
> items.
What's stopping you?
> open(FH25, "<./join/test.txt") || die "could not open '25.db' $!";
> open(FH51, ">./join/REC_HEAD.txt") || die "could not open '25.db' $!";
Why do your error messages seem as if they're written for different file
names than you're actually using? Why do you open FH51 for output since
your code never uses it?
> while ($line=<FH25>) {
> chomp;
> $line =~ m,^\|REC FILE(\|[^|]+)\|,;
> $prefix = $1 if $1;
> if ($line =~ /REC BATCH/) {
> $line = $prefix . $line;
>
> @record = split(/\|/, $line);
> $field = "|$record[4] $thetime";
>
> while (<FH25>){
Although Perl will let you indent however you'd like, it greatly helps
readability to indent your code neatly. Your indentation doesn't make it
clear, but it looks to me as if you're reading from the same filehandle in
an inner loop as you are in the outer loop. That's probably not what you
want.
Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 20 Oct 1998 22:13:12 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <362D086F.9C3ED492@bbnplanet.com>
John Porter wrote:
> Right, according to U.S. law. Is there an international law that
> covers this? And are the French signatory to it? Bet not.
To quote a friend of mine who may have stolen this from somewhere else
"The French copy noone. Then, again, No one copies the French." Renault!
Need we say more? :)
Some interesting links for the scotchies.
http://fujipub.com/scotchmalt/
http://fujipub.com/scotchmalt/smws_women.html
The society is going to have their tasting at the Ritz in Boston on the
27th (next week). Any Bostonians care to join moi? Jackets are required
for the men and I may even have to wear a dress.
e.
After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia. - U. Eco -
------------------------------
Date: Tue, 20 Oct 1998 22:44:26 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Request for Perl script that emulate Remote Shell
Message-Id: <Pine.GSO.4.02A.9810201543180.5534-100000@user2.teleport.com>
On Tue, 20 Oct 1998, Tamir Hagit wrote:
> I need help in writing a script that will connect to a non UNIX
> machines and do something that look like remote shell, which means
> that the program should do telnet to any other machine, ask something,
> get an answer, print it and exit.
>
> Any ideas....???
Yes, you should probably study the security issues involved. Studying the
source for rsh and rshd would be a good start. There are some modules
on CPAN which may help with the implementation. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 20 Oct 1998 23:35:15 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Searching for long lines in a huge text file.
Message-Id: <T69X1.13$Fh4.128293@nsw.nnrp.telstra.net>
Another reply to this.
While I am certainly not an authority on this subject, and there are
people visiting this group who know a lot more about this than I do, I
have been faced with this problem often enough to have spent some
thought on it.
One mistake many people make when thinking about the recognition of
sentences and words is that they underestimate the human brain. People
think that there must be a few simple algorithmic rules that the brain
uses to perform the quite dazzling task of making sense of some text.
This is not the case. Processing of text, and making sense of it,
requires at least pattern recognition, a large dictionary, and an
understanding of grammar. Tie these together with a bunch of horribly
complex rules, and you've got it. If you don't need to understand
everything, but just want to recognise sentences and words, you are
still faced with quite a big task. First you have to define to your
program what a word is, what a sentence is. You'll have to write some
pattern recognition stuff for that.
Simplistic forms of that could be:
A word is any string of non-whitespace characters
A sentence is any string, terminated by a full stop (period, dot),
followed by whitespace
Instead of words, however, you might want to look for tokens. A token
could be a word, or a phone number, or a date. Phone numbers and dates
may contain whitespace, so you'll have to accommodate for that. Names
pose yet another problem. Do you want to treat each part of a name as
a token, or is the whole name a token. But I digress.
Then you have to deal with exceptions to the 'sentence' rule. What
happens if you have an abbreviation in the middle of a sentence, which
commonly ends in a dot? You'll have to keep a dictionary of all
abbreviations you might encounter, and check for those. Even a
dictionary will not be sufficient here, because you might have strings
like 'Dr. F. Bar' in your text.
You can try to make sense of the grammar of a sentence to determine
where the sentence ends. This last thing is what the brain does,
seemingly without effort. The brain understands grammar. Grammar is
very hard to program.
Of course, if your text rigorously adheres to a certain format your
job gets a lot easier, e.g. all sentences are terminated by a
newline and newlines do not occur anywhere else, or the typist uses
the old convention of ending every sentence with a dot followed by at
least two whitespace characters (spaces or newlines). But normally,
that's just not the case.
It's a very hard thing to do. With simple pattern recognition, and a
dictionary, you can probably reach a certain success rate. But it will
never be 100%.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In the fight between you and the world,
Commercial Dynamics Pty. Ltd. | back the world - Franz Kafka
NSW, Australia |
------------------------------
Date: Tue, 20 Oct 1998 23:14:33 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: sequential count
Message-Id: <Pine.GSO.4.02A.9810201614160.5534-100000@user2.teleport.com>
On Tue, 20 Oct 1998, Marcus J. Foody wrote:
> I'm struggling with a count routine. What I need is a sequential count
> of the lines within a receivable.
How far have you gotten?
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 20 Oct 1998 22:32:01 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Show files for download
Message-Id: <Pine.GSO.4.02A.9810201531240.5534-100000@user2.teleport.com>
On 19 Oct 1998, Joop van der Linden wrote:
> I want to make a script. The script has to read all the file-names in
> the "download/" directory. In the "download/" directory are files with
> a total of 2 per type. For example, Version10.zip, Verzion10.txt. I
> want the ".Zip" files to be downloadable and the ".Txt" files to be
> vissible.Is it simple to make such a script and can you give me some
> guidelines??
I'd recommend that you write it in Perl. If you haven't learned Perl yet,
you should use the Llama book, Learning Perl. Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 20 Oct 1998 16:25:37 -0700
From: "Konganda Belliappa" <konganda@corp.earthlink.net>
Subject: Socket Listner
Message-Id: <70j68l$gao$1@birch.prod.itd.earthlink.net>
Hi there,
Is there anybody who give me programming information on "socket listeners"
or be able to direct me in writing code to perform the operation of a
"socket listner". Please send email to belli@hotmail.com. Any information
would be greatly appreciated.
Thank you.
Bell
------------------------------
Date: 20 Oct 1998 23:40:54 GMT
From: Dpk <dpk@brainiac.egr.msu.edu>
Subject: test
Message-Id: <70j726$1b4$1@msunews.cl.msu.edu>
--
--
Dennis Kelly <dpk@egr.msu.edu>
Network Administrator
College of Engineering, MSU
------------------------------
Date: Tue, 20 Oct 1998 15:16:35 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Typing something without seeing with perl / Win NT
Message-Id: <MPG.1096ab9b8ad2fd9098982b@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <70iv23$6o9$1@jaydee.iway.fr> on Tue, 20 Oct 1998 23:25:25
+0200, Famille JACQUES <famillejacques@oceanet.fr> says...
> I want the user to type something (here, a
> password), without seeing it (just stars
> instead (*), for example).
perlfaq8: "How do I ask the user for a password?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 20 Oct 1998 17:41:02 -0500
From: Tom Turton <tturton@cowboys.anet-dfw.com>
Subject: Where's the mailin "guru" certificate?
Message-Id: <362D117D.E6D50E69@cowboys.anet-dfw.com>
Hey, finally broke down (well, my company made me an offer I couldn't
refuse!) and bought "Programming Perl", "Perl Cookbook", "Advanced Perl
Programming", and even "Mastering Regular Expressions". Now, assuming
I work my way through all these wonderful references, howzcome there
isn't a mail-in card in the back of the books to get a Genuwine Perl
Guru certificate?
---Tom (I'll be happy if I can just figure out what some of Abigail's
one-liners do!) Turton
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4027
**************************************