[9031] in Perl-Users-Digest
Perl-Users Digest, Issue: 2649 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 20 15:07:38 1998
Date: Wed, 20 May 98 12:00:55 -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, 20 May 1998 Volume: 8 Number: 2649
Today's topics:
Re: Authentication?? (brian d foy)
AutoLoader/SelfLoader/other techniques <thomson@zinger.adp.wisc.edu>
Re: Benchmark: Adding to the end of string <jdf@pobox.com>
Re: Benchmark: Fastest way to read a file (John Porter)
Re: Benchmark: local filehandle vs. Filehandle.pm <jay@rgrs.com>
Re: Benchmark: pre-extending array? <jdf@pobox.com>
Re: Benchmark: pre-extending array? (Earl Hood)
case insensitive checks, a=b David@iqtexas.com
Re: case insensitive checks, a=b <jdf@pobox.com>
Re: case insensitive checks, a=b (brian d foy)
Credit card help (HUBRIS3)
email access through the web redpeppa@my-dejanews.com
Flushing STDIN before read? (Paul D. Smith)
Re: Function syntax with prototyping, filehandles and a (Marc Haber)
Re: generating hash of complex records (Kevin Reid)
IN NEED OF AN EXAMPLE OF USING Win32::Registry qvanegeren@frxsoft.com
Re: Inter-process file arbitration? <merlyn@stonehenge.com>
Re: Inter-process file arbitration? (Mark-Jason Dominus)
Re: Inter-process file arbitration? (Mark-Jason Dominus)
Re: Newbie cgi question markq@nerds-at-work.com
Re: Non-static private variables (Ilya Zakharevich)
Re: Perl 5.0 map operator (brian d foy)
Perl and C-ISAM Informix <regis.julie@capway.com>
Re: perl and html ?? (Brian Lavender)
Re: Perl Help (Mark-Jason Dominus)
Re: Perl to 'C' interface (Ken Fox)
Problems with Sys::Syslog <william2@wdni.com>
Re: regexp for strings of chars (Ilya Zakharevich)
Re: Sendmail to alias from Perl CGI script? <mahmed@dkl.com>
Re: Software vendor liability [Was: Does Perl have a ID (Ken Fox)
Re: uniq command or module for perl?? (John Porter)
What's wrong with this OO perl? <bjs@iti-oh.com>
Re: What's wrong with this OO perl? (Mark-Jason Dominus)
Re: What's wrong with this OO perl? (Chris Nandor)
Where is warning about PERL 5.001? (Brian Lavender)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 20 May 1998 13:59:44 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Authentication??
Message-Id: <comdog-ya02408000R2005981359440001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6jt9el$kvu$1@monet.op.net>, mjd@op.net (Mark-Jason Dominus) posted:
>In article <35608B06.6C6C474D@Compuserve.com>,
>Mark Sage <Mark_Sage@Compuserve.com> wrote:
>>I am trying to get a PERL program to display a user/password dialog, and
>>then process the input. I can make the dialog display by sending a
>>"HTTP/1.0 404 Not Authorized", but no matter what I do I cannot get
>>anything returned.
>
>Typically, the web server will not give you the credentials, because
>doing so would create a possible security problem.
>
>The solution (if there is one) depends on your web server. It will
>involve recompiling or reconfiguring the server, or putting a hook
>into the API, or something. Whatever it is, it's not appropriate for
>this newsgroup; please ask in the group about your server, whatever
>that is.
well, in servers compiled with mod_perl you could hook into the Apache
API at just about anywhere - which seems completely relevant to this
group, if that's what he wants to talk about that :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers T-shirts! <URL:http://www.pm.org/tshirts.html>
------------------------------
Date: 20 May 1998 12:35:55 -0500
From: Don Thomson <thomson@zinger.adp.wisc.edu>
Subject: AutoLoader/SelfLoader/other techniques
Message-Id: <tzlnrwvo90.fsf@zinger.adp.wisc.edu>
I'm writing a large module that implements a class and am considering
different ways to have it load at runtime only those methods that are
used rather than compiling the whole thing. The AutoLoader and
SelfLoader man pages each discuss the advantages and disadvantages of
one over the other, for instance the following for SelfLoader:
SelfLoader suffers a startup speed disadvantage in the one-
time parsing of the lines after __DATA__, after which
routines are cached.
There is a maintainance gain in not needing to run AutoSplit on the
module at installation, and a runtime gain in not needing to keep
opening and closing files to load subs. There is a runtime loss in
needing to parse the code after the __DATA__.
and the following for AutoLoader:
AutoLoader only reads code as it is requested, and in many
cases should be faster, but requires a machanism like
AutoSplit be used to create the individual files.
I'm not concerned about having to use AutoSplit. The other factors are
hard to weigh abstractly, so I suppose I'll try each and then benchmark
them.
But then I see that the author of CGI.pm doesn't use either, preferring
to load at runtime routines packaged in something along the lines of:
$AUTOLOADED_ROUTINES=<<'END_OF_AUTOLOAD';
%SUBS = (
'ReadParse' => <<'END_OF_FUNC',
sub ReadParse {
(body of ReadParse here)
}
END_OF_FUNC
);
END_OF_AUTOLOAD
I'm going to be browsing though other folks' code to see what other
techniques have been invented. But if anyone has any comments from
their own experience on relative merits and disadvantages of any of
these techniques (or others) other than what's mentioned above, I'd be
interested in hearing them. Thanks!
--
----- Don Thomson ----- DoIT (Division of Information Technology) -------
thomson@doit.wisc.edu (608) 262-0007 1210 W. Dayton, Madison, WI 53706
------------------------------
Date: 20 May 1998 13:32:24 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Re: Benchmark: Adding to the end of string
Message-Id: <u36k6bev.fsf@mailhost.panix.com>
<jari.aalto@poboxes.com> (Jari Aalto+mail.perl) writes:
> These all add "a" to the end of existing variable.
No, they don't:
> c => 'my $a; for (1..100) { $a = "$a a" }'
This effectively appends ' a' to the string, not 'a'.
> d => 'my $a; for (1..100) { substr($a,0,0) = "a" }'
This prepends 'a' to the string (adds it to the beginning).
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: Wed, 20 May 1998 16:59:20 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Benchmark: Fastest way to read a file
Message-Id: <MPG.fccd767ebf7c6a99896dd@news.min.net>
On 20 May 1998 18:19:14 +0300,
in article <tblnrxq8b1.fsf@blue.sea.net>,
jari.aalto@poboxes.com (jari.aalto@poboxes.com) wrote:
>
> Not long ago someone suggested that slurping a file to a string
> by undeffing $/ would be the fastest way, but I can't see any
> difference in the timings. They seem all equally fast. 5.004_04
>...
> timethese( 10_000,
> {
> a => '
> open F, "test.txt"; @file = <F>; close F'
> ,
> b => '
> $/ = undef;
> open F, "test.txt"; @file = split /\n/,<F>; close F'
> ,
> c => '
> $/ = undef;
> open F, "test.txt"; $file = <F>; close F'
> });
>
> a: 16 secs ( 2.37 usr 5.37 sys = 7.74 cpu)
> b: 16 secs ( 2.77 usr 5.49 sys = 8.26 cpu)
> c: 16 secs ( 2.14 usr 5.39 sys = 7.53 cpu)
These tests are not testing what you think -- they're mostly
testing the overhead you don't care about, not the actual reading
of input data. You want to read a file with lots of lines,
rather than repeating the same short test many times.
my $filename = 'length08.txt'; # contains about 150,000 lines
my $n = 1;
use Benchmark;
sub slurping {
local $/;
open F, $filename;
my @f = <F>; # gets one big string
close F;
\@f;
}
sub by_lines {
open F, $filename;
my @f = <F>;
close F;
\@f;
}
timethese( $n,
{
slurping => \&slurping,
by_lines => \&by_lines,
}
);
Benchmark: timing 1 iterations of by_lines, slurping...
slurping: 6 secs ( 0.53 usr 0.99 sys = 1.52 cpu)
by_lines: 36 secs ( 7.51 usr 4.36 sys = 11.87 cpu)
(warnings deleted.)
John Porter
------------------------------
Date: 20 May 1998 13:59:19 -0400
From: Jay Rogers <jay@rgrs.com>
To: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Re: Benchmark: local filehandle vs. Filehandle.pm
Message-Id: <82emxoombs.fsf@shell2.shore.net>
<jari.aalto@poboxes.com> (Jari Aalto+mail.perl) writes:
> After seeing the discussion about the slowness of Filehandle
> package I wanted to see just how slow it would make code.
...
>
> timethese( 100,
> {
> a => '
> use FileHandle;
> my $file = "/etc/passwd";
> for (1..100)
> {
> my $FH = new FileHandle;
> open $FH, $file;
> }'
> ,
> b => '
> my $file = "/etc/passwd";
> for (1..100)
> {
> local *FH;
> open FH, $file;
> close FH;
> }'
> });
>
> a: 27 secs (15.77 usr 10.95 sys = 26.72 cpu)
> b: 84 secs (68.53 usr 14.55 sys = 83.08 cpu)
Hmmm... when I run this on a sparc ultra-2 I get results that support
the opposite, that is *FH being faster than FileHandle->new()
Benchmark: timing 100 iterations of a, b...
a: 3 secs ( 2.02 usr 0.63 sys = 2.65 cpu)
b: 1 secs ( 0.55 usr 0.46 sys = 1.01 cpu)
Even so, that benchmark is only going to load the files needed by
FileHandle once.
The point of the thread started by Nate was that if you just need a
unique filehandle then FileHandle and its alter ego IO::File may be
overkill because of all the stuff that gets loaded.
Forcing those files to get loaded again on each Benchmark iteration is
probably more representative and more strongly shows the benefit of *FH
use Benchmark qw(timethese);
%Keep = map { $_ => 1 } keys %INC;
sub rm_modules {
for (keys %INC) {
delete $INC{$_} unless $Keep{$_};
}
}
timethese(100,
{
a => '
&rm_modules();
require FileHandle;
my $file = "/etc/passwd";
for (1..100) {
my $FH = new FileHandle;
open $FH, $file;
}',
b => '
&rm_modules();
my $file = "/etc/passwd";
for (1..100) {
local *FH;
open FH, $file;
close FH;
}',
});
Benchmark: timing 100 iterations of a, b...
a: 14 secs ( 9.15 usr 1.95 sys = 11.10 cpu)
b: 1 secs ( 0.65 usr 0.40 sys = 1.05 cpu)
--
Jay Rogers
jay@rgrs.com
------------------------------
Date: 20 May 1998 13:43:54 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Re: Benchmark: pre-extending array?
Message-Id: <ra1o6avp.fsf@mailhost.panix.com>
<jari.aalto@poboxes.com> (Jari Aalto+mail.perl) writes:
> my $i = 0;
> for (1..100)
Why not
for (my $i = 0; $i < 100; $i++)
which doesn't build a temp list?
> $a[$i] = "1";
> $i++;
> }
> @a[0..$i]'
This is a bug, as $i is worth one more than the last meaningful index
into your array.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: 20 May 1998 17:12:16 GMT
From: ehood@geneva.acs.uci.edu (Earl Hood)
Subject: Re: Benchmark: pre-extending array?
Message-Id: <6jv2tg$241@news.service.uci.edu>
[mail & posted]
In article <MPG.fcccef5285fe50d9896d9@news.min.net>,
John Porter <jdporter@min.net> wrote:
>sub pushing {
> my $c = 1;
> my @a;
> for (1..$size) {
> $c ||= $_;
> push @a, undef;
> }
> \@a;
>}
>
>sub extending {
> my $c = 1;
> my @a = (undef) x $size;
> for (1..$size) {
> $c ||= $_;
> }
> \@a;
>}
This is not equivalent in functionality. The extending is not
really "extending" but array initialize. To make it more like the
pushing function, the following is better:
sub extending {
my $c = 1;
my @a;
for (1..$size) {
$c ||= $_;
$a[$#a+1] = undef;
}
\@a;
}
Now it mirrors the action of extending the array during a loop. This
mirrors the semantics of pushing.
Here is what I get:
Benchmark: timing 1000 iterations of control, extending, pushing...
control: 6 secs ( 5.10 usr 0.00 sys = 5.10 cpu)
extending: 16 secs (15.25 usr 0.00 sys = 15.25 cpu)
pushing: 10 secs ( 8.68 usr 0.00 sys = 8.68 cpu)
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Wed, 20 May 1998 17:10:55 GMT
From: David@iqtexas.com
Subject: case insensitive checks, a=b
Message-Id: <6jv2qv$ur3$1@nnrp1.dejanews.com>
$a='dog';
$b='DoG';
if($a eq $b) {cool,they are alike} else {do something else}
Is there a "Perl like" way to do this?
non Perl methods:
1) replacing the variables using uc
if(uc($a) eq uc($b))
2) writing a sub to return the upper case or lower case for the comparison
if(my_uc($a) eq my_uc($b))
Thanks for the help,
-David
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 20 May 1998 13:51:20 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: David@iqtexas.com
Subject: Re: case insensitive checks, a=b
Message-Id: <ogws6ajb.fsf@mailhost.panix.com>
David@iqtexas.com writes:
> non Perl methods:
> 1) replacing the variables using uc
> if(uc($a) eq uc($b))
In what way is this "non-Perl?"
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: Wed, 20 May 1998 14:15:44 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: case insensitive checks, a=b
Message-Id: <comdog-ya02408000R2005981415440001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6jv2qv$ur3$1@nnrp1.dejanews.com>, David@iqtexas.com posted:
>non Perl methods:
>1) replacing the variables using uc
> if(uc($a) eq uc($b))
how is that non-Perl? looks like Perl to me. you're not replacing
variables - you're just comparing the return values of the uc(). you
could also use lc() if you like. you could also use a regex like
$a =~ m/\Q$b\E/i;
but why would you want to?
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers T-shirts! <URL:http://www.pm.org/tshirts.html>
Perl is a lot more than regular expressions
------------------------------
Date: 20 May 1998 17:10:02 GMT
From: hubris3@aol.com (HUBRIS3)
Subject: Credit card help
Message-Id: <1998052017100200.NAA11730@ladder03.news.aol.com>
I am trying to help a small business set up a web page.
(www.dacepublishing.com) They would like to set up a credit card form to take
credit cards over the net. We have a secured site and server but I am not
advanced enough to know how to set up the form and bin. Any help on this or
suggestions on the site please e-mail hubris3@aol.com or post here! Thank you,
Hubris3
------------------------------
Date: Wed, 20 May 1998 18:25:05 GMT
From: redpeppa@my-dejanews.com
Subject: email access through the web
Message-Id: <6jv76c$576$1@nnrp1.dejanews.com>
im lookin for a script that allows users to access their email through the
web..ive tried searching for it but havent had much luck,thank you
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 20 May 1998 14:22:41 -0400
From: psmith@baynetworks.com (Paul D. Smith)
Subject: Flushing STDIN before read?
Message-Id: <p567j0dcpa.fsf@baynetworks.com>
OK, so I have this important question I want to ask the user. I'm
reading from STDIN. I want to flush any typeahead he/she may have
entered, to avoid possible incorrect responses.
Soooo... how to do that with perl?
My investigations so far are leading me down the fcntl() path, setting
the O_NONBLOCK option on the STDIN file descriptor, then using sysread()
to try to read from STDIN until I get back some kind of "would block"
error, then unsetting the O_NONBLOCK option and continuing as normal.
Is this the only/best way to go?
If so, what's the most portable method for this? There seem to be many
choices for setting non-blocking bits, such as O_NDELAY, FNDELAY, or
O_NONBLOCK, but ideally the same perl code would run on SunOS 4.1.x and
Solaris 2.x, along with AIX and HP-UX.
Anyone have any samples they'd care to part with :)?
Also, faq pointers or other doc or CPAN pointers are great, as are
pointers to existing code that does similar things (I searched through
the core and the modules I have installed for fcntl and BLOCK but didn't
notice any examples, and my search of CPAN didn't turn up anything).
--
-------------------------------------------------------------------------------
Paul D. Smith <psmith@baynetworks.com> Network Management Development
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
These are my opinions--Bay Networks takes no responsibility for them.
------------------------------
Date: Wed, 20 May 1998 17:50:29 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: Re: Function syntax with prototyping, filehandles and arrays
Message-Id: <6jv559$hel$2@nz12.rz.uni-karlsruhe.de>
Tom Christiansen <tchrist@mox.perl.com> wrote:
>In comp.lang.perl.misc,
> Marc.Haber-usenet@gmx.de (Marc Haber) writes:
>:One of my various prototypes is
>
>Ooooh. Perl ``prototypes'' are about context coercion.
>They aren't what Pascal/C/C++/anything else uses them for.
>They probably won't make you happy.
So they actually aren't good for early mistype detection? Hey, I
finally gotta throw my C and C++ away :-)
>:sub write_to_temp(*$$$*)
>:{
>: my (*FH,$mailfilename,$heloname,$sender,@rcpts) = @_;
>:
>:that should be called like
>:
>:write_to_temp(\STDIN,$filename,$host,$sender,@rcpts);
>
>Why is it that you have a globular star on the fifth parameter
>in the prototype, but the calling code and the called code both
>treat what's coming in as a list there? Why isn't it an @?
It isn't an @ because I would like to have the chance to add a second
array at a later time. I tried the *, it didn't work.
>Or maybe a \@ in the proto, a @ in the caller, and a $rcpts_aref in
>the callee?
That might be the solution. I will try it later.
>If I were you, I would try making the program work without prototypes. :-)
Are the prototypes really that different from the prototype concept we
know from other languages?
Greetings
Marc
--
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber | " Questions are the | Mailadresse im Header
Karlsruhe, Germany | Beginning of Wisdom " | Fon: *49 721 966 32 15
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29
------------------------------
Date: Wed, 20 May 1998 13:06:32 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: generating hash of complex records
Message-Id: <1d99u35.1xj66uf122ta4uN@slip-32-100-246-215.ny.us.ibm.net>
Chris Stuber <cstuber@census.gov> wrote:
> I need to be able to store the equivilent of a C structure into
> a hash. I am sort of following a simple version of an example
> on page 274 of the Camel book (Generation of a hash of complex
> records. The code below yields "George 21" which isnt quite what
> I had hoped for. I have tried dozens of different things, but
> nothing working so far. Any assistance would be greatly appreciated.
>
> $rec = {};
>
> $rec->{NAME} = "George";
> $rec->{NUMBER} = "41";
> $AA{ $rec->{NAME} } = $rec;
>
> $rec->{NAME} = "Bob";
> $rec->{NUMBER} = "21";
> $AA{ $rec->{NAME} } = $rec;
>
> $key = "George";
> print "$key $AA{$key}{NUMBER}\n";
The problem is the second set of assignments is changing the same hash,
and the two entries in %AA point to the same hash too.
Here's some versions that work:
$rec = {};
$rec->{NAME} = "George";
$rec->{NUMBER} = "41";
$AA{ $rec->{NAME} } = $rec;
$rec = {}; # This generates a NEW, SEPARATE anonymous hash.
$rec->{NAME} = "Bob";
$rec->{NUMBER} = "21";
$AA{ $rec->{NAME} } = $rec;
$key = "George";
print "$key $AA{$key}{NUMBER}\n";
# -------------------
$rec = {
NAME => "George",
NUMBER => 41,
};
$AA{$rec->{NAME}} = $rec;
$rec = {
NAME => "Bob",
NUMBER => 21,
};
$AA{$rec->{NAME}} = $rec;
$key = "George";
print "$key $AA{$key}{NUMBER}\n";
# -------------------
%AA = (
"Bob" => {
NAME => "Bob",
NUMBER => 21,
},
"George" => {
NAME => "George",
NUMBER => 41,
},
);
$key = "George";
print "$key $AA{$key}{NUMBER}\n";
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: Wed, 20 May 1998 18:02:58 GMT
From: qvanegeren@frxsoft.com
Subject: IN NEED OF AN EXAMPLE OF USING Win32::Registry
Message-Id: <6jv5sh$3l8$1@nnrp1.dejanews.com>
Does anybody have an example of a script that uses the Win32::Registry
module? I have tried to use the GetKey functionality, and I get no
information back. If anyone has an example script that uses this
module I would greatly appreciate it if you could e-mail me a copy
of it. Thanks in advance for any scripts/suggestions...
Quenten Van Egeren
(qvanegeren@frxsoft.com)
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Wed, 20 May 1998 17:12:08 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
To: "Jeremy Goldberg" <jgoldberg@pipex.com>
Subject: Re: Inter-process file arbitration?
Message-Id: <8cvhr0uas8.fsf@gadget.cscaper.com>
>>>>> "Jeremy" == Jeremy Goldberg <jgoldberg@dial-but-dont-spam.pipex.com> writes:
>> use Fcntl qw(:flock);
>>
>> open(FD, ">blah") or die "$$ open: $!";
>> flock(FD, LOCK_EX);
>> print "$$ Got lock, gonna sleep\n";
>> sleep 10;
>> close FD;
Jeremy> But the open will fail if another process is writing to it!
Not on standard Unix systems, dating all the way back to when
flock() was first introduced.
Where are you working that it fails?
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 103 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
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: 20 May 1998 14:31:51 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Inter-process file arbitration?
Message-Id: <6jv7in$p3j$1@monet.op.net>
Keywords: Bergson bidden Leningrad scruple
>"Jeremy Goldberg" <jgoldberg@dial-but-dont-spam.pipex.com>:
> >P.S. Does flock() only work AFTER you've opened a file?
In article <6jupgg$cii@bsd1.ilse.net>, robert <robert@il.fontys.nl> wrote:
>[Much useful advice omitted.]
>Yes, since it works on filedescriptors (so you have to immediately lock the
>file after opening it).
Often this is inconvenient. For instance, in the example you showed,
the program erases the file's contents before it obtains the lock;
this might be incorrect.
In many cases, it's useful to maintain a separate empty file whose
only purpose is to be locked. Then you might do:
open L, "> $LOCK_FILE" or die ...;
flock(L, LOCK_EX); # Sleep until lock
# File is now locked
open F, "+< $DATA_FILE" or die ...;
open G, ">> $LOG_FILE" or die ...;
# Read and write F, write G;
close F; close G;
close L; # Release lock
The file $LOCK_FILE holds the lock not for itself but for the data in
files $DATA_FILE and $LOG_FILE. You can open the data and log files
with any modes you want, sure that you are the only one doing so.
Another advantage of this technique is that you can put the process id
into the lock file for bookkeeping:
open L, "+< $LOCK_FILE" or die ...;
for (;;) {
last if flock(L, LOCK_EX | LOCK_NB);
($pid, $time) = <L>;
$elapsed = time - $time;
print "Locked by process $pid for last $time secs. Abort? [y] ";
my $result = <STDIN>;
exit 0 if $result =~ /^y/i || $result !~ /./;
sleep $ZZZZZ;
}
seek L, 0, 0;
print L $$, "\n", time, "\n";
# Lock obtained...
You can't do this if you actually lock the file with the real data.
------------------------------
Date: 20 May 1998 14:33:58 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Inter-process file arbitration?
Message-Id: <6jv7mm$p4l$1@monet.op.net>
Keywords: aboard drawn partisan smile
In article <6juvc2$6b1$1@plug.news.pipex.net>,
Jeremy Goldberg <jgoldberg@dial-but-dont-spam.pipex.com> wrote:
>>open(FD, ">blah") or die "$$ open: $!";
>>flock(FD, LOCK_EX);
>
>But the open will fail if another process is writing to it!
Won't. Locking is advisory.
------------------------------
Date: Wed, 20 May 1998 17:09:55 GMT
From: markq@nerds-at-work.com
Subject: Re: Newbie cgi question
Message-Id: <6jv2p2$uha$1@nnrp1.dejanews.com>
If you don't want java to handle the client-side logic, then you've got to use
another scripting language that runs in the browser. Perl runs on the server
- not the browser. Your best bet is to use javascript to perform limited
validation before the page gets sent back for further processing on the
server. Keep the validation limited to the code that you wouldn't mind
sharing with 10 million of your closest friends because the javascript is
easily viewed by the user in the browser.
In article <6jto38$fnc@bgtnsc02.worldnet.att.net>,
"Bob Gebhart" <bgebhart@juno.com> wrote:
>
> We're evaluating Perl, SilverStream, JBuilder, etc., trying to pick a
good
> Internet/Intranet development tool. I'm strongly attracted to Perl because
> of its power and "C-look", but am very, very ignorant, particularly in CGI
> programming. Here's my question:
>
> Say I have a form with 10 fields, and I don't want to let the user
enter
> all 10 fields and send the form back to let me check it server-side. I want
> to data-check the 4th field, say (it's a part #, with a required format),
> and bitch at the user if he screwed up. The 11th field, say, I want to
> check against a database of umpty-ump company names, resident on the
> server.
>
> The point is that I want to do data-checking on a field-by-field
basis,
> rather than doing all data checks at the end of the form.
>
> I know this can be done with Java applets, but MUST I use Java for
this
> sort of thing? All I really want to do is tell the client to send the
> server the 4th and 11th fields any time they change, but I'll accept any
> method that tells the user he screwed up immediately after entering a
> field.
>
> Is there a practical way to do this in CGI Perl?
>
> Yeah, I know, really a pitiful question. But you gotta start somewhere
...
>
> ---Bob
>
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 20 May 1998 17:21:20 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Non-static private variables
Message-Id: <6jv3eg$n6h$1@mathserv.mps.ohio-state.edu>
Keywords: Non-static private variables
[A complimentary Cc of this posting was sent to Mark-Jason Dominus
<mjd@op.net>],
who wrote in article <6julsh$n7f$1@monet.op.net>:
> >> >As I understand Perl classes are just packages, which are just name
> >> >spaces. And instances of these classes are references to thingies which
> >> >are scalars, hashes or arrays.
> >>
> >> This is exactly right.
> >
> >Wrong. Objects are not references, but the things you refer to.
>
> The distinction is all in your head. An object is not a datum or
> a reference; it is an abstraction that is not really well-defined.
Wrong. Read the docs, or try some experiments.
$a = bless [4,1], Rational;
$b = $a;
$a->increment;
$b->print;
Ilya
------------------------------
Date: Wed, 20 May 1998 14:35:42 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl 5.0 map operator
Message-Id: <comdog-ya02408000R2005981435420001@news.panix.com>
Keywords: from just another new york perl hacker
In article <01bd83d6$64787da0$e8dda487@N440-E39.att.dom>, "Ron Sullivan" <baserad2@attmail.com> posted:
>Hi,
>
>My name is Subbaraman and I am relatively new to Perl. I was trying out
>some examples using the map operator in Perl 5.0. I tried the following
>example :
>
>#!/usr/bin/perl
>
>@nums = ( 60 .. 62 );
>$tmp = map { z,$_ } @nums;
>print "$tmp\n";
>
>According to the Perl 5.0 man page, the block inside the curly braces is
>evaluated in LIST context with $_ set internally to
>each element of @nums in succession and returns a list. If my understanding
>is correct, the output of the RHS in the statement would be the list
>(z,60,z,61,z,62).
well,
>The documentation states that if the rvalue is a comma
>separated list and if the lvalue is a scalar, then the scalar would be
>assigned the last value in the list and that the scalar would be assigned
>the length of the list only if the rvalue is a named array and not a comma
>separated list.
which documentation is this? i don't see anything like that in my
perlfunc manpage.
>I was hoping that the last print statement would print the
>value 62. But instead the output from the last statement was 6 ( probably
>the length of the list ). I am not quite clear as to what is happening in
>this case.
try reading the perlfunc man page for the correct documentation, and
thinking about the output you get from these test cases:
#!/usr/bin/perl
@list = qw(just another new york perl hacker);
$" = ', ';
$temp = map { $_ } @list;
print "Test 1: temp is [$temp]\n";
$temp = map { $count++, $_ } @list;
print "Test 2: temp is [$temp]\n";
$temp = map { $_ }
('just', 'another', 'new', 'york', 'perl', 'hacker');
print "Test 3: temp is [$temp]\n";
$temp = map { $count++, $_ }
('just', 'another', 'new', 'york', 'perl', 'hacker');
print "Test 4: temp is [$temp]\n";
@temp = map { $_ } @list;
print "Test 5: temp is (@temp)\n";
@temp = map { $count++, $_ } @list;
print "Test 6: temp is (@temp)\n";
@temp = map { $_ }
('just', 'another', 'new', 'york', 'perl', 'hacker');
print "Test 7: temp is (@temp)\n";
@temp = map { $count++, $_ }
('just', 'another', 'new', 'york', 'perl', 'hacker');
print "Test 8: temp is (@temp)\n";
@temp = map { $count++, $_, m/e/}
('just', 'another', 'new', 'york', 'perl', 'hacker');
print "Test 9: temp is (@temp)\n";
__END__
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers T-shirts! <URL:http://www.pm.org/tshirts.html>
------------------------------
Date: Wed, 20 May 1998 20:05:58 +0200
From: "Rigis Julii" <regis.julie@capway.com>
Subject: Perl and C-ISAM Informix
Message-Id: <6jv876$j2p$1@minus.oleane.net>
Hello,
I try to find one module to acces at C-ISAM with Perl 5. This Modul exist
Thank
------------------------------
Date: Wed, 20 May 1998 18:23:24 GMT
From: brian@brie.com (Brian Lavender)
Subject: Re: perl and html ??
Message-Id: <35671e25.4201036@news.jps.net>
On 20 May 1998 05:13:57 GMT, "DUTOIT" <abcdm@wanadoo.fr> wrote:
>Can I use omnihttpd like a local server and how?
OmniHTTPD is fairly easy to install, so hopefully you have gotten that
done. Get yourself a copy of the Gurusamy PERL port
http://www.perl.com/. OmniHTTPD has a series of test scripts and you
should be able to put your scripts in the CGI bin and your docs in the
httdocs area. THen you call it up on your local machine with
http://127.0.0.1 and that will loopback to your local web server. Omni
HTTPD has a configuration setting for where PERL is located. Your
scripts also should be named with the extension of .pl. I think you
also have to associate the .pl extension with the perl executable in
windoze. Dont place the perl.exe in the cgi bin. It's a major security
hole.
That should do it.
Brian
--------
Brian E. Lavender
http://www.brie.com/brian/
With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
--Peter J. Schoenster
>Other solution to test it easily?
>Thanks you very much
De Rien
>Mr DUTOIT
>abcdm@wanadoo.fr
------------------------------
Date: 20 May 1998 13:50:12 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Perl Help
Message-Id: <6jv54k$otl$1@monet.op.net>
Keywords: inspect maladroit pernicious vivify
In article <01bd8412$69ca8640$e18722a6@csp06947.cs.mci.com>,
Sylvia Dean <sylvia.dean@mci.com> wrote:
>I need to write a program to open a file
>sort that file using sort -t , 2 filename.
>Once I do the sort I need to write to another file.
>I then need to read the second file parse info and
>compare two dates using something like this: [...]
>then I need to format a report. As a beginner perl programmer I have
>no clue how to get started. Can anyone help me get started?
Sure. The best way to proceed is to go to the book store and get a
copy of `Learning Perl' by Schwartz and Christiansen. You need to
read it and try out the examples, taking special note of all the
features and examples that seem relevant to the problem you want to
solve.
Then you should try writing some small, partially-functional versions
of your program, say one that opens the files and emits the data
without sorting or formatting it; then one that writes unsorted
reports, then finally the complete version.
If, while you're diong this, you have difficulty accomplishing a
paritcular part of your task, you should come back here and ask a
specific question of this form:
I am trying to do X. I am using this code to do it:
....
Instead, it does Y, which is not what I want. How can I solve
this problem.
Another alternative is to hire someone who is a professional computer
programmer to write the program for you.
Hope this helps!
------------------------------
Date: 20 May 1998 17:10:18 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Perl to 'C' interface
Message-Id: <6jv2pq$7dt7@eccws1.dearborn.ford.com>
John Holmes <hjoh@chevron.com> writes:
> I can't seem able to resolve these references.
>
> void
> foo1()
> CODE:
> foo2();
>
> void
> foo2()
> CODE:
> ....
The XS stubs that you write will get a different name. The stubs
weren't designed to be called from C -- they're designed to be called
from Perl. If you have a C function (not an XS stub) called foo2(),
then you have a link problem. If you are trying to call the XS stub
foo2(), then you need to call it just like you do with other Perl
subroutine, i.e. with the perl_call_*() routines.
It looks like you're trying to share code between the two XS routines.
I solve this by moving the common code into a static C function
defined at the start of the XS file. That way it is visible to your
XS routines but not to other parts of your program.
- Ken
--
Ken Fox (kfox@ford.com) | My opinions or statements do
| not represent those of, nor are
Ford Motor Company, Powertrain | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section | "Is this some sort of trick
| question or what?" -- Calvin
------------------------------
Date: 20 May 98 17:43:59 GMT
From: "Murray Williams" <william2@wdni.com>
Subject: Problems with Sys::Syslog
Message-Id: <01bd8416$dd4d2790$0438280a@william3>
Hello,
I have Perl 5.004 and am using the Sys::Syslog module in a program on an HP
G30 and an HP 725. When I run the program I get an error:
Constant subroutine _INCLUDE_AES_SOURCE redefined at (eval 17) line 1.
If I comment out the "use Sys::Syslog;" statement and remove the method
references from my program I no longer get this error. I went further to
write a test program in which the only statement is "use Sys::Syslog;" and
I still get this error so I am sure the problem is related to the
Sys::Syslog module.
The module works okay, all the messages I want written to the syslog file
are written as I expect them to be, however it makes the program look buggy
to the users which is unacceptable to me.
Has anyone else seen this problem, do you have an answer?
Thank you in advance for any help,
Murray Williams
william2@wdni.com
------------------------------
Date: 20 May 1998 17:17:56 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: regexp for strings of chars
Message-Id: <6jv384$n1f$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <6jt7g8$5h2@hplntx.hpl.hp.com>:
> My original point about not blowing away the guy who asked about this,
> by pointing him at Friedl's book, still stands.
Pointing to Friedl's book is *never* a bad advice. Perl engine
changed a *lot* from that merry old time, but all the "good" things
are still there. It is misfeatures that are (almost completely) gone,
and zillions of new features.
Ilya
------------------------------
Date: Wed, 20 May 1998 11:49:55 -0400
From: Mahmoud Ahmed <mahmed@dkl.com>
To: Noel Sampol <noels@chilli.net.au>
Subject: Re: Sendmail to alias from Perl CGI script?
Message-Id: <3562FBA3.E59DF0AD@dkl.com>
Check out your sendmail.cf file in /etc/sendmail.cf configuration file
particularly
#
#local info.
#
do man sendmail or man 8 sendmail
Good luck,
Noel Sampol wrote:
> Hi...
>
> I have a Perl CGI script that runs /usr/bin/sendmail to send confirmation
> e-mail to me and to the 'visitor'. The problem is when I try the script via
> HTTP FORM POST using my e-mail alias of noels@ozinet.zip.com.au, the mail
> does not get sent to my alias but only to my real email of noels@zip.com.au.
>
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Mahmoud Ahmed
Data Kinetics Limited
http://www.dkl.com
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
------------------------------
Date: 20 May 1998 17:25:13 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Software vendor liability [Was: Does Perl have a IDE?]
Message-Id: <6jv3lp$7dt8@eccws1.dearborn.ford.com>
smcdow@arlut.utexas.edu (Stuart McDow) writes:
> kfox@pt0204.pto.ford.com (Ken Fox) writes:
> > Being able to sue vendors for bad software encourages vendors to
> > produce good software
>
> Hmm. I think it would encourage vendors to get out of the software
> business altogether.
That's true. The ones who produce dangerous crap wouldn't be able
to continue to make money simply by having a fabulous marketing team.
Other vendors might have to slow down the rate of "innovation," but
then we'd have more reliable software with fewer features. Hmm, not
a bad idea.
> It also makes me wonder whether this attitude discourages companies
> from writing their own software.
Companies will absorb the risk if the return is great enough. Being
able to sue for software defects does not change the existing economics
of writing custom software for internal use.
The really sad thing about software liability is that Ford, which is
a car company, can be sued for defective software, but Microsoft, which
is a software company, can't. Of course it'd be pretty odd if cars
came with shrink wrap licenses too, but that's a whole different topic.
- Ken
--
Ken Fox (kfox@ford.com) | My opinions or statements do
| not represent those of, nor are
Ford Motor Company, Powertrain | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section | "Is this some sort of trick
| question or what?" -- Calvin
------------------------------
Date: Wed, 20 May 1998 17:47:24 GMT
From: jdporter@min.net (John Porter)
Subject: Re: uniq command or module for perl??
Message-Id: <MPG.fcce2ab6208bf8c9896df@news.min.net>
On Wed, 20 May 1998 11:33:57 -0500,
in article <6jv0i5$qhb@bgtnsc03.worldnet.att.net>,
mswatters@att.net (ValHolla) wrote:
>
> I am fairly versed in shell scripting, and I know some about perl.
> I need to know of an easy way in perl to use the shell equivalent of the
> uniq command.
Then you need to read the docs that come with perl, for example.
% cd `perl -MConfig -e 'print $Config{privlib}'`
% grep -w uniq *.pod
perlfaq4.pod:simulating uniq(1)'s behavior of removing only adjacent
which turns out to be within the answer to the faq:
How can I extract just the unique elements of an array?
hth,
John Porter
------------------------------
Date: Wed, 20 May 1998 13:11:53 -0400
From: "Brian J. Sayatovic" <bjs@iti-oh.com>
Subject: What's wrong with this OO perl?
Message-Id: <6jv2sp$iba$2@malgudi.oar.net>
What's wrong with this code? Perl keep stelling me:
Can't call method "path" without a package or object reference at
Directory.pm line 117.
sub _getFileList {
my $self = shift;
# If the directory can be opened
if(opendir(DIR, $self->path())) {
# The pathis valid
$self->{VALID} = 'TRUE';
# . . .
------------------------------
Date: 20 May 1998 13:44:42 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: What's wrong with this OO perl?
Message-Id: <6jv4qa$osn$1@monet.op.net>
Keywords: brake female where're Wyman
In article <6jv2sp$iba$2@malgudi.oar.net>,
Brian J. Sayatovic <bjs@iti-oh.com> wrote:
>What's wrong with this code?
Nothing.
>Can't call method "path" without a package or object reference at
>Directory.pm line 117.
I guess $self is not a package name or an object reference.
Have you thought about what that means?
Have you looked in `perldiag' for a more complete explanation of this message?
------------------------------
Date: Wed, 20 May 1998 18:00:52 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: What's wrong with this OO perl?
Message-Id: <pudge-2005981355110001@dynamic10.ply.adelphia.net>
In article <6jv2sp$iba$2@malgudi.oar.net>, "Brian J. Sayatovic"
<bjs@iti-oh.com> wrote:
# What's wrong with this code? Perl keep stelling me:
#
# Can't call method "path" without a package or object reference at
# Directory.pm line 117.
#
# sub _getFileList {
# my $self = shift;
# # If the directory can be opened
# if(opendir(DIR, $self->path())) {
# # The pathis valid
# $self->{VALID} = 'TRUE';
# # . . .
Simple. $self is not an object.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
MacPerl: Power and Ease (ISBN 1881957322), http://www.ptf.com/macperl/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Wed, 20 May 1998 17:58:19 GMT
From: brian@brie.com (Brian Lavender)
Subject: Where is warning about PERL 5.001?
Message-Id: <35661958.2971797@news.jps.net>
I am looking for the warning regarding PERL 5.001. I remember it being
posted just about everywhere a year ago, but now I can't find it. Does
anyone know where it is? I even searched Deja News. I need to show
some evidence to get the people at my work to upgrade their version of
PERL.
brian
--------
Brian E. Lavender
http://www.brie.com/brian/
With a PC, I always felt limited by the software available.
On Unix, I am limited only by my knowledge.
--Peter J. Schoenster
------------------------------
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 2649
**************************************