[10438] in Perl-Users-Digest
Perl-Users Digest, Issue: 4031 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 21 11:03:29 1998
Date: Wed, 21 Oct 98 08:00:22 -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 Wed, 21 Oct 1998 Volume: 8 Number: 4031
Today's topics:
Re: $0 does not contain script name (Mark-Jason Dominus)
Re: -Help Please-: Efficiency of substr vs. join for st (felix sheng)
anydbm test 12 fails 5.005 <= _02 (solaris2) htim@my-dejanews.com
Re: cgi-lib.pl vs CGI.pm? <perlguy@technologist.com>
Re: coderefs in a package - Where? (Mark-Jason Dominus)
Re: Displaying the Time dave@mag-sol.com
Re: Displaying the Time <gary.ennis@strath.ac.uk>
Re: File locking question... <jdf@pobox.com>
Help with subroutines prakashpatel@hotmail.com
Help with subroutines prakashpatel@hotmail.com
Re: Passing multiple arrays and hashes as parameter (FlightWFY)
Re: Perl & Y2K - booby trap code (Snowhare)
Re: Perl & Y2K - booby trap code (David Alan Black)
Re: Perl & Y2K - booby trap code <merlyn@stonehenge.com>
Re: Perl & Y2K - booby trap code (Larry Rosler)
Re: Perl & Y2K - booby trap code <merlyn@stonehenge.com>
Re: Perl Modulus operator unreliable? Help!! dturley@pobox.com
Re: Perl, dynamic loading, SCO OS 5 <bw@cs3.ecok.EDU>
Problem with perl scripts... hyytiainen@edu.h4thol.fi
Re: read main::DATA multiple <merlyn@stonehenge.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 Oct 1998 09:19:25 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: $0 does not contain script name
Message-Id: <70kn0t$cs3$1@monet.op.net>
In article <362DBB20.5CBE805@pallas.tid.es>,
Jurgen Koeleman <jurgen@pallas.tid.es> wrote:
>Instead of printing the filename "test" it prints "/dev/fd/3".
That is the name of the script on your system.
> Any idea what's going on here?
It is related to the way your operating system handles setuid scripts.
Normally, for non-setuid scripts, it just executes
perl test
But if the OS sees that the script is setuid, it opens `test' on file
descriptor 3, and then executes
perl /dev/fd/3
instead. This is to prevent someone from removing `test' and
replacing it with something else after the OS sees the setuid bit and
before it can run perl.
I don't know of any workaround.
------------------------------
Date: 21 Oct 1998 14:29:38 GMT
From: shengf@wolfgang.ms.com (felix sheng)
Subject: Re: -Help Please-: Efficiency of substr vs. join for string manipulation ?
Message-Id: <70kr4i$4fu@sanews1.morgan.com>
On Wed, 21 Oct 1998 05:09:33 GMT, chunkstar@my-dejanews.com wrote:
> I have perused the newsgroups and FAQ's, but have not found an explicit
>answer to my current dilemma. I am trying to create a new string from a
>combination of literal strings, interpolated strings and substrings in a
>run-time efficient manner. I will sacrifice memory for speed, but dual
>
>sub stringmanipulator {
> my $originalstring = shift;
> my $interpolate = shift;
> my $datapos = index( $originalstring, "KEYWORD" );
> if ( $datapos == -1 ) {
> die 'Didn't find KEYWORD';
> }
> $datapos += 7; # find the text after the keyword ( assumes longer string)
> my $tempstring = substr( $originalstring, $datapos );
> my $newstring = join( "", "EXTRA STUFF$interpolate", $tempstring );
> return $newstring; # return new string - $tempstring discarded
>}
Simply following up on this line of work you could modify the script so that it
looks something like:
sub smanip {
my( $ostr, $inter ) = @_;
my $pos;
die "no key" if ($pos = index($ostr, "KEY" )) == -1;
"EXTRA$inter" . substr( $ostr, $pos+3 );
}
saves a little bit on the temporary vars... actually, probably it only saves
you tempstring.. but that's what you were asking! ;>
hope that helps.
felix
/* felix sheng */
------------------------------
Date: Wed, 21 Oct 1998 13:29:42 GMT
From: htim@my-dejanews.com
Subject: anydbm test 12 fails 5.005 <= _02 (solaris2)
Message-Id: <70knk7$m3k$1@nnrp1.dejanews.com>
I am trying to build perl5.005_02 but test anydbm is failing on test 12.
I am currently using perl5.004_04 which built fine and passed the test.
I have also tried 5.005 which exhibited the same problem, is there a fix for
this?
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 21 Oct 1998 11:36:59 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: cgi-lib.pl vs CGI.pm?
Message-Id: <362DC75B.65C30D9B@technologist.com>
If your programs are not broke, don't fix them.
CGI.pm works great (thanks Lincoln!), but cgi-lib.pl also does a good
job. cgi-lib doesn't have as many bells-and-whistles as CGI.pm, but it
still gets the basic job done.
Bottom line, if you don't have any reason to switch, don't.
You may, however, want to start writing your _new_ programs using
CGI.pm. That way, you'll start getting used to it. Once you get used
to it, you will never switch back! I know I won't...
HTH,
Brent
--
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: 21 Oct 1998 09:14:14 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: coderefs in a package - Where?
Message-Id: <70kmn6$cq5$1@monet.op.net>
In article <Pine.SUN.4.02.9810201935100.20396-100000@mail.enetis.net>,
Justin England <jengland@enetis.net> wrote:
>my $obj = Customers->new();
>$obj->Name("John Doe");
>$obj->name("John Doe");
>
>With the only difference being the name of the function called.
There is a simple and a complicated solution.
1. In the `Customers' package, put
*name = \&Name;
Now `name' is an alias for `Name'.
2. A more general solution uses `autoloading'.
If you invoke a method that doesn't exist, and there is an
`AUTOLOAD' method, Perl will call AUTOLOAD instead.
Name all your methods with all lowercase. (Change `Name' to `name'
in your example.) Then add this AUTOLOAD method:
sub AUTOLOAD {
1 my $self = $_[0];
2 my ($pack, $methname) = $AUTOLOAD =~ /(.*)::(.*)/;
3 my $real_method = $self->can(lc $methname);
4 if ($real_method) {
5 no strict 'refs';
6 *{$AUTOLOAD} = $real_method;
7 goto &$AUTOLOAD;
8 } else {
9 require Carp;
10 Carp::croak(qq{Can't locate object method "$methname" or "\L$methname\E" via package $pack});
}
}
This is highly magical, so don't mess around with it unless you
understand it. Here's what it's doing:
If you ask for a method that doesn't exist, say ->NAME, then Perl will
call AUTOLOAD instead. $AUTOLOAD will be set to "Customer::NAME", and
@_ will be set to the arguments just like with any other method. In
particular, the first argument is the object itself, hjust like with
any other method; line 1 retrieves it. Line 2 splits up the $AUTOLOAD
into a package name "Customers" and a method name "NAME". Line 3
translates the method name to all-lowercase with the `lc' function,
and uses `can' to ask if the object recognizes the lowercase version
of the method name.
If not, control goes to lines 9-10, which abort the program with the
error message
Can't locate object method "NAME" or "name" via package Customer at...
`croak' makes the part after the `at' refer to the line in your main
script that actually tries to use a nonexistent method, instead of to
the line in Customer.pm where the error finally occurred.
If the all-lowercase methd name does exist, link 6 creates the alias
just like at the top of the article. This is so that future calls to
the capitalized version of the method don't have to go through the
autoloading process again; they just get the method instantly. Line 7
then plays a trick: It uses the `magical goto' to transfer control to
the real method. The magical part is that the AUTOLOAD function is
completely erased from the call stack, as if it had never been called;
when the real method returns, it returns not to AUTOLOAD, but to
wherever it was that called AUTOLOAD.
With this AUTOLOAD method in place, you can capitalize the names any
way you want, and all possible capitalizations will work; the names
will be completely case-insensitive. Saying
$obj->NaMe(...);
the first time will create and install a `NaMe' method which is
identical to the `name' method that exists already. Subsequent calls
to `NaMe' will go directly to `name'.
------------------------------
Date: Wed, 21 Oct 1998 14:05:58 GMT
From: dave@mag-sol.com
Subject: Re: Displaying the Time
Message-Id: <70kpo6$p19$1@nnrp1.dejanews.com>
In article <362E2EA2.41C6@strath.ac.uk>,
Gareth Ennis <gary.ennis@strath.ac.uk> wrote:
> Easy......
>
> I want to simply display the time and date in a logical format -
> (something like - 12:34 Tuesday 23 Oct 1998)
>
> I tried using -
> print localtime (time);
>
> but it prints out a whole range of numbers like :
>
> 1357112199832931
This is the list of values that localtime returns concaternated together. You
ran this example at 11:57:13 on Wednesday 21/10/98, the 293rd day of the year
(and in daylight savings time).
Print evaluates its arguments in a list context and localtime is happy to
supply them in that form. You may find it makes more sense if you impose a
scalar context on localtime.
print scalar localtime;
[n.b. localtime(time) is a tautology]
hth,
Dave...
--
dave@mag-sol.com
London Perl M[ou]ngers: <http://london.pm.org/>
[Note Changed URL]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 21 Oct 1998 15:28:15 -0700
From: Gareth Ennis <gary.ennis@strath.ac.uk>
To: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Displaying the Time
Message-Id: <362E5FFF.446B@strath.ac.uk>
> print scalar localtime(time);
>
> will generate:
> Wed Oct 21 07:34:01 1998
>
Perhaps something is set up wrong here... but the above does not
generate anything at all????
--
Gareth Ennis
ABACUS - Strathclyde University
email: gary.ennis@strath.ac.uk
http://iris.abacus.strath.ac.uk/new/
------------------------------
Date: 21 Oct 1998 15:55:04 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: gosdpads@yahoo.com (Danny Groppo)
Subject: Re: File locking question...
Message-Id: <m3ogr6dnpj.fsf@joshua.panix.com>
gosdpads@yahoo.com (Danny Groppo) writes:
> So, if write,
>
> sysopen(SOURCE, $path, O_WRONLY|O_APPEND|O_CREAT|O_EXLOCK);
>
> an exclusive lock will be made?
I can't answer that, but I can direct you to these resources (in case
you haven't already seen them):
% perldoc -f flock
% perldoc perlfaq5
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Wed, 21 Oct 1998 13:56:50 GMT
From: prakashpatel@hotmail.com
Subject: Help with subroutines
Message-Id: <70kp72$oa4$1@nnrp1.dejanews.com>
Mostly I use the cgi scripts to read in the form from the html file. So I
have few input fields in the form tag. Usually I put the part of the script
that takes the information of the line and seperates it. But now i want to
use a sub routine to do that and it doesn't work. I have created a file
called cgi-lib.pl which contains this:
sub form_method {
$method=$ENV{'REQUEST_METHOD'};
}
sub print_header {
if (!defined(@_)) {
print "Content-type: text/html\n\n";
}
else {
print "Location: @_\n\n";
}
}
sub parse_input { if (defined(@_)) { local(*input)=@_; } else {
local(*input)="*cgiinput"; } local ($temp,@pairs); if (&form_method eq
'POST') { read(STDIN,$temp,$ENV{'CONTENT_LENGTH'}); } else {
$temp=$ENV{'QUERY_STRING'}; } @pairs=split(/&/,$temp); foreach
$item(@pairs) { ($key,$content)=split (/=/,$item,2); $content=~tr/+/ /;
$content=~ s/%(..)/pack("c",hex($1))/ge; $input{$key}=$content; } return 1;
} ___________________________________________ I tried to use this sub
routine in my main cgi script which looks like this:
#!/usr/bin/perl
require ("cgi-lib.pl");
&parse_input(*fields);
&print_header;
dbmopen(%users,"users",0666) || die "Can't open users DBM file\n";
if (!defined($users{$fields{'email'}})) {
$users{$fields{'email'}}="$fields{'firstname'}::$fields{'last
print "Thanks for registering for our survey. Please remember to come
back
weekly to record your net use.";
}
else {
print "Someone has already registered from that e-mail address. Sorry.";
}
__________________________________________
I tried running it at the unix command as : perl test_sub.cgi
It gave me an error saying:
cgi-lib.pl did not return a true value at test_sub.cgi line 2.
Can someone pleas help me and tell me what's going on here.
Thank you
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 21 Oct 1998 13:57:05 GMT
From: prakashpatel@hotmail.com
Subject: Help with subroutines
Message-Id: <70kp7h$oa8$1@nnrp1.dejanews.com>
Mostly I use the cgi scripts to read in the form from the html file. So I
have few input fields in the form tag. Usually I put the part of the script
that takes the information of the line and seperates it. But now i want to
use a sub routine to do that and it doesn't work. I have created a file
called cgi-lib.pl which contains this:
sub form_method {
$method=$ENV{'REQUEST_METHOD'};
}
sub print_header {
if (!defined(@_)) {
print "Content-type: text/html\n\n";
}
else {
print "Location: @_\n\n";
}
}
sub parse_input { if (defined(@_)) { local(*input)=@_; } else {
local(*input)="*cgiinput"; } local ($temp,@pairs); if (&form_method eq
'POST') { read(STDIN,$temp,$ENV{'CONTENT_LENGTH'}); } else {
$temp=$ENV{'QUERY_STRING'}; } @pairs=split(/&/,$temp); foreach
$item(@pairs) { ($key,$content)=split (/=/,$item,2); $content=~tr/+/ /;
$content=~ s/%(..)/pack("c",hex($1))/ge; $input{$key}=$content; } return 1;
} ___________________________________________ I tried to use this sub
routine in my main cgi script which looks like this:
#!/usr/bin/perl
require ("cgi-lib.pl");
&parse_input(*fields);
&print_header;
dbmopen(%users,"users",0666) || die "Can't open users DBM file\n";
if (!defined($users{$fields{'email'}})) {
$users{$fields{'email'}}="$fields{'firstname'}::$fields{'last
print "Thanks for registering for our survey. Please remember to come
back
weekly to record your net use.";
}
else {
print "Someone has already registered from that e-mail address. Sorry.";
}
__________________________________________
I tried running it at the unix command as : perl test_sub.cgi
It gave me an error saying:
cgi-lib.pl did not return a true value at test_sub.cgi line 2.
Can someone pleas help me and tell me what's going on here.
Thank you
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 21 Oct 1998 13:33:56 GMT
From: flightwfy@aol.com (FlightWFY)
Subject: Re: Passing multiple arrays and hashes as parameter
Message-Id: <19981021093356.15424.00003749@ng100.aol.com>
Poon,
Are you sure you are using Perl 5.004 for HPUX ?. Perl 5.X supports
references and I have been using it to pass multiple arrays and hashes of
undetermined sizes to subroutines for a long time now. I am also with Intel. If
you like, you can call me at 554-4139 or email me at wyee@sedona.intel.com to
discuss this further.
------------------------------
Date: 21 Oct 1998 12:50:11 GMT
From: snowhare@devilbunnies.org (Snowhare)
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <70kla3$h5m$1@nnrp4.snfc21.pbi.net>
Nothing above this line is part of the signed message.
In article <70kgpc$e4b$1@nnrp1.dejanews.com>, <finsol@ts.co.nz> wrote:
>I posted a link in an earlier thread on this topic - unfortunately the link
>was changed & the article referenced had nothing to do with Perl - it did
>spark off an lively discussion however!
>
>The correct link for this article (unless they change it again!) is:
>http://www.idg.co.nz/WWWfeat/Y2000/amon1010.htm
I concur with the basic premise. And it is _very_ applicable to Perl.
It wasn't until the Blue Camel came out that the reference book stated
that localtime returns the year - 1900. The Pink Camel states
something like "comes straight out of a tm struct (That's a bit
of C programming lingo - don't worry about it.)" (pg 160) :O
Benjamin Franz
Version: 2.6.2
iQCVAwUBNi3aBOjpikN3V52xAQEYkQQApcKejx3/EdwKRCKT7jaWNRZ0thrwaX6d
BxY/LI3/tAdCBLNUssO1he3M8FjzzH0Fy1zE6q2FpobsU6VaZ5EYOpazGOqrZWnT
hkDe9pzf2omAJfa8uf+uD3PvUu0iJnCe+yRzr8dpatigYDkc8UKtk4DB2lbOhp20
OjXE36TKAh4=
=z6eb
-----END PGP SIGNATURE-----
------------------------------
Date: 21 Oct 1998 09:27:52 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <70kngo$aic$1@pilot.njin.net>
You know, they say that capital letters mean you're shouting. Well, in
eight+ years of Usenet participation I've never done it. However....
WE KNOW ABOUT THIS. IT'S BEEN TALKED ABOUT A MILLION TIMES. THERE
IS NO "BOOBY TRAP" IN PERL. THERE IS NO SECRET. IF YOU CAN'T ADD 1900
TO A NUMBER THEN UNPLUG YOUR COMPUTER AND DO SOMETHING ELSE WITH
YOUR TIME.
Love,
David Black
dblack@pilot.njin.net
snowhare@devilbunnies.org (Snowhare) writes:
>In article <70kgpc$e4b$1@nnrp1.dejanews.com>, <finsol@ts.co.nz> wrote:
>>I posted a link in an earlier thread on this topic - unfortunately the link
>>was changed & the article referenced had nothing to do with Perl - it did
>>spark off an lively discussion however!
>>
>>The correct link for this article (unless they change it again!) is:
>>http://www.idg.co.nz/WWWfeat/Y2000/amon1010.htm
>I concur with the basic premise. And it is _very_ applicable to Perl.
>It wasn't until the Blue Camel came out that the reference book stated
>that localtime returns the year - 1900. The Pink Camel states
>something like "comes straight out of a tm struct (That's a bit
>of C programming lingo - don't worry about it.)" (pg 160) :O
>Benjamin Franz
------------------------------
Date: Wed, 21 Oct 1998 14:14:37 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <8c1zo2t321.fsf@gadget.cscaper.com>
>>>>> "finsol" == finsol <finsol@ts.co.nz> writes:
finsol> I posted a link in an earlier thread on this topic -
finsol> unfortunately the link was changed & the article referenced
finsol> had nothing to do with Perl - it did spark off an lively
finsol> discussion however!
finsol> The correct link for this article (unless they change it again!) is:
finsol> http://www.idg.co.nz/WWWfeat/Y2000/amon1010.htm
Bogus bogus BOGUS.
Geez. I get quite irate when I see sloppy writing like the following:
quote> Perl, MacPerl, CGI using localtime
quote> [...]
quote> One of the booby-trap languages listed is MacPerl, a language
quote> used on Apple Macintosh computers. While it is true that Apple
quote> hardware does not have the same internal clock problems as the
quote> industry standard PCs, any software is just as likely to have
quote> year 2000 software problems. MacPerl applications are just as
quote> likely to be booby-trapped as applications written in the
quote> other affected languages.
There is nothing WRONG with MacPerl, or any other flavor of Perl.
localtime() and gmtime() have *always* returned year - 1900 starting
with perl version 0. And was documented as such.
If a sloppy programmer wrote "19$year" instead of ($year + 1900),
that's *their* fault. STOP BLAMING PERL.
We can give yoy a pocket chainsaw. We cannot keep you from
sawing your arm off from it.
STOP BLAMING PERL.
STOP PROPOGATING NONSENSE.
<sigh>
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Wed, 21 Oct 1998 07:09:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <MPG.10978aecc09d0fe69898d7@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <70kla3$h5m$1@nnrp4.snfc21.pbi.net> on 21 Oct 1998 12:50:11
GMT, Snowhare <snowhare@devilbunnies.org> says...
...
> I concur with the basic premise. And it is _very_ applicable to Perl.
> It wasn't until the Blue Camel came out that the reference book stated
> that localtime returns the year - 1900. The Pink Camel states
> something like "comes straight out of a tm struct (That's a bit
> of C programming lingo - don't worry about it.)" (pg 160) :O
However, the C documentation for 'struct tm' has *always* stated clearly
that the year value was 'years since 1900'. So the right answer was
always just one little indirection away. :-)
The article <URL:http://www.idg.co.nz/WWWfeat/Y2000/amon1010.htm> is a
good summary. I can summarize it even more succinctly:
The only valid uses of $year {from ((gm|local)time)[5]} are
1900 + $year
or
$year % 100
I have predicted already that the latter is the bug that will bite the
more.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 21 Oct 1998 14:18:57 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <8cww5uroad.fsf@gadget.cscaper.com>
>>>>> "Snowhare" == Snowhare <snowhare@devilbunnies.org> writes:
Snowhare> I concur with the basic premise. And it is _very_ applicable
Snowhare> to Perl. It wasn't until the Blue Camel came out that the
Snowhare> reference book stated that localtime returns the year -
Snowhare> 1900. The Pink Camel states something like "comes straight
Snowhare> out of a tm struct (That's a bit of C programming lingo -
Snowhare> don't worry about it.)" (pg 160) :O
Bulloney. Nonsense. "straight out of a tm struct" was completely
apropos to the audience of the Pink camel... other Unix hackers that
knew C. And nearly all of them were trusted to be able to type "man
localtime" to get the details.
The Blue camel was aimed a different (wider) audience, hence the
change in wording.
There was *nothing* wrong with the Pink camel's description. If I
read a book on brain surgery, I do *not* expect the book to describe
basic suture techniques, even though without that, the book is useless
to me. Books are written to a *specific* audience.
<sigh>
Of course, maybe I should do like others and just killfile anything in
CLPM with "Y2K" in it. That'd make my life easier.
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Wed, 21 Oct 1998 13:32:37 GMT
From: dturley@pobox.com
Subject: Re: Perl Modulus operator unreliable? Help!!
Message-Id: <70knpl$m77$1@nnrp1.dejanews.com>
In article <362d0f58$0$12421@nntp1.ba.best.com>,
arzachel@best.spamazoid.com (Jason Witherspoon) wrote:
> It's a little backwards, but surely you can see the problem. Is the
> modulus operator simply unreliable? It seems to work okay for smaller
> numbers, but I have no clue how Perl explains the above w/Boolean
> logic.
What is $price equal to? The modulus operator does not work with floating
point numbers. You need to use the fmod() function in the POSIX module.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 21 Oct 1998 13:36:21 GMT
From: Bill Walker <bw@cs3.ecok.EDU>
Subject: Re: Perl, dynamic loading, SCO OS 5
Message-Id: <70ko0l$b9r$1@sunhub-tulsa.onenet.net>
In comp.unix.sco.misc Peter Eckhardt <Peter.Eckhardt@transcom.de> wrote:
> Bill Walker schrieb:
> >
> > In comp.unix.sco.misc Peter Eckhardt <Peter.Eckhardt@transcom.de> wrote:
> > > Dynamic Loading works nicely. I will send you an e-mail
> > > with the config.
> >
> > Would you consider just posting it ? I doubt it is very long, and I
> > suspect there is a lot of interest.
> >
> > 73 de Bill W5GFE
> Here is it. Be aware it's tweaked in different places to fit
Worked like a charm. I had to move Fcntl and the DBM stuff to
be statically linked, but your config.sh created a dynamically
loading Perl -- first try, and it passes all of the supplied
tests.
FYI, here is my config.sh, with the Fcntl stuff moved.
(This is for perl 5.005_02 BTW)
73 de Bill W5GFE
--------------------- cut here ---------------
#!/bin/sh
#
# This file was produced by running the Configure script. It holds all the
# definitions figured out by Configure. Should you modify one of these values,
# do not forget to propagate your changes by running "Configure -der". You may
# instead choose to run each of the .SH files by yourself, or "Configure -S".
#
# Package name : perl5
# Source directory : .
# Configuration time: Wed Oct 21 06:23:37 CDT 1998
# Configured by : bw
# Target system : sco_sv cs3 3.2 2 i386
Author=''
Date='$Date'
Header=''
Id='$Id'
Locker=''
Log='$Log'
Mcc='Mcc'
RCSfile='$RCSfile'
Revision='$Revision'
Source=''
State=''
_a='.a'
_exe=''
_o='.o'
afs='false'
alignbytes='4'
ansi2knr=''
aphostname=''
apiversion='5.005'
ar='ar'
archlib='/usr/local/lib/perl5/5.00502/i386-sco_sv'
archlibexp='/usr/local/lib/perl5/5.00502/i386-sco_sv'
archname='i386-sco_sv'
archobjs=''
awk='awk'
baserev='5.0'
bash=''
bin='/usr/local/bin'
binexp='/usr/local/bin'
bison=''
byacc='byacc'
byteorder='1234'
c='\c'
castflags='0'
cat='cat'
cc='cc'
cccdlflags=' '
ccdlflags='-belf -W l,-Bexport '
ccflags='-belf -w0 -U M_XENIX -DPERL_SCO5 -I/usr/local/include'
cf_by='bw'
cf_email='bw@cs3.ecok.edu'
cf_time='Wed Oct 21 06:23:37 CDT 1998'
chgrp=''
chmod=''
chown=''
clocktype='clock_t'
comm='comm'
compress=''
contains='grep'
cp='cp'
cpio=''
cpp='cpp'
cpp_stuff='42'
cppflags='-belf -w0 -U M_XENIX -DPERL_SCO5 -I/usr/local/include'
cpplast='-'
cppminus='-'
cpprun='cc -E'
cppstdin='cc -E'
cryptlib=''
csh='csh'
d_Gconvert='gcvt((x),(n),(b))'
d_access='define'
d_alarm='define'
d_archlib='define'
d_attribut='undef'
d_bcmp='define'
d_bcopy='define'
d_bsd='define'
d_bsdgetpgrp='undef'
d_bsdsetpgrp='undef'
d_bzero='define'
d_casti32='undef'
d_castneg='define'
d_charvspr='undef'
d_chown='define'
d_chroot='define'
d_chsize='define'
d_closedir='define'
d_const='define'
d_crypt='define'
d_csh='define'
d_cuserid='define'
d_dbl_dig='define'
d_difftime='define'
d_dirnamlen='undef'
d_dlerror='undef'
d_dlopen='undef'
d_dlsymun='undef'
d_dosuid='undef'
d_dup2='define'
d_endgrent='define'
d_endhent='define'
d_endnent='define'
d_endpent='define'
d_endpwent='define'
d_endsent='define'
d_eofnblk='define'
d_eunice='undef'
d_fchmod='define'
d_fchown='define'
d_fcntl='define'
d_fd_macros='define'
d_fd_set='define'
d_fds_bits='define'
d_fgetpos='define'
d_flexfnam='define'
d_flock='undef'
d_fork='define'
d_fpathconf='define'
d_fsetpos='define'
d_ftime='undef'
d_getgrent='define'
d_getgrps='define'
d_gethbyaddr='define'
d_gethbyname='define'
d_gethent='define'
d_gethname='undef'
d_gethostprotos='undef'
d_getlogin='define'
d_getnbyaddr='define'
d_getnbyname='define'
d_getnent='define'
d_getnetprotos='define'
d_getpbyname='define'
d_getpbynumber='define'
d_getpent='define'
d_getpgid='define'
d_getpgrp2='undef'
d_getpgrp='define'
d_getppid='define'
d_getprior='define'
d_getprotoprotos='define'
d_getpwent='define'
d_getsbyname='define'
d_getsbyport='define'
d_getsent='define'
d_getservprotos='define'
d_gettimeod='define'
d_gnulibc='undef'
d_grpasswd='define'
d_htonl='define'
d_index='undef'
d_inetaton='define'
d_isascii='define'
d_killpg='define'
d_lchown='define'
d_link='define'
d_locconv='define'
d_lockf='define'
d_longdbl='define'
d_longlong='undef'
d_lstat='define'
d_mblen='define'
d_mbstowcs='define'
d_mbtowc='define'
d_memcmp='define'
d_memcpy='define'
d_memmove='define'
d_memset='define'
d_mkdir='define'
d_mkfifo='define'
d_mktime='define'
d_msg='define'
d_msgctl='define'
d_msgget='define'
d_msgrcv='define'
d_msgsnd='define'
d_mymalloc='define'
d_nice='define'
d_oldpthreads='undef'
d_oldsock='undef'
d_open3='define'
d_pathconf='define'
d_pause='define'
d_phostname='undef'
d_pipe='define'
d_poll='define'
d_portable='define'
d_pthread_yield='undef'
d_pthreads_created_joinable='undef'
d_pwage='define'
d_pwchange='undef'
d_pwclass='undef'
d_pwcomment='define'
d_pwexpire='undef'
d_pwgecos='define'
d_pwquota='undef'
d_pwpasswd='define'
d_readdir='define'
d_readlink='define'
d_rename='define'
d_rewinddir='define'
d_rmdir='define'
d_safebcpy='define'
d_safemcpy='undef'
d_sanemcmp='define'
d_sched_yield='undef'
d_seekdir='define'
d_select='define'
d_sem='define'
d_semctl='define'
d_semctl_semid_ds='define'
d_semctl_semun='define'
d_semget='define'
d_semop='define'
d_setegid='define'
d_seteuid='define'
d_setgrent='define'
d_setgrps='define'
d_sethent='define'
d_setlinebuf='undef'
d_setlocale='define'
d_setnent='define'
d_setpent='define'
d_setpgid='define'
d_setpgrp2='undef'
d_setpgrp='define'
d_setprior='define'
d_setpwent='define'
d_setregid='define'
d_setresgid='undef'
d_setresuid='undef'
d_setreuid='define'
d_setrgid='undef'
d_setruid='undef'
d_setsent='define'
d_setsid='define'
d_setvbuf='define'
d_sfio='undef'
d_shm='define'
d_shmat='define'
d_shmatprototype='define'
d_shmctl='define'
d_shmdt='define'
d_shmget='define'
d_sigaction='define'
d_sigsetjmp='define'
d_socket='define'
d_sockpair='define'
d_statblks='define'
d_stdio_cnt_lval='undef'
d_stdio_ptr_lval='undef'
d_stdiobase='undef'
d_stdstdio='undef'
d_strchr='define'
d_strcoll='define'
d_strctcpy='define'
d_strerrm='strerror(e)'
d_strerror='define'
d_strtod='define'
d_strtol='define'
d_strtoul='define'
d_strxfrm='define'
d_suidsafe='undef'
d_symlink='define'
d_syscall='define'
d_sysconf='define'
d_sysernlst=''
d_syserrlst='define'
d_system='define'
d_tcgetpgrp='define'
d_tcsetpgrp='define'
d_telldir='define'
d_time='define'
d_times='define'
d_truncate='define'
d_tzname='define'
d_umask='define'
d_uname='define'
d_union_semun='undef'
d_vfork='undef'
d_void_closedir='undef'
d_voidsig='define'
d_voidtty=''
d_volatile='define'
d_vprintf='define'
d_wait4='undef'
d_waitpid='define'
d_wcstombs='define'
d_wctomb='define'
d_xenix='undef'
date='date'
db_hashtype='u_int32_t'
db_prefixtype='size_t'
defvoidused='15'
direntrytype='struct dirent'
dlext='so'
dlsrc='dl_dlopen.xs'
doublesize='8'
dynamic_ext='B Data/Dumper IPC/SysV POSIX Socket attrs re IO Opcode'
eagain='EAGAIN'
ebcdic='undef'
echo='echo'
egrep='egrep'
emacs=''
eunicefix=':'
exe_ext=''
expr='expr'
extensions='B Data/Dumper IPC/SysV POSIX Socket attrs re IO Opcode Fcntl GDBM_File NDBM_File ODBM_File SDBM_File Errno'
find='find'
firstmakefile='makefile'
flex=''
fpostype='fpos_t'
freetype='void'
full_csh='/bin/csh'
full_sed='/bin/sed'
gccversion=''
gidtype='gid_t'
glibpth='/usr/shlib /shlib /lib/pa1.1 /usr/lib/large /lib /usr/lib /lib/large /usr/lib/small /lib/small /usr/ccs/lib /usr/ucblib /usr/local/lib'
grep='grep'
groupcat='cat /etc/group'
groupstype='gid_t'
gzip='gzip'
h_fcntl='true'
h_sysfile='false'
hint='previous'
hostcat='cat /etc/hosts'
huge=''
i_arpainet='define'
i_bsdioctl=''
i_db='undef'
i_dbm='define'
i_dirent='define'
i_dld='undef'
i_dlfcn='define'
i_fcntl='define'
i_float='define'
i_gdbm='define'
i_grp='define'
i_limits='define'
i_locale='define'
i_malloc='define'
i_math='define'
i_memory='undef'
i_ndbm='define'
i_netdb='define'
i_neterrno='undef'
i_niin='define'
i_pwd='define'
i_rpcsvcdbm='undef'
i_sfio='undef'
i_sgtty='undef'
i_stdarg='define'
i_stddef='define'
i_stdlib='define'
i_string='define'
i_sysdir='define'
i_sysfile='undef'
i_sysfilio='undef'
i_sysin='undef'
i_sysioctl='define'
i_sysndir='undef'
i_sysparam='define'
i_sysresrc='define'
i_sysselct='undef'
i_syssockio=''
i_sysstat='define'
i_systime='define'
i_systimek='undef'
i_systimes='define'
i_systypes='define'
i_sysun='define'
i_syswait='define'
i_termio='undef'
i_termios='define'
i_time='define'
i_unistd='define'
i_utime='define'
i_values='define'
i_varargs='undef'
i_varhdr='stdarg.h'
i_vfork='undef'
incpath=''
inews=''
installarchlib='/usr/local/lib/perl5/5.00502/i386-sco_sv'
installbin='/usr/local/bin'
installman1dir=''
installman3dir=''
installprivlib='/usr/local/lib/perl5/5.00502'
installscript='/usr/local/bin'
installsitearch='/usr/local/lib/perl5/site_perl/5.005/i386-sco_sv'
installsitelib='/usr/local/lib/perl5/site_perl/5.005'
intsize='4'
known_extensions='B DB_File Data/Dumper Fcntl GDBM_File IO IPC/SysV NDBM_File ODBM_File Opcode POSIX SDBM_File Socket Thread attrs re'
ksh=''
large=''
ld='ld'
lddlflags='-G -L/usr/local/lib -L/usr/local/bind/lib -belf'
ldflags=' -L/usr/local/lib'
less='less'
lib_ext='.a'
libc=''
libperl='libperl.a'
libpth='/usr/local/lib /shlib /lib /usr/lib /usr/ccs/lib'
libs='-lintl -lsocket -lnsl -lndbm -lgdbm -ldbm -lld -lm -lc -lcrypt -lPW -lx -lc_s'
libswanted='intl sfio socket inet nsl nm ndbm gdbm dbm db malloc dld ld sun m c cposix posix ndir dir crypt ucb bsd BSD PW x'
line='line'
lint=''
lkflags=''
ln='ln'
lns='/bin/ln -s'
locincpth='/usr/local/include /opt/local/include /usr/gnu/include /opt/gnu/include /usr/GNU/include /opt/GNU/include'
loclibpth='/usr/local/lib /opt/local/lib /usr/gnu/lib /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib'
longdblsize='12'
longlongsize=''
longsize='4'
lp=''
lpr=''
ls='ls'
lseektype='off_t'
mail=''
mailx=''
make='make'
make_set_make='#'
mallocobj='malloc.o'
mallocsrc='malloc.c'
malloctype='void *'
man1dir=' '
man1direxp=''
man1ext='0'
man3dir=' '
man3direxp=''
man3ext='0'
medium=''
mips=''
mips_type=''
mkdir='mkdir'
models='none'
modetype='mode_t'
more='more'
mv=''
myarchname='i386-sco_sv'
mydomain='.ecok.edu'
myhostname='cs3'
myuname='sco_sv cs3 3.2 2 i386 '
n=''
netdb_hlen_type='int'
netdb_host_type='const char *'
netdb_name_type='const char *'
netdb_net_type='unsigned long'
nm='nm'
nm_opt='-p'
nm_so_opt=''
nonxs_ext='Errno'
nroff='nroff'
o_nonblock='O_NONBLOCK'
obj_ext='.o'
optimize=' '
orderlib='false'
osname='sco_sv'
osvers='3.2'
package='perl5'
pager='/usr/local/bin/less'
passcat='cat /etc/passwd'
patchlevel='5'
path_sep=':'
perl='perl'
perladmin='bw@cs3.ecok.edu'
perlpath='/usr/local/bin/perl'
pg='pg'
phostname='hostname'
pidtype='pid_t'
plibpth=''
pmake=''
pr=''
prefix='/usr/local'
prefixexp='/usr/local'
privlib='/usr/local/lib/perl5/5.00502'
privlibexp='/usr/local/lib/perl5/5.00502'
prototype='define'
ptrsize='4'
randbits='15'
ranlib=':'
rd_nodata='-1'
rm='rm'
rmail=''
runnm='false'
scriptdir='/usr/local/bin'
scriptdirexp='/usr/local/bin'
sed='sed'
selecttype='fd_set *'
sendmail='sendmail'
sh='/bin/sh'
shar=''
sharpbang='#!'
shmattype='void *'
shortsize='2'
shrpenv=''
shsharp='true'
sig_name='ZERO HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM USR1 USR2 CHLD PWR WINCH NUM21 POLL STOP TSTP CONT TTIN TTOU VTALRM PROF XCPU XFSZ IOT CLD '
sig_name_init='"ZERO", "HUP", "INT", "QUIT", "ILL", "TRAP", "ABRT", "EMT", "FPE", "KILL", "BUS", "SEGV", "SYS", "PIPE", "ALRM", "TERM", "USR1", "USR2", "CHLD", "PWR", "WINCH", "NUM21", "POLL", "STOP", "TSTP", "CONT", "TTIN", "TTOU", "VTALRM", "PROF", "XCPU", "XFSZ", "IOT", "CLD", 0'
sig_num='0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 6, 18, 0'
signal_t='void'
sitearch='/usr/local/lib/perl5/site_perl/5.005/i386-sco_sv'
sitearchexp='/usr/local/lib/perl5/site_perl/5.005/i386-sco_sv'
sitelib='/usr/local/lib/perl5/site_perl/5.005'
sitelibexp='/usr/local/lib/perl5/site_perl/5.005'
sizetype='size_t'
sleep=''
smail=''
small=''
so='so'
sockethdr=''
socketlib=''
sort='sort'
spackage='Perl5'
spitshell='cat'
split=''
src='.'
ssizetype='ssize_t'
startperl='#!/usr/local/bin/perl'
startsh='#!/bin/sh'
static_ext='Fcntl GDBM_File NDBM_File ODBM_File SDBM_File'
stdchar='unsigned char'
stdio_base='((fp)->_base)'
stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)'
stdio_cnt='((fp)->_cnt)'
stdio_filbuf=''
stdio_ptr='((fp)->_ptr)'
strings='/usr/include/string.h'
submit=''
subversion='2'
sysman='/usr/catman/u_man/man1'
tail=''
tar=''
tbl=''
tee='tee'
test='test'
timeincl='/usr/include/sys/time.h /usr/include/time.h '
timetype='time_t'
touch='touch'
tr='tr'
trnl='\n'
troff=''
uidtype='uid_t'
uname='uname'
uniq='uniq'
usedl='define'
usemymalloc='y'
usenm='false'
useopcode='true'
useperlio='undef'
useposix='true'
usesfio='false'
useshrplib='false'
usethreads='undef'
usevfork='false'
usrinc='/usr/include'
uuname=''
version='5.00502'
vi=''
voidflags='15'
xlibpth=''
zcat=''
zip='zip'
# Configure command line arguments.
config_arg0='./Configure'
config_args=''
config_argc=0
PATCHLEVEL=5
SUBVERSION=2
CONFIG=true
# Variables propagated from previous config.sh file.
config_arg1='-der'
------------------------------
Date: Wed, 21 Oct 1998 14:10:26 GMT
From: hyytiainen@edu.h4thol.fi
Subject: Problem with perl scripts...
Message-Id: <70kq0i$p52$1@nnrp1.dejanews.com>
So I decided to ask for help...
I4ve had a problem with my cgi scripts...
Every time I try to execute any script, attempt results with this kind of
message...
-------------------------------------------------------------------------
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to
complete your request.
Please contact the server administrator, and inform them of the time the
error occurred, and anything you might have done that may have caused the
error.
_________________________________________________________________________
Or when I tried to call a script from html page, it didn4t write anything.
Okay! So I seeked a problem without finding it and decice to try with a script
as simple as possible.
_________________________________________________________________________
#!/usr/local/bin/perl
#
# hello world
#
print 'Hello world./n/n';
_________________________________________________________________________
And I tried to call it like this:
_________________________________________________________________________
Content-type: text/html
<html>
<head><title>testing</title></head>
<body>
<center>
<!--VirtualAvenueBanner-->
<!--#exec cgi=/cgi-bin/simple.pl-->
</center>
</body>
</html>
_________________________________________________________________________
And nothing....
I can4t figure out what is wrong... Can you?
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 21 Oct 1998 14:22:31 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: read main::DATA multiple
Message-Id: <8csogiro4f.fsf@gadget.cscaper.com>
>>>>> "Hartmut" == Hartmut Palm <palm@gfz-potsdam.de> writes:
Hartmut> How to read main::DATA multiple. I can't reopen/rewind __DATA__. With "tell"
Hartmut> and "seek" there is a difference of 20 bytes first time.
This works fine for me:
#!/usr/bin/perl
$where = tell(DATA);
print "the first time:\n", <DATA>;
seek(DATA,$where,0);
print "The second time:\n", <DATA>;
__END__
Here is
some data!
Ho ho!
What version/arch of perl are you using?
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
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 4031
**************************************