[6397] in Perl-Users-Digest
Perl-Users Digest, Issue: 22 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 27 06:07:26 1997
Date: Thu, 27 Feb 97 03:00:23 -0800
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, 27 Feb 1997 Volume: 8 Number: 22
Today's topics:
27 min. while () buffering of who (D. Black)
Avoiding trashing a file with flock (Mark Thompson)
Re: CGI SCRIPTS!! (Jonathan Peterson)
Re: Class library to make C++ more Perlish? (Donald H. Locker)
Re: Counting lines of Perl code (Michael Fuhr)
Re: File Locking <tchrist@mox.perl.com>
Re: Filehandle: open(FILE) while{} close(FILE) (Jonathan Peterson)
How can I pass parameters fps@fps.com.br
Re: how long before I can put down the books? <Dave@xenware.demon.co.uk>
Re: How to spam - legitimately (Michael Shields)
Re: How to spam - legitimately (Brad Knowles)
Learning Perl!!!! (Claes Gustafsson)
Mail Attachments <wvolz@atwill.com>
max string size. (Mohammed Dewan)
Re: Multi-line processing <tchrist@mox.perl.com>
Re: new win32::ODBC("DSN") <sip00@vg.swissptt.ch>
Re: new win32::ODBC("DSN") <sip00@vg.swissptt.ch>
Re: new win32::ODBC("DSN") <d.j.evans@rdg.ac.uk>
Re: PERL FOR WINDOWS (Markus Laker)
Re: Perl on Windows 95 (Hans Schrader)
Perl script for displaying last update date on a site? (John H. Ghadimi)
Re: Perl Script for DNS? (Michael Fuhr)
Re: PERL/NT development environment/guru setup out ther (Scott McMahan - Softbase Systems)
Re: Problems reading file using <> operator <billc@tibinc.com>
Re: Record Length (Aaron Remick)
Re: sometimes > not greater than? <sadd@msc.cornell.edu>
Re: sometimes > not greater than? (Tad McClellan)
Re: Sorting in perl <dehon_olivier@jpmorgan.com>
Testing file existence via rsh & Perl <harry@infoseek.com>
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Feb 1997 22:39:38 -0800
From: alecto@arlington.pe.net (D. Black)
Subject: 27 min. while () buffering of who
Message-Id: <5f3a7a$hh7@arlington.pe.net>
#! /usr/bin/perl
open (LOG,">> file") or die "cannot append: $!";
while () {
print LOG grep /foo|bar/ && /grue/, `who` ;
sleep 10;
}
the above runs wildly different in diff environs...
on a 486 Linux 1.1.59 box w/ two users doing next to nothing
it created file, waited over a minute with the file empty
THEN wrote to file... why not every ten seconds?
on a SunOS 5.4 sun4m sparc with ~100 users, ~96 of which were
running slirp, it did not write to the file until 27 minutes
had passed!!! I can force it to write every ten seconds
by moving the open within the while loop & closing the
file after the print, but opening and closing the file
every ten seconds seems not much more "correct" than
waiting 27 minutes . . .
what -exactly- is the factor than is regulating the time
between writes to the file? ($| to nonzero didn't help)
------------------------------
Date: Thu, 27 Feb 1997 09:51:52 GMT
From: mwt@cyberg8t.com (Mark Thompson)
Subject: Avoiding trashing a file with flock
Message-Id: <3315575b.9684038@news.alt.net>
Hi,
I'm writing a program which changes a password by copying the contents
of a password file out to a temporary file. The name of the temporary
file is always the same.
I ran the following test program to see how open and flock interelate
and I'm wondering if I'm missing a trick or something:
open(MBOX, ">passwd.tmp");
<STDIN>;
flock(MBOX, 2);
seek(MBOX,0,2);
print MBOX "Test";
flock(MBOX, 8);
If you notice, the open will trash testoutput before flock gets to
determine whether everything's all right. Another catch is that the
way the program is written, there's no way to know whether passwd.tmp
actually exists beforehand.
Anyone have any suggestions?
Thanks,
Mark Thompson
------------------------------
Date: 27 Feb 1997 09:39:33 GMT
From: jon@amxdigital.com (Jonathan Peterson)
Subject: Re: CGI SCRIPTS!!
Message-Id: <jon-2702970936120001@amx11.amxdigital.com>
In article <Pine.OSF.3.91.970208141217.25408A-100000@leofric>, Mr Matty
<hayes@coventry.ac.uk> wrote:
> I have acces to a web server, and limited access to a CGI-bin dir
> however, i cant save them as group www ( which is so that they can be
> executed) Is there any way i can get my perl scripts to execute rather
> then just displaying them, without putting them into the cgi-bin directory.
> I have a copy of X-netscape, so i can open them locally, but thats all.
> Anyone got any ideas??
If you can do:
> chmod o+x myfile.cgi
then it will be executable by all, so the group that owns it won't be
important in this respect.
Generally, web servers are set up to only execute scripts within the
cgi-bin directory tree. It is possible that yours is set up differently,
perhaps to execute any script anywhere that ends .cgi or that has the
execute bit set. IF this is the case you may be ok. Try it and see.
------------------
Opinions expressed above are not necessarily those of AMXdigital ltd.
Jonathan Peterson || jon@amxdigital.com || (+44) 0171 613 5300
"You wouldn't believe the things I've seen with your eyes."
------------------------------
Date: Thu, 27 Feb 1997 02:39:58 GMT
From: dhl@mrdog.msl.com (Donald H. Locker)
Subject: Re: Class library to make C++ more Perlish?
Message-Id: <E68q2n.785@mrdog.msl.com>
In article <01bc2110$e22e9bf0$0ef03a9e@transmogrifier>,
Charlton Barreto <charltoN@illustra.com> wrote:
>At 02:19 PM 2/20/97 +0100, you wrote:
>>Come on. The only feature that require OS support is the globbing like
>><*.c>. That's all. All the regex features are built-in.
>
>No. Not all. And NONE of the sed/awk functionality is built in. ROTFL,
>as you so cheerfully say....
If you picked yourself up off the F and stopped R'ing and L'ing, you
might learn something. Unfortunately, I have not yet seen the full
thread, so I can't respond to the original issue. However, I feel the
need to respond to some of the erroneous content in this post.
>>ROTFL. And what do you supposed your library routines in C/C++ ? When you
>>do I/O for example ? They called read(2)/write(2)/lseek(2). Wait, there
>are
>>system calls, aren't they ?
>>
>>Please don't try to confuse the issue.
>
>Seems like you need to attain a better understanding of C/C++ and 3GLs in
>general. C/C++ library routines are NOT (nor do they use) system calls.
Ummm. Yes they do use system calls. (Unless perhaps your "system" is
built by Microsloth, in which case I think they use BIOS calls, since
there is no system to call :)
>> PS: please cut down your sig . to 4 lines, no one care about Geek code or
>> such or fancy boxes. Thanks,
What he said. Get a clue, even if you have to take out a loan; you
desperately need it.
Ob perl. Perl may not be a 3-GL, nor is it really 4-GL; perhaps its a
pi-GL, which might be converted (vi Nathan P's PlPerl module) into a
piGL (onouncedpray "iggle-pay".) But now I'm getting into irrational
territory.
--
Donald.
These opinions were formulated by a trained professional.
DO NOT TRY THIS AT HOME!
At the time, the tone will be ... BEEP!
------------------------------
Date: 26 Feb 1997 19:49:21 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Counting lines of Perl code
Message-Id: <5f2snh$859@nova.dimensional.com>
lab@slpabu.msd.ray.com (Leonhard Brenner {13031} 7149 [ ]) writes:
>Has someone written a utility to count the lines of code
>in a perl script. It should deal with for loops (3 ;).
>Multiple code lines per line. And other goodies.
>Yes I know this is a stupid metric but, WCID?
% wc -l foo
What's a line of code? Isn't this one line?
my($a, $b, $c) = @_;
What about this code that does the same thing - isn't it three lines?
my $a = shift;
my $b = shift;
my $c = shift;
Do comments count? If not, why not? I had to type them, didn't I?.
They have to be maintained just the same as "real code", don't they?
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: 27 Feb 1997 09:17:30 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: File Locking
Message-Id: <5f3jfa$jha$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
jhoglund@skypoint.com (Jamie Hoglund) writes:
: open(FILE,"+>filename");
BUG BUG BUG: Your open mode is wrong. You need +< instead.
: flock(FILE,2);
: $count=<FILE>;
: chop $count;
: ++$count;
: seek(FILE,0,0);
: print FILE,"$counter\n";
BUG: No comma after FILE.
: flock(FILE,8);
: close(FILE);
BUG BUG BUG: You unlocked the file before your data made
it to disk. Close the thing, or autoflush the handle.
--tom
--
Tom Christiansen tchrist@alumni.cs.colorado.edu
"If Christianity were to disappear, in time, even the
churches would suffer." --Jonathan Swift
------------------------------
Date: 27 Feb 1997 09:57:12 GMT
From: jon@amxdigital.com (Jonathan Peterson)
Subject: Re: Filehandle: open(FILE) while{} close(FILE)
Message-Id: <jon-2702970953490001@amx11.amxdigital.com>
In article <kenlee.854753929@congo>, kenlee@congo.morgan.com (Kenneth W.
Lee) wrote:
> Hi all,
> I'm having some difficulty with filehandles. I've consulted
The filehandles are fine. It's the bit afterwards that's the trouble :)
CUT
> open ( INFILE, "<$infile" ) or die "Cannot open $infile:$!\n";
> open ( OUTFILE, ">>$infile" ) or die "Cannot create $outfile:$!\n";
>
> $line = <INFILE>;
> while ( $line )
> {
> s/FOO/BAR/; # any kind of parser here
> print $line;
> print OUTFILE $line;
> }
>
> This problematically runs an endless loop when I'd like
> it terminated upon the last line of <INFILE>. Is there
> something I've missed?
The $line = <INFILE>; will slurp the whole file into one scalar.
Then, the while ( $line ) will be always true, unless something in the
ensuing block sets $line to "" or 0. Thus the block executes endlessly (
unless you did s/.*|\n//g as your parser (ie substitute everything with
nothing))
What you _probably_ want is:
while (<INFILE>){ stuff }
This is a neat way of iterating over a file, one line at a time. At each
iteration the variable $_ will be set to the next line of the file.
------------------
Opinions expressed above are not necessarily those of AMXdigital ltd.
Jonathan Peterson || jon@amxdigital.com || (+44) 0171 613 5300
"You wouldn't believe the things I've seen with your eyes."
------------------------------
Date: 26 Feb 1997 15:08:14 -0800
From: fps@fps.com.br
Subject: How can I pass parameters
Message-Id: <5f2fou$jef@lana.zippo.com>
I'm programming a little perl aplication using perl.
1. I receive a username and a password in a html form,
2. then this form call a perl program that validates it.
3 This same program generates anoher html form with six
options (six perl modules).
4. If the user choose one I need to call this one
and pass the username (parameter).
I think the "system" command could do this but i can't pass the
parameter.
If you can help me thanks.
You can send me by email
------------------------------
Date: Thu, 27 Feb 1997 00:58:37 +0000
From: Dave Wheeler <Dave@xenware.demon.co.uk>
Subject: Re: how long before I can put down the books?
Message-Id: <4LqvJDA9wNFzEwKR@xenware.demon.co.uk>
In article <5es4ii$flh@news.interpath.net>, Scott McMahan - Softbase
Systems <softbase@mercury.interpath.com> writes
>Richard Morin (qnc496@joanrich.kite.ml.org) wrote:
>: Hi folks, Sorry for the non-specific question, but I'm kinda
>: curious about something. How long before most folks felt even
>: slightly proficient and could take the llama and camel books
>: off the desk beside them?
>
>We'll let you know if it ever happens.
>
>I use C, Java, JavaScript, perl, several shell languages, and Delphi.
>Now, I'm having to relearn C++. It's almost impossible not to have to
>re-learn any individual language every time you sit down to use it.
>
>Scott
>
Wow, phew, thingy and wotsit, (attorneys at law) - I thought it was just
me!!!!
--
************************************************************************
* Dave Wheeler <Dave@xenware.demon.co.uk> ; Voice/Fax 0181-501 1215 *
************************************************************************
------------------------------
Date: 27 Feb 1997 04:54:19 -0000
From: shields@crosslink.net (Michael Shields)
Subject: Re: How to spam - legitimately
Message-Id: <5f341r$jhh@daedalus.crosslink.net>
In article <5esrht$77t@nntp1.u.washington.edu>,
William R. Somsky <somsky@dirac.phys.washington.edu> wrote:
> Hmm... "email" as what I'd call a "substansive" noun I've heard:
> "I got _some_ email". It's like "The postman delivered some mail"
> or "I drank some water".
>
> But "email" as what I'd call an "objective" noun I haven't heard:
> "I got _an_ email". That'd be like "The postman delivered a mail"
> or "I drank a water".
I ate some cake. I ate a cake.
--
Shields, CrossLink.
------------------------------
Date: Thu, 27 Feb 1997 01:45:44 -0500
From: brad@his.com (Brad Knowles)
Subject: Re: How to spam - legitimately
Message-Id: <brad-2702970145440001@news.his.com>
In article <5f2o7r$9hi$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com
(Tom Christiansen) wrote:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
> Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> writes:
> :Although 'send me an email' doesn't sound that bad,
>
> It does to me. It doesn't sound like a native speaker.
> Everyone I know would just say "send me email" in that case.
I submit that, in this one specific case, this may be a "vee-eye" vs.
"vye" problem -- What is in common use amongst one set of "native"
speakers does not coincide with what is in use amongst another set.
I have personally seen, heard, and used both forms.
However, I will note the subtle distinction that comes to my mind --
when I say "send me an email", I typically am referring to a particular
problem that needs to be detailed in a single message, and I'll deal with
it (a form of singular usage).
When I say "send me email", I typically mean one or more messages, and
am generally referring to a topic that is likely to be in a state of
continuing conversation for some time (a form of plural usage).
--
Brad Knowles, MIME/PGP: brad@his.com
comp.mail.sendmail FAQ Maintainer <http://www.his.com/~brad/>
finger brad@his.com for my PGP Public Keys and Geek Code
The comp.mail.sendmail FAQ is at <http://www.his.com/~brad/sendmail/>
------------------------------
Date: Thu, 27 Feb 97 01:44:52 GMT
From: hakan.gustafsson@varberg.mail.telia.com (Claes Gustafsson)
Subject: Learning Perl!!!!
Message-Id: <5f2hv2$ef@d2o7.telia.com>
Keywords: tutorial,perl
Hi!
I would like to learn programming in Perl to make a CGI-script for my
homepage.
I can't find any good tutorials or courses on the World Wide Web.
Now I wonder if anyone can send me a zipped tutorial or an address to a site
on the Web.
Thanks!
------------------------------
Date: 27 Feb 1997 03:05:50 GMT
From: "Bill Volz" <wvolz@atwill.com>
Subject: Mail Attachments
Message-Id: <01bc245b$7d7f9b70$87aa2399@server>
Is it possible to send binary attachments using perl and sendmail?
------------------------------
Date: 27 Feb 1997 09:42:20 GMT
From: s798284@aix2.uottawa.ca (Mohammed Dewan)
Subject: max string size.
Message-Id: <5f3kts$n3k@mercury.cc.uottawa.ca>
hi,
i was trying to copy a whole file into a
string . The file size is only 200k . But i could
not do it . To my understanding perl runs in
protected mode . So Any string variable could
be as long as my total memory size. But it doesn't
seem to work that way . Could any one explain why .My
code is
open (File,"<"."test.txt")
while (<File>)
{
$store=$store.$_;
}
it just freez after some time .
Dewan
------------------------------
Date: 27 Feb 1997 09:11:28 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Multi-line processing
Message-Id: <5f3j41$ja3$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
wittig@omega.gmd.de (Georg Wittig) writes:
:Tom Christiansen <tchrist@mox.perl.com> writes:
: printf ("/* abc %s\n", mystring); /* some comment */
:will be translated to
: printf ("
What a shame. I can come up with other confusing tricks as well.
This is a very rare case, however. Trying to use regular expression
instead of yacc will always run this risk.
--tom
--
Tom Christiansen tchrist@alumni.cs.colorado.edu
#define SIGILL 6 /* blech */
--Larry Wall in perl.c from the 4.0 perl source code
------------------------------
Date: Thu, 27 Feb 1997 07:27:00 +0100
From: Philippe Simonet <sip00@vg.swissptt.ch>
Subject: Re: new win32::ODBC("DSN")
Message-Id: <33152934.275@vg.swissptt.ch>
Excuse me, found FAQ at http://www.roth.net/odbc/odbcfaq.htm.
Regards Philippe
------------------------------
Date: Thu, 27 Feb 1997 07:24:15 +0100
From: Philippe Simonet <sip00@vg.swissptt.ch>
Subject: Re: new win32::ODBC("DSN")
Message-Id: <3315288F.5528@vg.swissptt.ch>
Roth Consulting wrote:
>
> You need to read the docs! Or the FAQ.
> When this happens use the following line:
> print Win32::ODBC::Error() . "\n";
> dave
Where can I find these FAQ ?
Regards Philippe
------------------------------
Date: Thu, 27 Feb 1997 07:41:33 +0000
From: "David J. Evans" <d.j.evans@rdg.ac.uk>
Subject: Re: new win32::ODBC("DSN")
Message-Id: <33153AAD.4134@rdg.ac.uk>
Philippe Simonet wrote:
>
> Roth Consulting wrote:
> >
> > You need to read the docs! Or the FAQ.
> > When this happens use the following line:
> > print Win32::ODBC::Error() . "\n";
> > dave
> Where can I find these FAQ ?
>
> Regards Philippe
http://www.roth.net/users/rothd/perl/odbc.html
should get you started.
David
http://tigger.rdg.ac.uk
------------------------------
Date: Thu, 27 Feb 1997 08:33:51 GMT
From: mlaker@contax.co.uk (Markus Laker)
Subject: Re: PERL FOR WINDOWS
Message-Id: <5f3gvp$m5n$1@newsserver.dircon.co.uk>
help <college@tbaytel.net> wrote:
> What is the perl for Windows newsgroup,
There isn't one, unfortunately. Use this one.
> and has perl
> been ported to Windows NT 4.0 yet?
Yes. Look at Activeware's site; unfortunately my ISP's down at the
moment, so I can't look up the URL for you. You can get there more
circuitously, but taking in a lot of excellent information along the
way, from the excellent <http://www.perl.com>
Markus Laker.
[Mailed and posted.]
Markus Laker
------------------------------
Date: Thu, 27 Feb 97 07:56:00 GMT
From: hans.schrader@geol.uib.no (Hans Schrader)
Subject: Re: Perl on Windows 95
Message-Id: <5f3fa9$2au$2@toralf.uib.no>
In article <33137aee.33198280@news.gamewood.net>, wilsonpm@gamewood.net (Pete M. Wilson) wrote:
Go with a server that has great documentation and has been proven to run
perl 5.001 scripts!
--->O Reilly's WebSite or WebSite Pro- they have a very liberal try me
before buy period!
>Microsoft has the free PWS (Personal Web Server) for Win95 on their
>site. I don't know if it supports scripting.
>
>Peter Holtan <puzzled@cris.com> wrote:
>
>>Hank,
>>
>>I have the same question as Mark did. Please excuse me if my question
>>sounds stupid, but I am very new to this. Where can I get a server? Is
>>there a good one that you would suggest that I could download for free?
>>I hope I could get a server for Windows95, I have LINUX but I have too
>>many problems with it and X runs so damn slow.
>>
>>Thank you,
>>Peter Holtan
>>puzzled@cris.com
>>
>>
>>Hank LeMieux wrote:
>>>
>>> Mark,
>>>
>>> You wrote,
>>> > I would like to also see how it works by loading the page into Netscape
>>> > locally and then running the script (like it would on a server). Is
>>> > this possible. When I tried clicking on the button that calls the
>>> > script nothing happened.
>>>
>>> Well, here are two options:
>>>
>>> 1)Use Netscape's File|Open command to directly open the script. When
>>> netscape says it doesn't know what to do with the file, tell it to open
>>> it with the script interpreter (ie: if you're using perl, tell it to use
>>> perl.exe as the helper.) All this will do is have Netscape open the perl
>>> command window and run the script every time you open a .pl file. This
>>> won't emulate what the script will do on the server.
>>>
>>> 2) Install a server on your machine and run it locally. That's how I
>>> test my scripts.
>>>
>>> Hank
>>> --
>>>
>>> Hank LeMieux
>>> Freelance Web Design/JavaScript/CGI
>>> Santa Fe, NM, USA
>>> (505) 986-8166
>>> http://members.aol.com/HankW
>
>
Hans Schrader-Eureka's SySop:
"nglhs@alf.uib.no"--"http://hjs.geol.uib.no/"
------------------------------
Date: 27 Feb 1997 07:48:47 GMT
From: synfony@netbox.com (John H. Ghadimi)
Subject: Perl script for displaying last update date on a site?
Message-Id: <synfony-2602972350050001@slip129-37-242-214.ca.us.ibm.net>
Hi;
I'm looking for a shareware/freeware script that performs the following task:
I need to be able to poll all the files on a web site and determine the
most recent revision/creation date. Then I need to have that date be
displayed on the bottom of the main page. The ouput will be in the format
of "This site was last revised on <the polled date>". I was able to come
across a javascript command that did that, however it only polled the date
of the page that the script appeared on and not the whole site. Any
information or help would be greatly appreciated.
Thanks;
John G.
------------------------------
Date: 26 Feb 1997 19:50:53 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Perl Script for DNS?
Message-Id: <5f2sqd$88f@nova.dimensional.com>
wegscd@whirlpool.com (Doug Wegscheid) writes:
>my DNS guy just handed me a CGI script called WebDNS (written in Perl
>4) that will let you maintain the databases from a WWW browser. It's
>from MIT, I can't find any more information on it.
http://webdns.lcs.mit.edu/cgi-bin/webdns/
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: 23 Feb 1997 22:59:15 GMT
From: softbase@mercury.interpath.com (Scott McMahan - Softbase Systems)
Subject: Re: PERL/NT development environment/guru setup out there ?
Message-Id: <5eqi43$epm@news.interpath.net>
Gary (gniemcew@dti.net) wrote:
: It's probably a "dream on!" type of question, but here it goes anyway:
: is there an integrated development environment for PERL/NT4/Win95 ? I
: am thinking a nice (color coding) editor in one window, interpreter
: stdout in another, and still a script's output in yet another ? PERL
: debugger with variable trace ?
Emacs 19.34.1 for Windows 95/NT will do all that. Well, it'll at
least run the program in one window, and show you the source (with
syntax highlighting) in the other I don't know about splitting the
stdout and stderr and all to different windows. You'd have to
write some elisp code to pull that off.
: And yes, I want that voice recognition thing too ! :-)
You can write it in elisp.
Scott
------------------------------
Date: Thu, 27 Feb 1997 00:02:43 -0500
From: Bill Cowan <billc@tibinc.com>
To: Daniel Rasmussen <danr@hpwadjn.wal.hp.com>
Subject: Re: Problems reading file using <> operator
Message-Id: <33151573.2A68@tibinc.com>
Daniel Rasmussen wrote:
>
> Hi,
>
> I have a perl module that reads from a file using the <> operator.
> The exact code is as follows:
>
> open(PFILE, $pFile);
Suggestion:
Since you are not checking the status/result for your open(), try this:
open(PFILE, $pFile)
|| print STDERR "Can not open file handle: $pFile\n\t$!";
which would display any error message regarding the file open and help
to identify the problem.
> while (<PFILE>)
> {
> if (/coc/)
> {
> ($par, $cocInd) = /(\".*\")(.*)\)/;
> }
> }
> close(PFILE);
>
> This code works as expected when called from my test app but I have
> problems when its used by the app it was designed for. Specifically,
> it is reading more than one line at a time when used by the other
> app. It behaves more like read() in that it seems to be reading a
> specific number of byes rather than a line at a time.
>
> Is the <> operator somehow being toggled into a different mode?
> I can't find anything in my camel book about it.
>
> Any ideas?
>
> Perl version is 5.0.2. Please follow up to the news group or to both
> danr@an.hp.com and dras@sw.stratus.com.
>
> Thanks.
>
> Dan Rasmussen
> danr@an.hp.com
> dras@sw.stratus.com
-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com> Voice:919-490-0034 Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707
------------------------------
Date: 26 Feb 1997 17:28:21 GMT
From: remick@baygate.bayarea.net (Aaron Remick)
Subject: Re: Record Length
Message-Id: <5f1rrl$ffp@news.bayarea.net>
Keywords: Record Length Perl
In article <5epu7g$9jm$1@amberjack.netrunner.net>,
Henry Lifton <henlif@elsfl.com> wrote:
>It has been a year or so since I wrote a program in Perl. It was in Perl 4.
>At that time there was a limitation to the length of a record in a data base
>(I believe it was 1,000 bytes).
I'm guessing that when you say database, you mean dbm files. The limitation
was in the file format, not perl. Try grabing the newer libaries (I like
gdbm) and rebuilding perl. The 1k limit should go away.
--
aaron remick
remick@bayarea.net
http://www.bayarea.net/~remick
------------------------------
Date: Wed, 26 Feb 1997 22:21:31 -0500
From: Michael Sadd <sadd@msc.cornell.edu>
To: oshmis1@pacbell.net
Subject: Re: sometimes > not greater than?
Message-Id: <3314FDBB.10D8E967@msc.cornell.edu>
Nothing here surprised me. What you are seeing is that
your machine has finite precision to represent floating point numbers.
In some cases, what you think might be 5 will be represented as
5.000000...1, giving the false true values you noted.
It is a general rule of numerical programming that your results
should not be dependent on what a test does when a parameter
is supposed to be exactly some number.
Mike
--
| Michael Sadd | Cornell Univerisity |
| Department of Physics and | Ithaca, NY 14850 |
| Lab of Atomic and Solid State Physics | www.msc.cornell.edu/~sadd/ |
------------------------------
Date: Wed, 26 Feb 1997 23:08:30 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: sometimes > not greater than?
Message-Id: <es43f5.573.ln@localhost>
Marty McDowell (oshmis1@pacbell.net) wrote:
: We had a program going through timecard punches and found that
: sometimes 5 is not 5. How can I get the correct answer? Here
^^^^^^^^^^^^^^^^^^^^
I don't think so. Sometimes, however, 5.000000000000001 is not 5 ;-)
: is some samples (of course the real program had variables instead
: of hard coded numbers but it behaves the same)
: $f = 6 - 1;
: if ($f > 5) { print "$f yes\n"; } else { print "$f no\n"; }
: $f = 12 - 7;
: if ($f > 5) { print "$f yes\n"; } else { print "$f no\n"; }
: $f = 12.72 - 7.72;
: if ($f > 5) { print "$f yes\n"; } else { print "$f no\n"; }
: $f = 12.62 - 7.62;
: if ($f > 5) { print "$f yes\n"; } else { print "$f no\n"; }
: $f = 12.82 - 7.82;
: if ($f > 5) { print "$f yes\n"; } else { print "$f no\n"; }
: $f = 12.7 - 7.7;
: if ($f > 5) { print "$f yes\n"; } else { print "$f no\n"; }
: $f = 12.8 - 7.8;
: if ($f > 5) { print "$f yes\n"; } else { print "$f no\n"; }
: Produces the following:
: 5 no
: 5 no
: 5 yes
: 5 no
: 5 no
: 5 no
: 5 yes
: We're running 5.001m under SVR5.4 on an intel box (unisys).
Hmmmm. Let's try printing out more of the significant figures in
those floating point numbers:
----------------
$f = 6 - 1;
if ($f > 5) { printf "%20.15f yes\n", $f; }
else { printf "%20.15f no\n", $f; }
$f = 12 - 7;
if ($f > 5) { printf "%20.15f yes\n", $f; }
else { printf "%20.15f no\n", $f; }
$f = 12.72 - 7.72;
if ($f > 5) { printf "%20.15f yes\n", $f; }
else { printf "%20.15f no\n", $f; }
$f = 12.62 - 7.62;
if ($f > 5) { printf "%20.15f yes\n", $f; }
else { printf "%20.15f no\n", $f; }
$f = 12.82 - 7.82;
if ($f > 5) { printf "%20.15f yes\n", $f; }
else { printf "%20.15f no\n", $f; }
$f = 12.7 - 7.7;
if ($f > 5) { printf "%20.15f yes\n", $f; }
else { printf "%20.15f no\n", $f; }
$f = 12.8 - 7.8;
if ($f > 5) { printf "%20.15f yes\n", $f; }
else { printf "%20.15f no\n", $f; }
----------------
When I run _that_ I get:
5.000000000000000 no
5.000000000000000 no
5.000000000000001 yes
4.999999999999999 no
5.000000000000000 no
4.999999999999999 no
5.000000000000001 yes
Looks like it's doing the right thing to me...
That's how floating point numbers work on computers.
Can you coerce your numbers into integers instead of floats?
For example, can you multiply them all by 100 and use integer
arithmetic instead?
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 27 Feb 1997 10:09:34 +0100
From: Olivier Dehon <dehon_olivier@jpmorgan.com>
Subject: Re: Sorting in perl
Message-Id: <njzhgiyipip.fsf@jpmorgan.com>
Charlie Schofield <charlies@ctn.independent.co.za> writes:
>
> I have the following table of filenames, creation dates and retire dates
> which I create from a directory of articles.
>
> $table[$filecount] = {
> name => $file,
> date => $date,
> retiredate => $retiredate};
>
> then I want to be able to sort the articles by date or retiredate.
>
> I have tried
>
> @sorted = sort {$a.date cmp $b.date} @table;
>
>
>
> but this does not work. The dates are held as strings. I am able to
> sort by the name but not by the date or retiredate. Basically I want to
> know how to send the date field to the sort function.
I did not test it but
@sorted = sort {$a->{date} cmp $b->{date}} @table;
should work.
Or maybe I should re-read my Camel book !!!
Regards,
Olivier
------------------------------
Date: Thu, 20 Feb 1997 14:41:15 -0800
From: Harry Slaughter <harry@infoseek.com>
Subject: Testing file existence via rsh & Perl
Message-Id: <330CD30B.725B@infoseek.com>
I've been working on this all day and can't figure it out for the life
of me.
I want to do something like the following:
foreach $host (@hosts) {
## rsh $host test -f /path/to/file
if (#file exists) {
#do this;
}elsif (#file does not exist) {
#do that;
}else{
print "you can't do anything right\n";
}
}
Best I can figure is to hack an ls return value or something equally as
lame, but I'd rather do something cleaner. I hate "rsh".
Thanks
======================================================
Harry Slaughter harry@infoseek.com
Infoseek Corporation Voice: 408.567.2920
2620 Augustine Dr. #250 Fax: 408.986.1889
Santa Clara, CA 95054 http://www.infoseek.com
======================================================
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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.
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 22
************************************