[7703] in Perl-Users-Digest
Perl-Users Digest, Issue: 1329 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 17 11:27:14 1997
Date: Mon, 17 Nov 97 08: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 Mon, 17 Nov 1997 Volume: 8 Number: 1329
Today's topics:
Re: CGI PERL SCRIPT to TAR? <qdtcall@esb.ericsson.se>
CGI Script Output....help. <mgb@nbnet.nb.ca>
Re: exclusive file rights (Tad McClellan)
Re: exclusive file rights (Jeremy D. Zawodny)
Formprocessing on NT <massih@medea.se>
Re: Formprocessing on NT (Jeremy D. Zawodny)
Hiding HTML results in a perl program <vanucci@sp.dglnet.com.br>
Re: Hiding HTML results in a perl program <david.martin@biotek.uio.no>
Re: Hiding HTML results in a perl program (Jeremy D. Zawodny)
Re: is h2xs supposed to do this? (Des Herriott)
Re: launch, monitor and kill forked processes <jamesr@aethos.co.uk>
NT - access violation, 5.00402-bindist04-bc <quails@logica.com>
Re: odd difference between C and Perl (Gabor)
Re: odd difference between C and Perl <Alex_Krol@scitex.com>
Re: ora_open <zenin@best.com>
Re: perl bug? (Andrew M. Langmead)
Re: PERL for ALPHA/VMS (Clay Irving)
satan & perl surabaia@hotmail.com
sccs setup on solaris <mehta@mama.indstate.edu>
Re: Statistics for comp.lang.perl.misc (Andrew M. Langmead)
Re: Tk/Motif/Embedded Perl question lvirden@cas.org
Re: Trying to copy a file on winnt in perl... (Bob Wilkinson)
Winnt and Unix Communication <ljchern@singnet.com.sg>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 17 Nov 1997 14:19:49 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: CGI PERL SCRIPT to TAR?
Message-Id: <isaff33bey.fsf@godzilla.kiere.ericsson.se>
jaws@atl.mindspring.com (John Armsby) writes:
> My problem is How do I get the browser to select directories and then
> tar recursively down the tree, finally gzipping the resulting file? I
> don't see any nifty tools in the Perl tool box to enable directory
> selection for a subsequent tar.
My Archive::Tar module kan handle packing files into tar format, and
compressing it in gzip format if Compress::Zlib is available. It doesn't
recurse down directories by itself, since that is better done by File::Find.
Archive::Tar and Compress::Zlib can be found on CPAN, File::Find comes
with the standard distribution.
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: Sun, 16 Nov 1997 18:26:45 -0400
From: Michael Butler <mgb@nbnet.nb.ca>
Subject: CGI Script Output....help.
Message-Id: <346F7325.5CC43DC0@nbnet.nb.ca>
Hi, I'm new to CGI and Perl and need a little help. I've written a very
simple HTML document and Perl script. The HTML document consists of a
text box into which the user types some information. After pressing the
submit button the Perl script will simply print out some stuff to the
client. As you may have guessed I'm just trying to do something simple
to get the hang of things. Here'e the script:
#!/usr/bin/perl
print "Content-type: text/html/n/n";
$query_string = $ENV{'QUERY_STRING'};
print "<HTML>\n";
print "<HEAD><TITLE>Here it is</TITLE></HEAD>\n";
print "<BODY><H1> This is it!</H1>\n";
print "<BODY></HTML>";
As you can see this is a simple script but when I hit the submit button
on my browser I get a message box asking me what file to print to. If I
select a file then what I get is my CGI script printed exactly as above
into the file. It never seems to get returned to the browser.
Why don't I get a return document to my browser? If anyone can help I'd
appreciate it.
Thanks
Mike Butler
------------------------------
Date: Mon, 17 Nov 1997 08:10:40 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: exclusive file rights
Message-Id: <09jp46.ei.ln@localhost>
Jeremy D. Zawodny (jzawodn@wcnet.org) wrote:
: [original author automagically cc'd via e-mail]
: On Mon, 17 Nov 1997 01:20:02 GMT, syarbrou@ais.net (Steve) wrote:
: >from multiple writes and reads at once. How do you go about locking
: >access to the file so nothing else can access it while reading and
^^^^^^^^^^^^^^^^^^^^^^^^^^
Note that flock()ing does not ensure this.
It ensures that 'no cooperating programs' can access the file.
Even when locked, any (uncooperative) process can modify the file...
: >writing? The program does the following and I would like it locked
: >for the entire process(any other suggestions are welcom):
: This is covered in the Perl documentation. Search for the work 'lock'
: and you're bound to find it.
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 17 Nov 1997 14:51:41 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: exclusive file rights
Message-Id: <3471598a.317079446@igate.hst.moc.com>
[original author automagically cc'd via e-mail]
On Mon, 17 Nov 1997 08:10:40 -0600, tadmc@flash.net (Tad McClellan)
wrote:
>Jeremy D. Zawodny (jzawodn@wcnet.org) wrote:
>: [original author automagically cc'd via e-mail]
>
>: On Mon, 17 Nov 1997 01:20:02 GMT, syarbrou@ais.net (Steve) wrote:
>
>: >from multiple writes and reads at once. How do you go about locking
>: >access to the file so nothing else can access it while reading and
> ^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>Note that flock()ing does not ensure this.
>
>It ensures that 'no cooperating programs' can access the file.
>
>Even when locked, any (uncooperative) process can modify the file...
Correct. And the flock() documentation in Perl referrs to the flock()
Unix manpage. On one of my systems, that says:
---
DESCRIPTION
flock() applies or removes an advisory lock on the file
associated with the file descriptor fd. The compatibility
version of flock() has been implemented on top of fcntl(2)
locking. It does not provide complete binary compatibility.
Advisory locks allow cooperating processes to perform con-
sistent operations on files, but do not guarantee exclusive
access (that is, processes may still access files without
using advisory locks, possibly resulting in inconsisten-
cies).
---
Assuming that the poster follows my suggestion, that will become
clear.
However, it may be worth patching the docs to make this explicit in
the Perl documentation so that nobody gets a false sense of security.
Any takers?
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: Mon, 17 Nov 1997 14:54:51 +0100
From: Massih Enayatollah <massih@medea.se>
Subject: Formprocessing on NT
Message-Id: <34704CAA.13C62009@medea.se>
My problem:
I'm trying to set up formmail & windmail to handle my form processing,
but I've run in to some problem.
Problem: windmail.exe is not invoked from formmail.pl (I use NT4.0 &
IIS). How do I start a dos-window and start an .exe file in perl?
formmail.pl creates a tempfile (the contents of the form) correctly when
it's invoked from the web.
windmail.exe works correctly when invoked from the dos promter.
c:\winnt\windmail.exe -t -n d:\temp\tempfile > d:\temp\log.txt
Can anyone help me? If so, please send me an email ...
Thats it,
/Massih
formmail.pl
----------------
$mailprog = 'c:\\winnt\\windmail.exe';
$tempdir = 'd:\\temp';
$logfile = 'd:\\temp\\log.txt';
$IIS_MODE = 1;
# Parse Form Contents
&parse_form;
....
# Send E-Mail
&send_mail;
....
sub send_mail {
....
# Output a temporary file
open(MAIL,">$tempdir\\tempfile") || die("Cannot open
$tempdir\\tempfile -- Check Directory Permissions : $!");
... works ok! ....
close (MAIL);
.... Never done! ....
open(MAIL,"|$mailprog -t -n $tempdir\\tempfile > $logfile") ||
die("Cannot execute $mailprog -- Check mailprog path and permissions :
$!");
close(MAIL);
}
------------------------------
Date: Mon, 17 Nov 1997 14:31:57 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Formprocessing on NT
Message-Id: <347054c5.315858250@igate.hst.moc.com>
[original author automagically cc'd via e-mail]
On Mon, 17 Nov 1997 14:54:51 +0100, Massih Enayatollah
<massih@medea.se> wrote:
>My problem:
>
>I'm trying to set up formmail & windmail to handle my form processing,
>but I've run in to some problem.
I don't know what either of those are, but I'll see...
>Problem: windmail.exe is not invoked from formmail.pl (I use NT4.0 &
>IIS). How do I start a dos-window and start an .exe file in perl?
Well, you can use the system() call, or the backticks (`blah.exe`) and
probably even the exec() call.
>formmail.pl creates a tempfile (the contents of the form) correctly when
>
>it's invoked from the web.
>
>windmail.exe works correctly when invoked from the dos promter.
> c:\winnt\windmail.exe -t -n d:\temp\tempfile > d:\temp\log.txt
>
>
>Can anyone help me? If so, please send me an email ...
You included source code that contains some error checking, but you
didn't tell us which error message appears. It's hard to track this
down without knowing which line(s) of your code bombs.
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: Mon, 17 Nov 1997 11:41:20 -0200
From: "Fabiano Vanucci" <vanucci@sp.dglnet.com.br>
Subject: Hiding HTML results in a perl program
Message-Id: <879774241.996065@citroen>
I have to execute an CGI program that return an HTML page which I don't
want my users seeing that page (it has to be no RESULT back).
The problem is that the company that created (and hosted) that script says
that they can't change or customize their program in reason of custs.
I have to execute and manipulate the results inside my perl script.
Can it be done???
Fabiano Vanucci
------------------------------
Date: Mon, 17 Nov 1997 16:10:12 +0100
From: David Martin <david.martin@biotek.uio.no>
Subject: Re: Hiding HTML results in a perl program
Message-Id: <34705E54.F910D8CD@biotek.uio.no>
Fabiano Vanucci wrote:
> I have to execute an CGI program that return an HTML page which I don't
> want my users seeing that page (it has to be no RESULT back).
...
> Can it be done???
Return status 204 in the header. Try an HTML FAQ somewhere else for
correct header syntax.
..d
>
> Fabiano Vanucci
>
--
* David Martin - Atherosclerosis and Thrombosis research group *
* http://www.uio.no/~damartin/ david.martin@biotek.uio.no *
* Lab +47 22 95 84 54 Fax +47 22 69 41 30 GSM +47 90 74 27 65 *
------------------------------
Date: Mon, 17 Nov 1997 15:11:38 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Hiding HTML results in a perl program
Message-Id: <34705e70.318333679@igate.hst.moc.com>
[original author automagically cc'd via e-mail]
On Mon, 17 Nov 1997 16:10:12 +0100, David Martin
<david.martin@biotek.uio.no> wrote:
>Fabiano Vanucci wrote:
>
>> I have to execute an CGI program that return an HTML page which I don't
>> want my users seeing that page (it has to be no RESULT back).
>...
>> Can it be done???
>
>Return status 204 in the header. Try an HTML FAQ somewhere else for
>correct header syntax.
Or, better yet, the HTTP protocol spec. It contains the list of HTTP
response codes and headers as well as suggestion for when they should
or should not be used.
In any case, it's not a Perl question (as usual).
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: 17 Nov 1997 14:00:07 GMT
From: des@corp.netcom.net.uk (Des Herriott)
Subject: Re: is h2xs supposed to do this?
Message-Id: <64pil7$c1n$1@taliesin.netcom.net.uk>
In article <64i6n0$c5i$1@agate.berkeley.edu>,
ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> I repeated what you did with
> h2xs -x -n foo H:/get/perl/tmp/blah.h
> and got a correct result. 5.004_01 + jumbo-re-v1 + jumbo-malloc here,
> C::Scan is dated 9/26/97 (latest release by me).
Hmm, where I can get this latest version? The newest I could find on
CPAN is 0.4, which is dated Aug 25th 1997 (I notice now that that version
appears to have been released by JASONS). Should I be using 0.3?
Out of interest, I put together a cut-down demo:
use C::Scan;
$c = new C::Scan('filename' => "foo.h");
for $f (@{ $c->get('parsed_fdecls') }) {
print "function <$f->[1]> returns <$f->[0]>\n";
for $a (@{ $f->[2] }) {
print " arg <$a->[1]> is of type <$a->[0]>\n";
}
}
Given this in foo.h:
int do_foo(int x, int y);
I get this output:
function <do_foo> returns <int>
arg <arg0> is of type <int x>
arg <arg1> is of type <int y>
which ties in with the problem I originally reported.
Regards,
--
Des Herriott
des@corp.netcom.net.uk
------------------------------
Date: 17 Nov 1997 15:31:42 GMT
From: "James Richardson" <jamesr@aethos.co.uk>
Subject: Re: launch, monitor and kill forked processes
Message-Id: <01bcf36e$034f1dc0$26c0a4c1@kitkat.aethos.co.uk>
mathias@linux.ek79.uni-koeln.de wrote in article
<64mrp4$fn0@news.rrz.Uni-Koeln.DE>...
> Hi,
>
> I am trying to build a loop that
> starts a binary, waits a predefined
> amount of time, and then either kills
> the launched process if it is still
> running, or does something with its
> output if it has successfully completed.
>
OK, in order:
1) To launch a background process use 'fork and exec'
unless ($pid = fork) {
log_msg("Running daemon...");
exec $program_to_run;
log_msg("Couldn't start the daemon! ($program_to_run)\n",1);
}
log_msg ("Fork OK!");
#Uncomment the next line to wait for process to finish
#waitpid($pid,0);
}
2) To check if a program is running... I never really found a totally
satisfactory solution....
open (PS, "ps -e | grep $program_name|");
#Of course you can add -u username if you are using suitable UNIXware
@processes = <PS>;
$num_processes = @processes;
foreach $process (@processes) {
($blank,$pid, $tty, $time, $name) = split(/[ \t]+/, $process);
push (@pids,$pid);
}
The above is only an example, it WILL NOT WORK on all UNIX systems and is
not portable, cos ps puts things in different places all the time.... (but
if you are using POSIX you can specify the output format ;-) check the man
page)
3) Waiting
sleep? (man perlfunc)
4) Killing the process
kill normally does the job....
foreach $pid (@process_pids) {
#Kill returns the number of processes killed
$ok += kill "QUIT", $pid;
}
#OK should now equal the number of processes that we had to kill
if ($ok == $num_processes) {
1;
}
else {
log_msg ("Couldn't stop process!\n",1);
}
These examples wont go together and make a working program... but they
should demo how to do some stuff...
One thing that you may want to do is check whether or not you are running
in the foreground... cos you might want to have different behaviour for
your daemon program if you are.... This is from the perl faq (by Tom
Christiansen and Nathan Torkington) READ IT, IT IS VERY USEFUL! .. (Mind
you most other things here are in the man pages too..........)
sub im_in_the_foreground {
#Work out if i'm in the foreground or not....
open(TTY, "/dev/tty") ;#or die $!;
$tpgrp = tcgetpgrp(TTY);
$pgrp = getpgrp();
if ($tpgrp == $pgrp) {
1;
} else {
undef;
}
}
> Thank you in advance for your emailed
> answer.
>
Why do people always want personal replies? Thats not the point....(sigh)
James Richardson
------------------------------
Date: 17 Nov 1997 13:13:27 GMT
From: "Steve Quail" <quails@logica.com>
Subject: NT - access violation, 5.00402-bindist04-bc
Message-Id: <01bcf35a$95565300$6b02ea9e@UKP014312.logica.co.uk>
Any help *much* appreciated, I'm using Perl 5.00402 binary distribution,
including ODBC. The program ran fine during testing at base but falls over
on clients system with an access violation - typically after a few hours
(i.e. not entirely repeatable). The program is being started using AT.
Could this be faulty hardware or file access permissions ??
Application exception occurred:
App: (pid=154)
When: 11/14/1997 @ 18:50:48.625
Exception number: c0000005 (access violation)
*----> System Information <----*
Computer Name: XYZ12345
User Name: superadmin
Number of Processors: 2
Processor Type: x86 Family 6 Model 3 Stepping 3
Windows Version: 4.0
Current Build: 1381
Current Type: Multiprocessor Free
Registered Organization: Energis
Registered Owner: Energis User
*----> Task List <----*
0 Idle.exe
2 System.exe
25 smss.exe
33 csrss.exe
39 WINLOGON.exe
45 SERVICES.exe
48 LSASS.exe
71 SPOOLSS.exe
90 LLSSRV.exe
80 RPCSS.exe
112 inetinfo.exe
115 PSTORES.exe
156 NDDEAGNT.exe
162 EXPLORER.exe
155 LOADWC.exe
154 perl.exe
149 DRWTSN32.exe
0 _Total.exe
(00400000 - 00400000)
(77f60000 - 77fbc000) dll\ntdll.dbg
(00240000 - 00240000)
(77f00000 - 77f5e000) dll\kernel32.dbg
(77e70000 - 77ec4000) dll\user32.dbg
(77ed0000 - 77efc000) dll\gdi32.dbg
(77dc0000 - 77dfe000) dll\advapi32.dbg
(77e10000 - 77e62000) dll\rpcrt4.dbg
(002a0000 - 002a0000)
(00c80000 - 00c80000)
(04a50000 - 04a8c000) odbc32.DBG
(779f0000 - 77a36000) dll\msvcrt.dbg
(70db0000 - 70e23000) comctl32.dbg
(77c40000 - 77d7c000) dll\shell32.dbg
(77d80000 - 77db2000) dll\comdlg32.dbg
(77a90000 - 77a9b000) dll\version.dbg
(779c0000 - 779c8000) dll\lz32.dbg
(04ad0000 - 04aea000) odbccp32.DBG
(04a00000 - 04a00000)
(010b0000 - 010b0000)
(010c0000 - 010c0000)
(010d0000 - 010d0000)
(5f810000 - 5f817000) dll\rpcltc1.dbg
(10000000 - 10000000)
(5f000000 - 5f011000)
(010e0000 - 010e0000)
(01140000 - 01140000)
(01170000 - 01170000)
(011c0000 - 011c0000)
(01290000 - 01290000)
(012d0000 - 012d0000)
(01300000 - 01300000)
(776d0000 - 776d8000) dll\wsock32.dbg
(776b0000 - 776c2000) dll\ws2_32.dbg
(776a0000 - 776a6000) dll\ws2help.dbg
(01340000 - 01340000)
(77b20000 - 77bd2000) dll\ole32.dbg
(77fd0000 - 77ffa000) dll\winmm.dbg
(01360000 - 01360000)
(013b0000 - 013b0000)
(013c0000 - 013c0000)
(013d0000 - 013d0000)
(01400000 - 01400000)
(01600000 - 01600000)
(74ff0000 - 74ffc000) dll\rnr20.dbg
(77660000 - 7766e000) dll\msafd.dbg
(77690000 - 77699000) dll\wshtcpip.dbg
State Dump for Thread Id 0x4e
eax=00000000 ebx=00cdffff ecx=01784b78 edx=10029580 esi=01784ab0
edi=00000000
eip=1000854f esp=0012f5a4 ebp=00ca7fe0 iopl=0 nv up ei pl zr na po
nc
cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000
efl=00010246
function: <nosymbols>
1000853b 0a0a or cl,[edx]
ds:10029580=20
1000853d 09cc or esp,ecx
1000853f cc int 3
10008540 83ec04 sub esp,0x4
10008543 53 push ebx
10008544 56 push esi
10008545 8b742410 mov esi,[esp+0x10]
ss:0103dfab=????????
10008549 57 push edi
1000854a 33ff xor edi,edi
1000854c 8b4604 mov eax,[esi+0x4]
ds:026934b6=????????
FAULT ->1000854f 39b894000000 cmp [eax+0x94],edi
ds:00000094=????????
10008555 0f85d7000000 jne 10008632
1000855b 8b4610 mov eax,[esi+0x10]
ds:026934b6=????????
1000855e 85c0 test eax,eax
10008560 0f84cc000000 je 10008632
10008566 50 push eax
10008567 e8e4710000 call 1000f750
1000856c 83c404 add esp,0x4
1000856f 663d8400 cmp ax,0x84
10008573 0f85a6000000 jne 1000861f
10008579 8d44240c lea eax,[esp+0xc]
ss:0103dfab=????????
1000857d 57 push edi
*----> Stack Back Trace <----*
FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name
00ca7fe0 00cb0660 00000000 00000000 00000000 00000000 <nosymbols>
*----> Raw Stack Dump <----*
0012f5a4 00 00 ca 00 b0 4a 78 01 - ff ff cd 00 30 84 78 01
....Jx.....0.x.
0012f5b4 bd be 01 10 b0 4a 78 01 - 40 80 ca 00 30 84 78 01
....Jx.@...0.x.
0012f5c4 ff ff cd 00 f6 5d 00 10 - b0 4a 78 01 e0 7f ca 00
....]...Jx.....
0012f5d4 40 80 ca 00 64 7d ca 00 - 90 04 cd 00 72 b0 a6 04
@...d}......r...
0012f5e4 30 84 78 01 40 80 ca 00 - 24 f6 12 00 c0 1d 9b 00
0.x.@...$.......
0012f5f4 00 00 00 00 c0 1d 9b 00 - 00 09 cd 00 18 f6 12 00
...............
0012f604 50 09 cd 00 04 e8 27 00 - 8a ad a6 04 90 04 cd 00
P.....'.........
0012f614 c8 1d 9b 00 03 00 00 00 - c0 1d 9b 00 00 00 00 00
...............
0012f624 3c f6 12 00 5a 63 c8 00 - 90 04 cd 00 c8 1d 9b 00
<...Zc..........
0012f634 01 00 00 00 5c 8b 93 00 - d0 fe 12 00 d1 6c c8 00
...\........l..
0012f644 c0 1d 9b 00 c0 e4 30 00 - 00 00 00 00 ec f1 91 00
.....0.........
0012f654 d8 f6 12 00 b4 00 b6 00 - 00 ec fd 7f 00 00 00 00
...............
0012f664 00 00 00 00 00 00 02 00 - 1c c9 f3 77 1e 00 20 00 ...........w..
------------------------------
Date: 17 Nov 1997 14:30:36 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: odd difference between C and Perl
Message-Id: <slrn670kqt.sqr.gabor@vinyl.quickweb.com>
>>> I've written a routine to convert Islamic
>>> dates to Gregorian ones. For internal reasons,
>>> I've done a version in C and another in Perl.
>>>
>>> At one stage you have to multiply the Islamic
>>> year by 0.970224 and add 622.54.
>>>
>>> Given the Islamic year 1367
>>>
>>> the C code
>>>
>>> x = (Hy * 0.970224) + 622.540000;
>>>
>>> produces 1948.836182 (x is declared as a float)
>>>
>>> whereas the Perl code
>>>
>>> $x = ($Hy * 0.970224) + 622.540000;
>>>
>>>
>>> produces 1948.836208
>>>
>>> The second of these is confirmed by my HPCalculator.
>>> which at 9 decimal places gives 1948.836208000.
>>>
>>> I haven't yet discovered an input for which this
>>> makes a difference to the final result, but it may
>>> exist (you have to do further calculations with the
>>> fractional result, to calculate the month and day).
>>>
>>> But it would be interesting to know why the difference
>>> occurs.
Because you declared 'x' to be a float. Declare it as type double and
you'll get identical answers.
#include <stdio.h>
main()
{
double x;
int Hy = 1367;
x = Hy * 0.970224 + 622.540000;
print("%f\n",x);
}
perl -e 'print 1367 * 0.970224 + 622.54,"\n";'
gabor.
--
signal(i, SIG_DFL); /* crunch, crunch, crunch */
-- Larry Wall in doarg.c from the perl source code
mharris@gov.on.ca he, he, he
------------------------------
Date: Mon, 17 Nov 1997 16:48:38 -0800
From: Alex Krol <Alex_Krol@scitex.com>
Subject: Re: odd difference between C and Perl
Message-Id: <3470E5E6.6B10@scitex.com>
Olivier Dehon wrote:
>
> John Davis <jd@mukh.asc.ox.ac.uk> writes:
>
> > I've written a routine to convert Islamic
> > dates to Gregorian ones. For internal reasons,
> > I've done a version in C and another in Perl.
> >
> > At one stage you have to multiply the Islamic
> > year by 0.970224 and add 622.54.
> >
> > Given the Islamic year 1367
> >
> > the C code
> >
> > x = (Hy * 0.970224) + 622.540000;
> >
> > produces 1948.836182 (x is declared as a float)
> >
> > whereas the Perl code
> >
> > $x = ($Hy * 0.970224) + 622.540000;
> >
> >
> > produces 1948.836208
> >
> > The second of these is confirmed by my HPCalculator.
> > which at 9 decimal places gives 1948.836208000.
> >
> > I haven't yet discovered an input for which this
> > makes a difference to the final result, but it may
> > exist (you have to do further calculations with the
> > fractional result, to calculate the month and day).
> >
> > But it would be interesting to know why the difference
> > occurs.
>
> In C, 0.970224 and 622.540000 are of type float, whereas
> Perl treats them as doubles, hence the difference in
> precision.
>
> Try 0.970224L and 622.540000L to get constants of type
> double in C.
No, floating constants in C (and C++) are of type double,
unless explicitely specified by suffix (f and F for float,
l and L for long double).
Original poster's problem is that he is storing the
_result_ of his calculation in a variable of type float.
Regards,
Alex Krol
------------------------------
Date: 17 Nov 1997 13:33:52 GMT
From: Zenin <zenin@best.com>
Subject: Re: ora_open
Message-Id: <879773790.178396@thrush.omix.com>
Michael A. Chase <mchase@ix.netcom.com> wrote:
: Describe is a SQL*Plus command, not SQL. I'm not familiar with oraperl,
: but you can get the same information by querying the all_tables table.
Hmm, would you mind sharing the column name(s) in that table that
show this information? I can't seem to find anything that looks
like "row_name" or similar.
Thanks.
--
-Zenin
zenin@best.com
------------------------------
Date: Mon, 17 Nov 1997 15:50:25 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: perl bug?
Message-Id: <EJss01.8pt@world.std.com>
"Zisha Weinstock" <sysop@diamonds.com> writes:
>#!/usr/bin/perl
>sub FOO { print "foo!\n"; }
>open FOO or die;
>On my system (SCO OpenServer 5 perl version 5.003), this prints out "foo"
>and then
>dies. Why? Is it confusing a filehandle with a function call or is this by
>design?
Before perl 5, subroutines needed to be preceded by an ampersand, and
they never required parenthesis when there were no arguments. (and I
guess before the amersand was the "do FOO" syntax.)
&FOO;
When perl 5 was developed, the amersand was made optional if perl
could determine that it is should be a subroutine call. Some of the
rules that it uses:
1. There are parenthesis following the identifier.
2. It has already seen the subroutine definition as it is compiling
the subroutine call. (Including all of the subroutine definitions it
has seen already in "use" statements.)
3. The subroutine has a "forward declaration". The would be the
keyword "sub" followed by an identifer, but with no block following
it.
Since your code has already seen a subroutine named "FOO", whenever it
sees a term named "FOO" it will call the "FOO" subroutine and use its
result instead.
In your case, you are likely opening a filehandle named "1". (Unless
the print fails.)
--
Andrew Langmead
------------------------------
Date: 17 Nov 1997 09:45:21 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: PERL for ALPHA/VMS
Message-Id: <64pla1$440@panix.com>
In <346FACB1.A364FA6C@erols.com> jsbobcat@erols.com writes:
>I know Perl is available for Alpha / OpenVMS but I can't find a site
>which has it. Do you know where I could find this free version?
Check the VMS Perl "FAQ" (unofficial):
http://w4.lns.cornell.edu/~pvhp/perl/vms.html
You may also want to check the VMS section or Perl Reference:
http://reference.perl.com/query.cgi?vms
--
Clay Irving <clay@panix.com> http://www.panix.com/~clay/
------------------------------
Date: Mon, 17 Nov 1997 08:41:05 -0600
From: surabaia@hotmail.com
Subject: satan & perl
Message-Id: <879777104.19934@dejanews.com>
I am encountering the following error when running Satan on Irix
6.2 or Solaris. Someone on comp.sys suggested that my Satan is old
and requires Perl4 (I am running Perl 5.004_02). So I got the latest
ftp.win.tue.nl/pub/security/satan-1.1.1 but the problem is still there.
Has any Perl expert successfully run Satan with Perl 5.004_02 on Irix
or Solaris?
Thanks in advance!
-------------------------------------------------------------------
Error from Netscape 3.0 when running Satan 1.1.1 with perl 5.004_02
syntax error at /tmp/MO...pl line 2, near "HEAD>"
Bareword found where operator expected at /tmp/MO...pl line 3, near
"<TITLE>Initialization"
(Missing operator before SATAN?)
In string, @fish now must be written as \@fish at /tmp/MO...pl line
3, near "TITLE>
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Sun, 16 Nov 1997 18:35:37 GMT
From: Miten S Mehta <mehta@mama.indstate.edu>
To: "Eric D. Friedman" <friedman@uci.edu>
Subject: sccs setup on solaris
Message-Id: <Pine.LNX.3.96.971116133147.8987C-100000@mama.indstate.edu>
11/16/97
Hello,
I know little about sccs but am going to need to do setup, administration
for sccs. could some one experienced with setting sccs on solaris guide
me. I know all user commands but need the initial setting guidance for
the team.
I remember at previous work we had a common "SCCS" dir owned probably by
user "sccs". This was "777" and there were "csh" scripts as "lget, lnew,
ledit, ldelta, lunget" for usage convenience. I can probably write those
scripts myself.
are there modules in perl for ease?
is there some one who could guide with may be "cvs" :-) and is using it?
Have a good day !!!
Best Regards,
Miten Mehta.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
Res: |
Miten S Mehta |
311 S Lasalle St, 39E, |
Durham, NC 27705 |
Tel: 919 416 3889 |
e-mail: mehta@mama.indstate.edu |
resume url: |
ftp://mama.indstate.edu/users/mehta/resume.html |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Mon, 17 Nov 1997 15:14:52 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <EJsqCs.1ro@world.std.com>
danny@lennon.postino.com (Danny Aldham) writes:
>Tad McClellan (tadmc@flash.net) wrote:
>: Would it be possible to get the Top 10 Posters of FAQs?
>: I swear, close to 50% of the posts are such a beast. Couldn't
>No, I think RTFM posts far out-number FAQ posts. Every FAQ post
>seems to elicit 3 or 4 RTFM posts.
Most posts, whether they are FAQs or not, tend to result in more than
one response. Usenet and similar environments are often called
"discussion groups" for this very reason. (Have you ever had a
discussion with a person or a group of people where every question
only results in one single response? It gets annoying and almost
unnerving after a while.)
For FAQs specifically, there are a couple of reasons why you tend to
get more than one answer to frequently asked questions.
1. Propegation delays. Each responder doesn't see the others response.
2. The common breach of Netiquette where the responder doesn't read
the entire thread before responding. (It doesn't make it right, but it
does happen. When someone sees that they have performed this faux pax,
the best they can do is try to prevent it from happening in the
future.)
3. Other responses may be incomplete. The other posts may not be
giving a piece of information that the author may feel is important.
After all, different people have different points of view.
4. Other responses may approach the problem from a completely
different point of view as the author might.
5. Another response may be completely flawed, compeling someone who
sees the flaw to follow up with corrections.
And of course, for each additional post, there is a potential that the
whole processes starts over again.
My personal opinion is like many others in that the volume of FAQ
answers is just a symptom of the problem of a high volume of FAQ
questions. And I feel that solving the symptom will not solve the
underlying problem.
I have been toying with an idea that may alleviate the situation. If
the frequent posters to comp.lang.perl.* put a header in their posts
that are answers to FAQs (maybe with the contents of the header being
a URL to the source of their answers.) others may find a way to kill
both the response and its originating question. They reason that I'm
thinking of putting the URL in the header is to differentiate the
posts between absolutely factual answers and replies that are contain
they authors opinions.
--
Andrew Langmead
------------------------------
Date: 17 Nov 1997 14:31:35 GMT
From: lvirden@cas.org
Subject: Re: Tk/Motif/Embedded Perl question
Message-Id: <64pkg7$9h6$1@srv38s4u.cas.org>
According to Brian Wheeler <bdwheele@indiana.edu>:
:In article <01bcf037$af53bf20$d8131791@btpab1.knmi.nl>,
: "Peter Lagerweij" <lagerwey@knmi.nl> writes:
:
: Hmm. I don't know the answer to your question, but I do have a
:_related_ question:
: Is it possible to embed perl in a motif application and _use_ motif?
:If it is...couldn't there be a perl plugin to netscape? client side scripting
:would be way cool...
You might investigate the OpenGL perl module. At one point I believe
the WWW page for it listed info about creating a Perl plugin which then
was used to do OpenGL into a web page.
--
Larry W. Virden INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.
------------------------------
Date: Mon, 17 Nov 1997 13:42:47 +0100
From: b.wilkinson@pindar.com (Bob Wilkinson)
Subject: Re: Trying to copy a file on winnt in perl...
Message-Id: <b.wilkinson-1711971342470001@ip57-york.pindar.co.uk>
In article <Pine.WNT.3.96.971114132511.161A-100000@pc19675.fhcrc>, Douglas
Nichols <dnichols@fhcrc.org> wrote:
> This seems silly but I'm not finding a command to copy a file from one
> place to the next. I could just read it but I'd rather have someother
> routine do the dirty.
>
> If you know would you direct me?
>
> thanks
>
> dn
>
> Douglas Nichols dnichols@fhcrc.org
> ----------------------------------------------------------------------------
> Database Manager National Wilms Tumor Study Group
> Fred Hutchinson Cancer Research Center
perldoc File::Copy
Bob
--
.sig file on holiday
------------------------------
Date: 17 Nov 1997 15:45:49 GMT
From: "Keith Chern" <ljchern@singnet.com.sg>
Subject: Winnt and Unix Communication
Message-Id: <01bcf36f$a7c5aa80$674ba8c0@keith_nb.platinum.com>
Anybody know how perl in an Unix system could trigger an NT/Win95 on the
same network of IP protocol to run an executable or WinPerl on the NT/Win95
to run a script? Is it by using socket communication?
Unix and Unix communication can easily automate the trigger by automate a
telnet login and execute on the telnet services right? Whereas Unix and
WinNT/Win95 is another story.
Thanks!
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 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.
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 1329
**************************************