[9669] in Perl-Users-Digest
Perl-Users Digest, Issue: 3261 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 27 12:27:56 1998
Date: Mon, 27 Jul 98 04:04:56 -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 Mon, 27 Jul 1998 Volume: 8 Number: 3261
Today's topics:
Re: [CFP] On to Perl 5.005: Beta testing begins <andreas.greulich@mbox.bfi.admin.ch>
Re: Best perl book for web programming (Martin Vorlaender)
blat blues <sponge@iav.com>
Re: Building and sorting a list of records (Martin Vorlaender)
Re: Code for deciding week number? Leon Schmetz
Re: Detecting Countries (Iain Chalmers)
embedding perl into VB <jkiser@best.com>
EOF, EOT and END_OF_TEXT error messages <jbonzo@home.com>
Re: Flat-File Database (Gareth)
fork() problem dwiesel@my-dejanews.com
getting the binary represenation of a number (Amy Rogers)
Re: getting the binary represenation of a number (Abigail)
Re: getting the binary represenation of a number (Craig Berry)
Re: having problems reading STDIN (Mark-Jason Dominus)
If statement does not compare correctly Leon Schmetz
Re: mailspinner.cgi <Sking1235@aol.com>
Re: perl and binary data file (Craig Berry)
Re: Perl4 to Perl5 <Borre.Fjeldso@ericsson.no>
Pg-Perl extension for PostgreSQL rasyidi@aitpg.Adorna-RMIT.edu.my
Re: PLEASE HELP: Simple ascii to binary script <uri@sysarch.com>
Re: problem undefining hash (root)
Re: problem undefining hash (M.J.T. Guy)
Problem with random numbers <wodehouse@cheerful.com>
Re: Reacting to 1 of 10 or so possible values.... Need (Ronald J Kimball)
Re: Recent Secret Government Experiments Killing People <somewhere@over.the.rainbow>
Re: Returning values from a child process (nobody)
Re: Rounding (Ronald J Kimball)
Re: Script for webmail <Sking1235@aol.com>
seeing if a file exists. (Ollie Cook)
Unable to get REMOTE_HOST <tho@sn.no>
Usage of tie with ndbm_file <quednauf@nortel.co.uk>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 27 Jul 1998 12:20:34 +0200
From: "Andreas Greulich" <andreas.greulich@mbox.bfi.admin.ch>
Subject: Re: [CFP] On to Perl 5.005: Beta testing begins
Message-Id: <35bc5473.0@fwsrva.bfi.admin.ch>
Hi,
I just tried to compile Perl 5.005_50 on a Solaris 2 (5.5.1) machine and got
a
compiler error. This is an excerpt out of my install_log:
------------------------------
>
./Configure -Dusethreads -des -Dcc=gcc -Dprefix=/opt/perl_thread -DDEBUGGING
...
...setting architecture name to sun4-solaris-thread.
...
Any additional libraries?
[-lsocket -lnsl -ldl -lm -lposix4 -lpthread -lc -lcrypt]
What optimizer/debugger flag should be used? [-O]
Any additional cc flags?
[-D_REENTRANT -I/usr/local/include -I/opt/local/include -I/opt/gnu/include]
Let me guess what the preprocessor flags are...
Any additional ld flags (NOT including libraries)?
[ -L/usr/local/lib -L/opt/local/lib -L/opt/gnu/lib]
...
> make
`sh cflags libperl.a miniperlmain.o` miniperlmain.c
CCCMD =
gcc -B/usr/ccs/bin/ -DPERL_CORE -c -D_REENTRANT -I/usr/local/
include -I/opt/local/include -I/opt/gnu/include -O
gcc: file path prefix `/usr/ccs/bin/' never used
... (also success with perl.c, malloc.c, gv.c, toke.c, perly.c and op.c int
his order)
`sh cflags libperl.a regcomp.o` regcomp.c
CCCMD =
gcc -B/usr/ccs/bin/ -DPERL_CORE -c -D_REENTRANT -I/usr/local/
include -I/opt/local/include -I/opt/gnu/include -O
regcomp.c: In function `scan_commit':
regcomp.c:209: `thr' undeclared (first use this function)
regcomp.c:209: (Each undeclared identifier is reported only once
regcomp.c:209: for each function it appears in.)
regcomp.c: In function `regclassutf8':
regcomp.c:2249: `thr' undeclared (first use this function)
regcomp.c: In function `reguni':
regcomp.c:2546: `thr' undeclared (first use this function)
regcomp.c: In function `save_re_context':
regcomp.c:3108: `thr' undeclared (first use this function)
gcc: file path prefix `/usr/ccs/bin/' never used
make: *** [regcomp.o] Error 1
l> exit
------------------------------
Release 5.004_75 (beta release 1) compiled without problems.
I'm using gcc version 2.7.2.1.
------------------------------
Date: Mon, 27 Jul 1998 05:18:40 +0200
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Best perl book for web programming
Message-Id: <35bbf190.524144494f47414741@radiogaga.harz.de>
You've got lots of suggestions for books. As a nice URL to backup your
CGI programming knowledge with heavily commented examples look into
http://www.stonehenge.com/merlyn/WebTechniques/
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
Cetero censeo | work: mv@pdv-systeme.de
Redmondem esse delendam. | http://www.pdv-systeme.de/users/martinv/
| home: martin@radiogaga.harz.de
------------------------------
Date: 27 Jul 1998 09:43:16 GMT
From: "Neal Miyake" <sponge@iav.com>
Subject: blat blues
Message-Id: <01bdb942$3f8801e0$480918cf@default>
Hi,
Been porting over some unix perl scripts to NT4 Servers running Exchange
5.5, IIS4 and Perl for Win32. Am trying to send mail via command line, and
was told to try blat.
Blat works great... sometimes. For some reason, it takes a really long
time before the command runs, maybe two minutes. The command usually
timeouts before it can send the message.
Part of the problem may lie in the way the Exchange server was configured.
The lan uses Microsoft Network to identify the components, so the dns
service is not enabled. As for Exchange, the SMTP addressing is not like a
typical dns address.
Usually, you set up blat with this install line:
blat -install SMTPserver.blah.com userid@SMTPserver.blah.com
I've tried many configs, but the only way I could get it to work is:
blat -install NTcomputername userid@domainname.fakedomain.com
where the Exchange server recognizes SMTP addressing as
domainname.fakedomain.com.
As mentioned before, most of the time, the command timeouts. However,
sometimes the message actually is sent correctly. I'm guessing that it's
having problems finding the server since it is not a typical dns name. Any
suggestions or solutions would be greatly appreciated. Please also copy a
reply to sponge@iav.com. Thank you very much in advance.
Neal
------------------------------
Date: Mon, 27 Jul 1998 06:14:15 +0200
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Building and sorting a list of records
Message-Id: <35bbfe97.524144494f47414741@radiogaga.harz.de>
Stephane Barizien (sto41@wanadoo.fr) wrote:
: I want to build a list of records in a loop, then sort that list according
: to a given field.
: I've tried:
: {
: ...
: push @lines, (field1 => $somevalue, field2 => $anothervalue);
: ...
: }
If you want to store more than one value in an array element, you'll
need to use anonymous hashes:
push @lines, {field1 => $somevalue, field2 => $anothervalue};
: @sortedlines = sort byfield2 @lines;
: sub byfield2
: {
: $field2{$a} cmp $field2{$b};
: }
I wonder where you got that hash %field2 from...
: but it doesn't work (of course! ;-)
sub byfield2
{
$a->{'field2'} cmp $b->{'field2'};
}
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
Cetero censeo | work: mv@pdv-systeme.de
Redmondem esse delendam. | http://www.pdv-systeme.de/users/martinv/
| home: martin@radiogaga.harz.de
------------------------------
Date: Mon, 27 Jul 1998 10:45:38 +0200
From: Leon Schmetz
Subject: Re: Code for deciding week number?
Message-Id: <35bc3c4f.2263957@news.origin-it.com>
As far as I know, there are no functions available to get the week
number unless you try to use functions from Excel or the like.
However you can calculate the weeknumber using the localtime function.
This function returns as one of its values the the number of the day
within the year. Also the day number in the week can be found.
Secondly you have to determine what day of the week january 2nd was.If
this was a working day, then january, 2 is in week number 1.
>From there it is only simple math to calculate the current week
number.
Hope this helps.
On Sun, 26 Jul 1998 16:14:09 +0200, Thomas Jespersen
<thomas@daimi.aau.dk> wrote:
>Thomas Albech wrote:
>>
>> Hi everyone,
>>
>> How do you mathematically decide, which week number we are currently in?
>> Is there any expression for it
>> in combination with the Time module?
>>
>> Thanks,
>> Thomas
>
>perldoc perlfaq4
>
>Look for:
>
>How do I find the week-of-the-year/day-of-the-year?
------------------------------
Date: Mon, 27 Jul 1998 17:28:21 +1000
From: bigiain@mightymedia.com.au (Iain Chalmers)
Subject: Re: Detecting Countries
Message-Id: <bigiain-2707981728220001@bigman.mighty.aust.com>
In article <35ba2cd5.153611903@news2.cais.com>,
root.noharvest.\@not_even\here.com wrote:
<-snip->
> But, as a side note, I think it's MIT, or some other school that does
> allow downloads of PGP, but only if their scripting can reasonably
> determine that you are coming from a "US Ip address" - of course, this
> is not foolproof, but it might just be "reasonable effort" so you
> can't be made liable for a few rogue free-thinkers who wish to have
> good encryption even though the U.S. doesn't wish them to.
heh heh heh, my Australian ISP has a proxy server in California...
ooops, did i accidentally click that download link,
Iain
------------------------------
Date: Sun, 26 Jul 1998 23:54:18 -0700
From: Jeffee Kiser <jkiser@best.com>
Subject: embedding perl into VB
Message-Id: <35BC2418.950E709E@best.com>
Does anyone know if there are any ways (or know where some documentation
may be) on embedding the perl interpretter into an application written
in Visual Basic? Thanks
Jeff Kiser
jkiser@best.com
jeffk@synplicity.com
------------------------------
Date: Mon, 27 Jul 1998 03:27:30 GMT
From: "Justin M. Bonzo" <jbonzo@home.com>
Subject: EOF, EOT and END_OF_TEXT error messages
Message-Id: <35BB93D2.E4315DDE@home.com>
I'm trying to implement a new postcard script I downloaded from the web.
Everything is working fine except I get the following messages. Can anyone
help?
# Can't find string terminator "EOT" anywhere before EOF.
File 'Desktop Folder:postcards:postcard.pl'; Line 274
# Can't find string terminator "END_OF_TEXT" anywhere before EOF.
File 'Desktop Folder:postcards:cgi-lib.pl'; Line 91
Thanks,
Justin
--
<><><><><><><><><><><><><><><><><><><>
Justin M. Bonzo
jbonzo@home.com
http://members.home.net/jbonzo
ICQ#: 10202789
<><><><><><><><><><><><><><><><><><><>
The box said "Windows 3.1 or better," so I bought a Macintosh.
"Practice random acts of kindness and senseless beauty."
-- Unknown
------------------------------
Date: Mon, 27 Jul 1998 10:46:21 GMT
From: garth_h@geocities.com (Gareth)
Subject: Re: Flat-File Database
Message-Id: <35bc4f81.10469318@192.168.0.1>
On Mon, 20 Jul 1998 15:27:26 -0400, "Sam Spurling"
<spurling@mindspring.com> wrote:
>I am new to perl and am wanting to write a database that can be added to
>deleted from and modified. Does anyone have an example that I can use to
>see and understand how this works in perl.
try having a look at dbman from
http://www.gossamer-threads.com/
keep on grooving
Gareth
http://www.geocities.com/SunsetStrip/Club/8182
e-mail gareth_h@geocities.com
------------------------------
Date: Mon, 27 Jul 1998 08:50:35 GMT
From: dwiesel@my-dejanews.com
Subject: fork() problem
Message-Id: <6phf0q$m2e$1@nnrp1.dejanews.com>
Hi,
I have a fork() problem. I can't figure out what is wrong. Look at this
code...
#! /usr/local/bin/perl
$number_of_forks = 0;
$SIG{CHLD} = sub { $number_of_forks--; wait;};
for ($i = 0; $i < 3; $i = $i + 1)
{
$number_of_forks++;
$pid = fork;
# If child
if ($pid eq 0)
{
&do_something_that_takes_a_while($i);
exit;
}
}
while($number_of_forks > 0)
{
print "Number of forks: $number_of_forks\n";
sleep 1;
}
When I run this small program I get the following output:
my_computer:~$ test.pl
Number of forks: 3
Number of forks: 1
Number of forks: 1
Number of forks: 1
etc. etc. (looping forever)
I can't figure out what I have done wrong... can you help me?
// Daniel
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Sun, 26 Jul 1998 20:13:00 -0700
From: xxxx@xxxx.xxx (Amy Rogers)
Subject: getting the binary represenation of a number
Message-Id: <xxxx-2607982013000001@dnai-207-181-237-52.dialup.dnai.com>
Hi-
I'm a perl newbie. I'm trying to understand how to get the binary
representation of a number. The process given in a book (David Till's
Teach yourself Perl in 21 days) does not make it clear how it works and
would like to hear another way to look at it, if at all possible.
On the same subject here's a short program that uses the << operator to
print out the first 16 powers of 2. The answer is given below, but I'm
having trouble understanding the "$value = $value << 1;" line. I
understand that I should convert the $value to a bit notation so I could
shift the first bit out to the right by one to get the new value.
$value = 1;
$counter = 0;
while ($counter < 16 ) {
print "2 to the power $counter is $value\n";
$value = $value << 1;
$counter++;
On the other hand, even if I had understood the whole bit notation
conversion, I wonder what relevancy, if at all, it has for the beginner
like myself? The "Learning Perl, 2nd edition" doesn't appear touch on
this subject at all.
Amy
aro@dnai.com
------------------------------
Date: 27 Jul 1998 04:56:21 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: getting the binary represenation of a number
Message-Id: <6ph19l$mr7$2@client3.news.psi.net>
Amy Rogers (aro@dnai.com) wrote on MDCCXCI September MCMXCIII in
<URL: news:xxxx-2607982013000001@dnai-207-181-237-52.dialup.dnai.com>:
++ Hi-
++
++ I'm a perl newbie. I'm trying to understand how to get the binary
++ representation of a number. The process given in a book (David Till's
++ Teach yourself Perl in 21 days) does not make it clear how it works and
++ would like to hear another way to look at it, if at all possible.
What exactly do you mean by "the binary representation" of a number?
How it's stored internally? That depends on the machine - a little
endian machine will have a different representation than a big endian
machine, and for negative numbers, it depends whether one's or twos'
(or is it ones' and two's?) complement is being used.
In general, to convert from binary to decimal, and from decimal to
binary, one uses pack. Read perlfunc, and perlfaq.
++ On the same subject here's a short program that uses the << operator to
++ print out the first 16 powers of 2. The answer is given below, but I'm
++ having trouble understanding the "$value = $value << 1;" line. I
That's just another way of writing $value = $value * 2;
++ understand that I should convert the $value to a bit notation so I could
++ shift the first bit out to the right by one to get the new value.
You don't have to do anything. Perl will take of that.
++ $value = 1;
++ $counter = 0;
++ while ($counter < 16 ) {
++ print "2 to the power $counter is $value\n";
++ $value = $value << 1;
++ $counter++;
++
++ On the other hand, even if I had understood the whole bit notation
++ conversion, I wonder what relevancy, if at all, it has for the beginner
++ like myself? The "Learning Perl, 2nd edition" doesn't appear touch on
++ this subject at all.
Sometimes, people use integers as bitfields. In those cases, bitwise
arithmetic can be useful.
I seldom have the use for <<. Very seldom.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
------------------------------
Date: 27 Jul 1998 07:08:03 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: getting the binary represenation of a number
Message-Id: <6ph90j$cu$2@marina.cinenet.net>
Amy Rogers (xxxx@xxxx.xxx) wrote:
: I'm a perl newbie. I'm trying to understand how to get the binary
: representation of a number. The process given in a book (David Till's
: Teach yourself Perl in 21 days) does not make it clear how it works and
: would like to hear another way to look at it, if at all possible.
There's probably a direct way to do this with pack/unpack, but I can't
seem to make it work right now. For positive integers, this does the
trick:
sub tobin
{
my $res = '';
for (my $num = shift;
$num != 0;
$num >>= 1) {
$res .= $num & 1;
}
return scalar reverse $res;
}
: On the same subject here's a short program that uses the << operator to
: print out the first 16 powers of 2. The answer is given below, but I'm
: having trouble understanding the "$value = $value << 1;" line.
Me too; it's a lot clearer (to me) to write that as
$value <<= 1;
Either one means "Take the binary representation of the number $value, and
shift it 1 position to the left." For nonnegative integers, this is
exactly the same as multiplying the number by two. Shifting left by N is
equivalent to multiplying by 2^N.
: I understand that I should convert the $value to a bit notation so I
: could shift the first bit out to the right by one to get the new value.
To the left, that is. And yes, writing out the bit values and walking
through the code by hand can be very instructive.
: $value = 1;
: $counter = 0;
: while ($counter < 16 ) {
: print "2 to the power $counter is $value\n";
: $value = $value << 1;
: $counter++;
(You're missing a }, of course.) I'd write that as
for (my $pwr = 0; $pwr < 16; $pwr++) {
print "2 to the power $pwr is ", 1 << $pwr, "\n";
}
Saves having two control variables.
: On the other hand, even if I had understood the whole bit notation
: conversion, I wonder what relevancy, if at all, it has for the beginner
: like myself?
Depends on what you're trying to do, of course. But yes, in general,
beginners don't end up needing to manipulate bits much.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 27 Jul 1998 01:46:46 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: having problems reading STDIN
Message-Id: <6ph486$bvi$1@monet.op.net>
In article <6pecd0$51e$1@ash.prod.itd.earthlink.net>,
Brent Verner <REPLY_TO_damonbrent@earthlink.net> wrote:
>while(<STDIN>)
>{
> read STDIN, $buffer, 4096, length($buffer);
>--- i am having problems getting all of the STDIN. specifically, the read
>STDIN doesn't pick up where it stopped reading -- it picks up *well beyond*
>the last read position.
> are there things that might inadvertently cause STDIN's file pointer
> to be moved forward (like other file operations)?
You sure hit the nail on the head here. <STDIN> means to read a line
of input from STDIN.
Try
while ($rc = read(STDIN, $buffer, 4096)) {
# Process buffer; note that $rc is the number of characters
# actually read and might be less than 4096.
}
if (defined $rc) {
# Normal EOF condition
} else {
# Read error; reason for failure is in $!
}
------------------------------
Date: Mon, 27 Jul 1998 10:12:20 +0200
From: Leon Schmetz
Subject: If statement does not compare correctly
Message-Id: <35bc35c0.585388@news.origin-it.com>
# I am trying to find out wether one or more bits are set in a given
# value. Below is my testscript. Can you explain why Perl does
# not find values equal????
print sprintf "\nvalue1 is % 11d \(%08x\)", (-1609432919),
(-1609432919);
print sprintf "\nvalue2 is % 11d \(%08x\)", (-2147483648),
(-2147483648);
print sprintf "\n\nResult by OR is %08x\n\n",((-1609432919) |
(-2147483648));
print "Result should equal value1\n";
if (((-1609432919) | (-2147483648)) == (-1609432919))
{
print "\n Matched value";
}
else
{
print "\n If statement does not find this equal";
}
print sprintf "\n\nResult by AND is %08x\n\n",((-1609432919) &
(-2147483648));
print "Result should equal value2\n";
if (((-1609432919) & (-2147483648)) == (-2147483648))
{
print "\n Matched value";
}
else
{
print "\n If statement does not find this equal also";
}
------------------------------
Date: Mon, 27 Jul 1998 05:28:45 -0500
From: Samuel King <Sking1235@aol.com>
To: redpeppa@my-dejanews.com
Subject: Re: mailspinner.cgi
Message-Id: <35BC565D.6B821624@aol.com>
you can find web email scripts at cgi-resources.com
redpeppa@my-dejanews.com wrote:
> if anyone has a copy of mailspinner.cgi plz email me..im 18 and i really
> cant afford paying $1,000 when all im looking for is a personal web email
> client...thanks
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 27 Jul 1998 06:38:28 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: perl and binary data file
Message-Id: <6ph794$cu$1@marina.cinenet.net>
Jingfang Wang (jwang2@osf1.gmu.edu) wrote:
: Can any one tell me whether Perl can read binary data file?
Yes. And on all but the Uncle Bill family of OSs, there's no such thing
as a 'binary file' as a distinct type; files are just files. Now, you do
tend to use different functions to read a file depending on what kind of
data it contains (<FILE> for text data, $/ undef'd <FILE> or read() for
binary data).
: And I also want to know what is the most efficient way for Perl to read
: in a data file?
Depends on a lot of issues; for small files, it's hard to beat
{ local $/; $filedata = <FILE> }
but that can cause problems if the file is too big to fit in memory (or
even if it fits but thrashes virtual memory badly).
Another good alternative is to read chunks in using the read() function.
This is especially appropriate if your data comes in fixed-size records.
: How about use Perl to read a data file comparing with using C or
: Fortran?
Sorry, can't parse that question.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 27 Jul 1998 12:50:44 +0200
From: =?ISO-8859-1?Q?B=F8rre_Fjelds=F8?= <Borre.Fjeldso@ericsson.no>
Subject: Re: Perl4 to Perl5
Message-Id: <gvl67gjr2ij.fsf@eto.ericsson.se>
Sean Bennett <sean@mail.nnet.ne.jp> writes:
> Good day all on a Sat. morning...
>
> I'm on a FreeBSD2.2.6 system...
>
> 'Perl -v' says that I have Perl 4 installed, even though I did a Perl5
> pkg_add last week...
>
<snip>
This isn't a Perl question, but anyway...
FreeBSD has certain tools/scripts written for Perl 4 so it ships with
Perl 4 in /usr/bin. New packages/ports are by default installed in
/usr/local/bin. Update your path by inserting /usr/local/bin before
/usr/bin, i.e.
PATH=/usr/local/bin:$PATH; export PATH # sh, ksh, bash ..
setenv PATH /usr/local/bin:$PATH # csh, tcsh ...
BTW Do not remove /usr/bin/perl or replace this with Perl 5. I suspect
you could be getting some problems that way.
//Bxrre
--
Bxrre Fjeldsx - bgf@dod.no - Honda VFR750 - Dod# daf - NMCU #26215
We should develop anti-satellite weapons because we could not have
prevailed without them in "Red Storm Rising". -- Dan Quayle
------------------------------
Date: Mon, 27 Jul 1998 09:08:38 GMT
From: rasyidi@aitpg.Adorna-RMIT.edu.my
Subject: Pg-Perl extension for PostgreSQL
Message-Id: <6phg2l$n7q$1@nnrp1.dejanews.com>
How I want to start the sript(#!/usr/bin/perl or ????)?
Where must I save the script?
If the script must save in cgi-bin directory, how i want to call the script
from HTML page?
For PHP/FI, the script is inside the HTML page and for perl!!! ?
Can someone help me to create an example script to add, delete, view and
modify the database from postgresql using perl?
Thanks.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 27 Jul 1998 00:55:46 -0400
From: Uri Guttman <uri@sysarch.com>
To: James <James@comp4ncr.com>
Subject: Re: PLEASE HELP: Simple ascii to binary script
Message-Id: <x7d8arlwod.fsf@sysarch.com>
please do not send attachments to this group. postings should be in plain
text with NO binary data, especially encoded SOURCE code. we like to see
source code and we can read it just fine in ascii. i doubt you will get
any help unless we can see what you are trying to do.
good luck with disabling attachments.
BTW perl can convert ascii to binary with one builtin function. i
leave finding that one as an exercise to the original poster. try
grepping through the perl documentation and faqs.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 27 Jul 1998 03:01:55 GMT
From: root@am.westblaak.spirit.nl (root)
Subject: Re: problem undefining hash
Message-Id: <6pgqj3$18l$1@newnews.nl.uu.net>
To: sweth-usenet@astaroth.nit.gwu.edu (Sweth Chandramouli)
In article <sweth-usenet-2507981659010001@alex-va-n013c081.moon.jic.com>, sweth-usenet@astaroth.nit.gwu.edu (Sweth Chandramouli) writes:
> this is definitely something simple that i'm missing. i have the
> following block of code in a script of mine, designed to read key,value
> pairs from a file (opened elsewhere) and pump them into a hash:
>
> sub init_hash {
> if (keys %id_hash) {undef %id_hash} || die 'undef failed';
I did not try, actually, but I guess something like
if (keys %id_hash) {undef %id_hash || die 'undef failed'};
could do it. I've never seen
if ($a == $b) {
$a++;
} || warn 'some error...\n";
before, and thats what you actually try to do..:-)
I hope this helps,
Andre.
+---------------------------------+----------------------------------+
| Andre Merzky | |
| Dep. of Physics - EEP I | Kathrin Kirsch & Andre Merzky |
| Humboldt University of Berlin | bij Beekma |
| Invalidenstr. 49 | van Boetzelaerstraat 5^3 |
| D-10115 Berlin | NL-1051 CS Amsterdam |
| Tel.: ++49 - 30 - 2093 7988 | Tel.: ++49 - 171 - 280 24 12 |
| --- |
| pinocchio@earthling.net - http://home.pages.de/~pino |
| __o --- |
| _`\<,_ |
|____ (_)/ (_) _________________________________think global_________|
> while (<INPUT_FILE>) {
> @tmp_array = split(/,/);
> $id_hash{$tmp_array[0]} = $tmp_array[1];
> };
> };
------------------------------
Date: 27 Jul 1998 10:38:35 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: problem undefining hash
Message-Id: <6phlbb$4vb$1@pegasus.csx.cam.ac.uk>
root <root@am.westblaak.spirit.nl> wrote:
>
>I did not try, actually, but I guess something like
>
> if (keys %id_hash) {undef %id_hash || die 'undef failed'};
That's a nonsense. There is no concept of undef() failing. It
always undefines its argument then returns undef. So the die()
will always be called.
Mike Guy
------------------------------
Date: Sat, 25 Jul 1998 20:45:56 +0200
From: "ch" <wodehouse@cheerful.com>
Subject: Problem with random numbers
Message-Id: <6pd93p$ff4$1@dinkel.civ.utwente.nl>
Hello,
I have a script to choose a random song from over 15,000. The problem is
that the choice made by the script is not random enough (some songs get
chosen too much, others not at all); initialization of the script is done by
Srand(timer), then a random number is chosen and multiplied by 15,000... is
there any better way of choosing a random number, something that is _really_
random?
Casper H.
------------------------------
Date: Mon, 27 Jul 1998 00:29:02 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Reacting to 1 of 10 or so possible values.... Need some streamlining help.
Message-Id: <1dcsu2i.1o4epbc4s3lysN@bay1-405.quincy.ziplink.net>
BullDog USMC <bulldog@usmc.net> wrote:
> if ($reqType eq "typeOne"){
> ...set up environment...
> ...execute routine(s)...
> exit;
> }
>
> [...]
>
> The problem is that each IF statement is getting more and more
> complex.
>
> Are there any suggestions on how to streamline this handling?
CASE:
foreach ($reqType) {
/^typeOne$/ && (&do_something, last CASE);
/^typeTwo$/ && (&do_something_else, last CASE);
&do_default_thing;
}
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 26 Jul 1998 22:55:42 -0400
From: Nobody <somewhere@over.the.rainbow>
Subject: Re: Recent Secret Government Experiments Killing People!!!
Message-Id: <6pgq6h$lvm@bgtnsc02.worldnet.att.net>
I agree completely. Just like the research in non-lethal weapons. Ultrasonic,
Vortex, and Laser research done my our government is very important. As for
corporations doing research like this, well it all depends on the corporation. I
mean if a corporation where to research genetics and cloning, I sure they could get
a lot of profit. I mean useable organs are very costly and if a corporation where
able to mass produce, let's take hearts, hearts then they could make a lot of
money. Now if you are going to say that such a feat is impossible, then look at
the mice they cloned recently. 24 clones and some where clones of clones.
Interesting ain't it.
- wrote:
> Nobody <somewhere@over.the.rainbow> Said this:
>
> >Let me guess this place out in Nevada. It was an old abandon base which also
> >known as Area 51???!!??
>
> Exactly, another flaw in the whole story - they abandoned that
> facility at least 2 years ago after they finally figured it's cover
> was completely blown. I believe the skunk works and all the other
> black projects are in Colorado or New Mexico now.
>
> And oh yeah.... black projects aren't all the big a deal. I for one
> am glad they exist - I can't imagine how some commercial and "real
> world" technologies would become available if the government didn't
> fund this sort of advanced, almost surreal research. I can't see a
> GM, or a GE, or a Microsoft funding the same kind of research, since
> most of the projects probably get scrapped after a few years and a few
> hundred million dollars. Corporations can't afford such "frivolous"
> research, they need ROI (return on Investment).
>
> >
> >Daniel (dS=dQ/T) Key wrote:
> >
> >> blowclinton@my-dejanews.com wrote in message
> >> <6pc4eu$32r$1@nnrp1.dejanews.com>...
> >> >Okay...
> >> >
> >> >A friend of mine, whose identity must remain anonymous has agreed for me to
> >> >let everyone know what she has seen.
>
------------------------------
Date: 27 Jul 1998 03:21:27 GMT
From: ac1@fspc.netsys.itg.telecom.com.au (nobody)
Subject: Re: Returning values from a child process
Message-Id: <6pgrnn$3mc@newsserver.trl.OZ.AU>
Chris Bero (cbero@uwyo.edu) wrote:
: If I have a parent process which forks to a child process and that child does
: some kind of processing of a variable, is there a way to return the new value of
: that variable to the parent process? (my god, that was one sentence!)
We're not gods, just incredibly intelligent AND good-looking :-).
: Any suggestions would be welcomed.
Head Geek? Is that an official title in Wyoming?
Try this on for size:
#!/opt/perl5/bin/perl -w
$intVar = 1;
if (fork) {
print "Parent has $intVar\n";
wait;
$intVar = ($? >> 8);
print "Parents child returned $intVar\n";
} else {
sleep 2;
print "Child has $intVar\n";
$intVar += 10;
print "Child returns $intVar\n";
exit $intVar;
}
Regards,
AllanC
AlphaGeek (C/*NIX)
Apprentice (Perl).
------------------------------
Date: Mon, 27 Jul 1998 00:29:12 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Rounding
Message-Id: <1dcsu80.wd4k2612g2vqgN@bay1-405.quincy.ziplink.net>
Ollie Cook <oliver.cook@bigfoot.com> wrote:
> On 24 Jul 1998 21:31:29 GMT, cberry@cinenet.net (Craig Berry) wrote:
>
> >Ollie Cook (oliver.cook@bigfoot.com) wrote:
> >: I've just written a Web Cart perl script for a client and I'm now
> >: stuck at what seems the simplest part of the script. How can I round
> >: the amount to pay to 2 dp? Current the value in the scalar is, say,
> >: 1839.12864 , due to complex VAT arithmetic. I'd like it to round to
> >: 1839.13. How can I achieve this?
>
> The code I was looking for was sprintf("%.2f",$incvat)
> Thanks for pointing me towards the posting and I'm sorry,l didn't
> realise you had your head so firmly up your arse, when I posted.
You asked a question that is clearly answered in the Perl FAQ, is asked
at least once a week in clpm, and has already been answered here
numerous times in the past month. If you couldn't even look at the FAQ
or dejanews, I'd guess that you're the one with your head up your arse.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 27 Jul 1998 05:10:20 -0500
From: Samuel King <Sking1235@aol.com>
To: skyboy@my-dejanews.com
Subject: Re: Script for webmail
Message-Id: <35BC520A.3A6912CD@aol.com>
Available at cgi-resources.com\
skyboy@my-dejanews.com wrote:
> Does anyone have a Perl script that allow the users in my LAN acess
> e-mails through Web ?
>
> Thanks
> ACJr.
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 27 Jul 1998 07:21:28 GMT
From: oliver.cook@bigfoot.com (Ollie Cook)
Subject: seeing if a file exists.
Message-Id: <35bc2928.457026@news.ukonline.co.uk>
I'm having some trouble at the moment with a shopping cart that i'm
writing, and would really appreciate it if some of you could shed some
light on the matter, which none of my manuals have been able to do.
Basically, I just want it to fill an array with zeros if the file
doesn't exist, and if the file does exist to read in the data from
that file. However, the code that I'm using at the moment makes the
'if' run even if the file doesn't exist. I'll copy the code in here:
#Fill Out Amount, Either From File, Or Set To Zero
if (-e "$visitordir/$ENV{'REMOTE_ADDR'}") {
open (DATAIN,"$visitordir/$ENV{'REMOTE_ADDR'}");
@readin = <DATAIN>;
close(DATAIN);
$readloop = "0";
foreach $loopie (@readin) {
$readloop++;
($initem[$readloop], $inquant[$readloop]) = split (/_/, $loopie);
$amount[$readloop] = $inquant[$readloop];
}
}
else {
$count = "0";
for $doh (1..$looper) {
$count++;
$amount[$doh] = "0";
}
}
I hope someone can give me a clue on this one, and if you're disgusted
by my code, please don't be - I'm just learning.
Regards,
Ollie
----
Oliver COOK, Web Site Designer for
Premiere Web Designs - Http://Www.Premiere.Uk.Com/
+
Webmaster of The Audio-Visual Archive
* over 900 images and 700 sounds, free
* Http://Www.Premiere.Uk.Com/ava/
------------------------------
Date: Sun, 26 Jul 1998 23:37:31 +0200
From: "Thomas =?iso-8859-1?Q?=D8derud?=" <tho@sn.no>
Subject: Unable to get REMOTE_HOST
Message-Id: <35BBA19B.392A2EF3@sn.no>
My ISP is running an Apache Server.
In one of my script I retrive the REMOTE_HOST Environment Variable with
the
output being the ip adress. Does anybody know how to fix this..??
Thomas Xderud
------------------------------
Date: Mon, 27 Jul 1998 11:28:14 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Usage of tie with ndbm_file
Message-Id: <35BC563E.A6356F72@nortel.co.uk>
Hello there, it's Monday and it's difficult to think
after roaming through perlfunc, dejanews, altavista and infoseek I am
not a lot wiser. My question is: Does anyone have more information on
using tie to tie a hash to a database? Maybe some kind of short tutorial
to get me started?
Especially what are the modes needed at the end of the tie command? I
suspect that this particular question is not Perl, but maybe someone can
point me to a source that explains this. I copied the following from the
ndbm_file pod, and, well, it's not working right now.
use CGI qw(:standard);
use NDBM_File;
#line 13:
tie (%VOTE, 'NDBM_File', '/u/quednauf/temp/testfile', O_RDWR|O_CREAT,
0640);
^^^^^^^^^^^^^^^^^^^^
?????
@names = param;
foreach $pa(@names) { $VOTE{$pa} = param($pa); }
untie(%VOTE);
No 'tesfile' was created.
PS
My Server didn't give Internal Server error, but I saw the following
warning (?):
Argument "O_SVWST" isn't numeric in null at
/u/quednauf/public_html/cgi-bin/vote.pl line 13.
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
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 3261
**************************************