[6288] in Perl-Users-Digest
Perl-Users Digest, Issue: 910 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 7 09:08:18 1997
Date: Fri, 7 Feb 97 06:00:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 7 Feb 1997 Volume: 7 Number: 910
Today's topics:
Re: "-i" switch is unsafe! <rra@cs.stanford.edu>
Re: "-i" switch is unsafe! <neeri@iis.ee.ethz.ch>
-w switch and the require statement <kimaryan@ozemail.com.au>
Re: Advice: Fastest ASCII hash tree dump <dbenhur@emarket.com>
Re: ANNOUNCEMENT: Perl documentation and FAQ discontinu <arichards@postoffice.worldnet.att.net>
Re: Calculating easter (Alain Fontaine)
Re: Easy help with scalar variables (brian d foy)
Re: Extract links and text from HTML <aas@bergen.sn.no>
Re: Fast list search <rra@cs.stanford.edu>
Re: fcntl to lock a file? (Tim Goodwin)
Re: hget.pl, chat2.pl and socket.ph problems <arichards@postoffice.worldnet.att.net>
Re: How do U copy a directory? (Tad McClellan)
Re: How to do this using perl? <dbenhur@emarket.com>
Re: How to peek at next line of STDIN? <tchrist@mox.perl.com>
installing perl 5 <pm1x@erols.com>
Re: Interesting behaviour of ?: with delete <guenther@lunen.gac.edu>
NT Perl 5 question - registry (Jack Knight)
Re: Parm/Option parsing. (Dave Thomas)
Re: Perl on Microsoft IIS, NT Server 4.0 <arichards@postoffice.worldnet.att.net>
Re: Perl vs Korn Shell (Neil S. Briscoe)
perl? <ezarrabi@direct.ca>
Re: perl? (Tad McClellan)
Re: Script to Find-replace (Simon Dale)
Re: simultaneous dbmopen (Tim Goodwin)
Re: Sort on third element of an Multi-Dim Array (Mike Stok)
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 07 Feb 1997 00:16:19 -0800
From: Russ Allbery <rra@cs.stanford.edu>
Subject: Re: "-i" switch is unsafe!
Message-Id: <qumzpxh820c.fsf@cyclone.stanford.edu>
In comp.lang.perl.misc, Joe Bednorz <bednorz@mail.net-connect.net> writes:
> The other day someone on comp.lang.c tried to explain why 0 was true and
> all other integer values were false. "Well, there's only one way for a
> program to succeed, but many ways for it to fail."
> Horse-puckey. What about deletion? Of anything? If the object isn't
> there is that an error? Of course not. The desired objective has been
> achieved.
One item could not be deleted because it was missing.
-- Mac System 7.0b1 error message
(Sorry.)
--
Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 07 Feb 1997 11:34:02 +0100
From: Matthias Neeracher <neeri@iis.ee.ethz.ch>
Subject: Re: "-i" switch is unsafe!
Message-Id: <86iv44sy5g.fsf@iis.ee.ethz.ch>
Tom Christiansen <tchrist@mox.perl.com> writes:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc, joe_bednorz@inteq.bhi-net.com writes:
> :Joe Bednorz Proud Member of the Unix-Hater's Mailing List
>
> Get stuffed.
Hmm, this must be a new meaning of "courtesy" with which I was not previously
familiar.
Matthias
-----
Matthias Neeracher <neeri@iis.ee.ethz.ch> http://www.iis.ee.ethz.ch/~neeri
"I'm set free to find a new illusion" -- Velvet Underground
------------------------------
Date: 7 Feb 1997 08:12:14 GMT
From: "Kim Ryan" <kimaryan@ozemail.com.au>
Subject: -w switch and the require statement
Message-Id: <01bc14d0$540e2ee0$6d9d16cb@dialup.ozemail.com.au>
When my programs get fairly large, I like to split them into several files,
and include each file with the require statement. This causes the -w switch
to issue spurious messages, such as identifier only used once, when in fact
it is used more than once, but in a different file to the one I am
currently checking. The line numbers that errors are reported on also seem
to get confused. Is there any solution to this problem?
Kim Ryan
kimaryan@ozemail.com.au
http://www.ozemail.com.au/~kimaryan
------------------------------
Date: Fri, 07 Feb 1997 00:30:39 -0800
From: Devin Ben-Hur <dbenhur@emarket.com>
To: Todd Lehman <lehman@visi.com>
Subject: Re: Advice: Fastest ASCII hash tree dump
Message-Id: <32FAE82F.7DCB@emarket.com>
Todd Lehman <lehman@visi.com> wrote:
> I'm reading and writing a nested hash data structure from/to a plain ASCII
> text file and I want to do it as fast as possible in Perl. I'm storing
> some web data this way and interacting with it using Perl/CGI scripts.
[snip]
> I've done everything I could think of so far to optimize the code,
> short of unrolling the recursion (I guess I might try that as a final
> last-gasp step). Any other possibilities?
Well, short of unrolling, you do make extra subroutine calls just to
print the leaf nodes. I'm actually interested in this same problem for
some code I'm working on, so I played around with a couple varients
(Tiny2 & Tiny3 below) to see if I could speed up the hash dump.
Tiny2 avoids the unneccessary extra subroutine calls. Tiny3 tries to
use the each operator to get key,value pairs instead of iterating over
the keys and doing lookups. I expected Tiny3 to be faster, but it's
not.
I suspect unrolling won't be faster, because you'll still have to push
context on a stack somewhere and in order to do it you'll lose the
foreach context in the loop so you'll have switch to subscripting your
way through the keys array instead.
(Oh, BTW, and I modified your timing loops to use the standard
Benchmark module rather than an external program).
> Code is below. I guess the limiting factor is traversing the tree,
> or maybe the regex substitution to conver ' to \' ?
yes, most of it is traversing the tree and printing. I tried a version
without the substitute (Tiny4) and saved about 15%. Actually, a big
part of it is the printing. A version that walks the tree but doesn't
print (Tiny5) is about twice as fast as a functional version.
BTW, you have a bug in your original code in that you escape the ' in
the key before you look up the value. In the event that you actually
have a key with ' in it, you'll fail on the look up.
> I guess right now I'm getting about 10,000 final string objects per
> second on my target machine, which is good enough for me from a practical
> standpoint. But still, from a programming standpoint, that seems
> awfully slow...
Doesn't seem that slow to me.
Here's your sample data again, followed by my version
of your program. (By the way, your sample data probably
underweights the expense of the \' escaping because all
the keys and data are so short).
Oh, and here's the timing results I got:
Slurp benchmark...
timethis 1000: 5 secs ( 3.40 usr 0.43 sys = 3.83 cpu)
Benchmark: timing 1000 iterations of Pretty, Timy, Tiny2, Tiny3, Tiny4, Tiny5...
Pretty: 5 secs ( 2.65 usr 0.07 sys = 2.72 cpu)
Tiny: 3 secs ( 2.40 usr 0.00 sys = 2.40 cpu)
Tiny2: 3 secs ( 2.00 usr 0.02 sys = 2.02 cpu)
Tiny3: 5 secs ( 2.37 usr 0.03 sys = 2.36 cpu)
Tiny4: 2 secs ( 1.65 usr 0.02 sys = 1.67 cpu)
Tiny5: 1 secs ( 0.88 usr 0.00 sys = 0.88 cpu)
> --------------------begin dump.in--------------------
> {
> 'a' => 'b',
> 'c' => {
> 'd' => 'e',
> 'f' => 'g',
> 'h' => {
> 'i' => 'j',
> },
> 'k' => {
> 'l' => 'm',
> 'n' => 'o',
> 'p' => {
> 'q' => 'r',
> 's' => 't',
> },
> },
> 'u' => 'v',
> },
> 'w' => {
> 'x' => {
> 'y' => 'z',
> },
> },
> }
> --------------------end dump.in--------------------
# ------------------ begin dump.pl -----------------
#!/bin/perl
use strict;
use Benchmark;
sub SlurpData #---READ INPUT FILE
{
my ($varname, $filename) = @_;
my $slurp;
open(SLURP, "<$filename") || die "Cannot open data file '$filename'!";
while (<SLURP>) { $slurp .= $_; }
close(SLURP);
eval $varname . " = " . $slurp . ";";
}
sub PrettyDump #---WRITE OUTPUT FILE, PRETTYPRINTED
{
if (ref($_[0]) eq "")
{
$_[0] =~ s/'/\\'/gs;
print OUT "'", $_[0], "'";
}
elsif (ref($_[0]) eq "HASH")
{
my $level = $_[1];
my $key;
print OUT "{\n";
foreach $key (keys %{$_[0]})
{
$key =~ s/'/\\'/gs;
print OUT $level, " '", $key, "' => ";
PrettyDump($_[0]->{$key}, $level . " ");
print OUT ",\n";
}
print OUT $level, "}";
}
}
sub TinyDump #---WRITE OUTPUT FILE, SUPER-COMPACTED
{
if (ref($_[0]) eq "")
{
$_[0] =~ s/'/\\'/gs;
print OUT "'", $_[0], "'";
}
elsif (ref($_[0]) eq "HASH")
{
my $key;
print OUT "{";
foreach $key (keys %{$_[0]})
{
$key =~ s/'/\\'/gs;
print OUT "'", $key, "'=>";
TinyDump($_[0]->{$key});
print OUT ",";
}
print OUT "}";
}
}
sub Tiny2 { # reduce subroutine calls
my ($key,$val);
print OUT "{";
foreach $key (keys %{$_[0]}) {
$val = $_[0]->{$key};
$key =~ s/'/\\'/gs;
print OUT "'" . $key . "'=>";
if (ref($val)) {
Tiny2($val);
} else {
$val =~ s/'/\\'/gs;
print OUT "'" . $val . "'";
}
print OUT ",";
}
print OUT "}";
}
sub Tiny3 { # use each operator
my ($key,$val);
print OUT "{";
while ( ($key,$val) = each(%{$_[0]}) ) {
$key =~ s/'/\\'/gs;
print OUT "'" . $key . "'=>";
if (ref($val)) {
Tiny3($val);
} else {
$val =~ s/'/\\'/gs;
print OUT "'" . $val . "'";
}
print OUT ",";
}
print OUT "}";
}
sub Tiny4 { # no \' escaping
my ($key,$val);
print OUT "{";
foreach $key (keys %{$_[0]}) {
$val = $_[0]->{$key};
print OUT "'" . $key . "'=>";
if (ref($val)) {
Tiny4($val);
} else {
print OUT "'" . $val . "'";
}
print OUT ",";
}
print OUT "}";
}
sub Tiny5 { # just walk the tree
my ($key,$val);
foreach $key (keys %{$_[0]}) {
$val = $_[0]->{$key};
if (ref($val)) {
Tiny5($val);
} else {
# print, yeah
}
}
}
#---TEST CODE
my $iter = 1000;
my $arg = shift;
if ($arg and ($arg !~ /^-(\d+)/)) { # just test
SlurpData('$::data', 'dump.in');
open(OUT,">&STDOUT") or die("Can't dup STDOUT: @!");
&{$arg}($::data, ""); print OUT "\n";
} else { # run benchmarks
$iter = $1 if ($1);
print "Slurp benchmark...\n";
timethis($iter, q!SlurpData('$::data', 'dump.in');! );
open(OUT, ">dump.out") || die "Cannot open output file!";
SlurpData('$::data', 'dump.in');
timethese($iter, {
Pretty => 'PrettyDump($::data, "");',
Tiny => 'TinyDump($::data, "");',
Tiny2 => 'Tiny2($::data, "");',
Tiny3 => 'Tiny3($::data, "");',
Tiny4 => 'Tiny4($::data, "");',
Tiny5 => 'Tiny5($::data, "");',
});
close(OUT);
}
# ------------------ end dump.pl -----------------
--
Devin Ben-Hur <dbenhur@emarket.com>
eMarketing, Inc. http://www.emarket.com/
"Don't run away. We are your friends." O-
------------------------------
Date: Thu, 06 Feb 1997 23:24:48 -0700
From: Adam Richards <arichards@postoffice.worldnet.att.net>
Subject: Re: ANNOUNCEMENT: Perl documentation and FAQ discontinued
Message-Id: <32FACAB0.1EDD@postoffice.worldnet.att.net>
I read the examples but must admit didnt read the FAQ.
I have the camel book and it is dog-eared (that means
i read the hell out of it).
I think the medium is an issue.
Recommend:
1. create user awareness of the USEGROUP search engines
like alta vista or infoseek.
2. And/or use PERL to create an on-line hearctical search
site with examples.
I post questions here occasionally because
I know there are very experienced programmers who
can not only help with an answer, but solve the
problem with style.
I know alot of WEB server questions come up as well,
but to tell the truth this is where the Perl hacks hang
out and they probably set up a web server to use perl,
thus, they have the experience and usually the answer.
QED.
Perl is a great tool, the more support the better.
adam
------------------------------
Date: Fri, 07 Feb 1997 09:09:55 +0100
From: fontaine@sri.ucl.ac.be (Alain Fontaine)
Subject: Re: Calculating easter
Message-Id: <fontaine-0702970909550001@macaf.sri.ucl.ac.be>
In article (Dans l'article) <5ddmcs$jhs@ming.init.se>, lgt@init.se
(Lars-Gunnar Taube) wrote (icrivait) :
> Jonas Liljegren <jonas@cultcom.se> writes:
>
> >How do I calculate the date of easter?
#!/usr/bin/perl
$gyear = 1582;
print "Enter year (>=532): ";
while (($in=<STDIN>) ne "\n") {
($year) = split(' ',$in);
if ($year=~/\D/||$year<532) {
print "Please give a year >=532: "
} else {
$gold = $year%19+1;
$epac = (11*$gold+27)%30;
$dom = int(5*$year/4);
if ($year>$gyear) {
$cent = int($year/100);
$greg = int(3*($cent-15)/4);
$clav = int(8*($cent-14)/25);
$epac = (23+$epac+$clav-$greg)%30;
$dom = $dom-$greg-10;
}
$moon = 50-($epac+((($epac==25)&&($gold>11))||($epac==24))+6)%30;
$eday = $moon+7-($moon+$dom)%7;
print(int(($eday-1)/31)+3,"/",($eday-1)%31+1,"\n");
print "Enter year (>=532): ";
}
}
/AF
------------------------------
Date: Thu, 06 Feb 1997 07:58:02 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Easy help with scalar variables
Message-Id: <comdog-0602970758020001@nntp.netcruiser>
[redirected to comp.lang.perl.misc, since it has nothing to do with
CGI]
In article <5debbp$ctu@Holly.aa.net>, "Mr. Freeze" <gbigelow@teleport.com>
wrote:
> Hello, this is a easy (probably stupid) question coming from a CGI newbie.
> I have a scalar variable and I am trying to increment it by 1 (i.e.~ 8 to
> 9). I have tried both of these (considering that $value = 8):
> $value = $value + 1;
>
> AND
>
> $value++;
both of those should work. are you sure that $value was 8 before
you tried to increment it?
#!/usr/bin/perl
my $value = 0;
foreach (0..10)
{
print $value++, ' '
}
__END__
0 1 2 3 4 5 6 7 8 9 10
--
brian d foy <URL:http://computerdog.com>
unsolicited commercial email is not appreciated
------------------------------
Date: 07 Feb 1997 10:59:46 +0100
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: Extract links and text from HTML
Message-Id: <hohdxym0d.fsf@bergen.sn.no>
kent@darwin.darwin.eeb.uconn.edu (Kent E. Holsinger) writes:
> So, what I'd like to do is to write a script that will extract links
> like this from my pages, and write them in a file with a format
> something like
>
> http://www.its.nbs.gov/nbs/ <the list of words above>
You can use the HTML::Parser class for this. The following example
makes a sub-class called "Ext" which print the text while we are
inside <a ...> elements.
--------------------------------------------------------
#!/usr/bin/perl -w
package Ext;
require HTML::Entities;
@ISA=qw(HTML::Parser);
require HTML::Parser;
sub start
{
my($self, $tag, $attr) = @_;
if ($tag eq 'a') {
my $link = $attr->{'href'};
print "$link ";
$self->{'a'}++;
}
}
sub end
{
my($self, $tag) = @_;
if ($tag eq 'a') {
print "\n" unless --$self->{'a'};
}
}
sub text
{
my($self, $text) = @_;
if ($self->{a}) {
HTML::Entities::decode($text);
$text =~ s/\s+/ /g;
print $text;
}
}
package main;
$p = new Ext;
$p->parse_file("test.html");
--
Gisle Aas <aas@sn.no>
------------------------------
Date: 07 Feb 1997 01:49:19 -0800
From: Russ Allbery <rra@cs.stanford.edu>
Subject: Re: Fast list search
Message-Id: <qumu3np7xpc.fsf@cyclone.stanford.edu>
Tom Christiansen <tchrist@mox.perl.com> writes:
> I think we should add a new perl built-in called faq(). For example,
> faq("string in list") might return:
> 5.5) How can I tell whether an array contains a certain element?
You know, that might not be that bad of an idea, actually. use FAQ
anyone?
--
Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 7 Feb 1997 13:12:12 GMT
From: tim@pipex.net (Tim Goodwin)
Subject: Re: fcntl to lock a file?
Message-Id: <5df9nc$fsh@join.news.pipex.net>
In article <ri3ev9jppa.fsf@viman.com>, Matt Cline <gandalf@viman.com> wrote:
>I'm trying to use fctnl to lock a file. However, I keep on getting
>a "Bad file number" error, no matter what file number I give it.
Probably, you're trying to apply an exclusive lock through a file
descriptor open only for reading, or a shared lock through a file
descriptor open only for writing. Neither of these makes sense,
so the system won't let you do it.
Shared locks can only be applied through filehandles open for reading,
and exclusive locks can only be applied through filehandles opened for
writing.
>Does someone have some existing code using fcntl that works?
I'd recommend using the File::Lock module.
Tim.
--
Tim Goodwin | "A language needs both intestines and guts." -- Larry Wall
------------------------------
Date: Thu, 06 Feb 1997 23:36:18 -0700
From: Adam Richards <arichards@postoffice.worldnet.att.net>
To: Eddy De Clercq <Eddy.DeClercq@coi.be>
Subject: Re: hget.pl, chat2.pl and socket.ph problems
Message-Id: <32FACD62.863@postoffice.worldnet.att.net>
I used a module called url.pl or geturl.pl
which was built on ftplib.pl and it worked.
as a matter of fact, I have been able to
script FTP using sockets with ftplib.pl.
send me mail if you want me to mail these modules.
adam
------------------------------
Date: Thu, 6 Feb 1997 22:08:47 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How do U copy a directory?
Message-Id: <fs9ed5.ss4.ln@localhost>
Atticus Killough (atticus@wealthcomreps.com) wrote:
: Curious to know how in my CGI/Perl script I am writing I can get my
: program to recursively copy one directory into another that hasn't
: been created.
: In my korn shell the command would be:
: cp -R /usr/home/myname/the_directory /usr/home/myname/new_directory
: I tried running this from the following line
: system 'cp -R /usr/home/myname/the_directory
: /usr/home/myname/new_directory';
: Why doesn't this work?
Maybe because user 'nobody' doesn't have write permission in
your home directory?
(CGI programs often run as user 'nobody' or 'www')
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Thu, 06 Feb 1997 21:24:54 -0800
From: Devin Ben-Hur <dbenhur@emarket.com>
Subject: Re: How to do this using perl?
Message-Id: <32FABCA6.372A@emarket.com>
Tom Christiansen wrote:
> In comp.lang.perl.misc, dbenhur@emarket.com writes:
> :Or what I would do since most of my scripts want to run
> :on both DOS & unix:
> :
> :@data = split /\\|\//, $file_path_and_name;
>
> Remind me to make files with backslashes in them.
Well, Tom, you are welcome to be intentionally perverse, but
anyone who regularly works with multiple operating systems
will avoid a fairly broad assortment of special characters in
their filenames. I can easily make names that work fine for
DOS or MacOS that will break assumptions that unix programs
make about well-formed names too.
The fact is, in real life, I have never encountered a file name
with embedded backslashes. Splitting paths using either
forward or backslash is a workable solution for scripts that
want to work "reasonably" on both DOS-based and unix platforms.
A more thorough solution would allow either auto-detection
or explicit locallization to the host operating environment.
However this can be rather difficult and tedious, and is often
not worth the effort unless you really need a very high level of
portability and idiot-proofness.
--
Devin Ben-Hur <dbenhur@emarket.com>
eMarketing, Inc. http://www.emarket.com/
"Don't run away. We are your friends." O-
------------------------------
Date: 7 Feb 1997 03:31:54 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to peek at next line of STDIN?
Message-Id: <5de7na$df4$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
htchapma@vela.acs.oakland.edu (H. Todd Chapman) writes:
:I searched Dejanews, the FAQ, and Tom's EYEWTK???? and came up with one post+
:
:The question is:
:
:How can I peek at the next line from <> without making it inacessible from t+
Your characters have been chopped at the point they hit the edge of my
vt100, which yes, I really am using. Please bear this in mind.
:In other words I want to use the angle operator to read in a line and then p+
I once wrote a bunch of functions to do this, but you had to call them
instead of the normal thing. With 5.004, however, you have tied
filehandles, so that means you could do what you want transparently, which
would be cool. Well, assuming it's not really an interactive handle, that
is, or you'll be hosed the way you get hosed with ungetc.
Hm... maybe we need a >STDIN< operation. :-)
--tom
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
I think it's a new feature. Don't tell anyone it was an accident. :-)
--Larry Wall on s/foo/bar/eieio in <10911@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 7 Feb 1997 09:13:57 GMT
From: "Frank Murray" <pm1x@erols.com>
Subject: installing perl 5
Message-Id: <01bc14d8$39307620$d51860cf@frankmur>
Any help provided would be greatly apreciated.
I tried to seup perl on SCO ver 3.2V5.02
First I ran "sh Configure -d" this went well
The problem is when I run make I get the error "Termination code 139 (bu21)
and a core dump. The last line on the screen before the error is
"miniperl -Ilib pod/pod2html.PL".
What am I doing wrong, I am a novice at best when it comes to "C".
Thanks in advance
Frank Murray
------------------------------
Date: 06 Feb 1997 20:45:44 -0600
From: Philip Guenther <guenther@lunen.gac.edu>
Subject: Re: Interesting behaviour of ?: with delete
Message-Id: <e693ev9s59j.fsf@lunen.gac.edu>
Chris Schoenfeld <chris@ixlabs.com> writes:
> I can do this, and it works:
>
> !exists $acks{$1} ? $acks{$1}='' : delete $acks{$1};
>
> But if I do the more straightforward:
>
> exists $acks{$1} ? delete $acks{$1} : $acks{$1}='';
>
> I get something like:
> Can't modify delete with scalar assignment
The ?: operator has a higher precedence than assignment. Thus,
exists $acks{$1} ? delete $acks{$1} : $acks{$1}='';
is parsed as:
(exists $acks{$1} ? delete $acks{$1} : $acks{$1}) = '';
instead of:
exists $acks{$1} ? delete $acks{$1} : ($acks{$1}='');
With it arranged the other way, there's only one way to parse it. The
error message you see is because "delete $acks{$1}" can't be assigned to
(i.e., it's not an L-value). Solution? I would suggest that it's bad
style to use the ternary operator if it's just acting as an 'if', and that
the above should be written as:
if (exists $acks{$1}) {
delete $acks{$1};
} else {
$acks{$1} = '';
}
Philip Guenther
----------------------------------------------------------------
Philip Guenther UNIX Systems and Network Administrator
Internet: guenther@gac.edu Voicenet: (507) 933-7596
Gustavus Adolphus College St. Peter, MN 56082-1498
------------------------------
Date: Fri, 07 Feb 1997 09:27:01 GMT
From: jfk@pobox.com (Jack Knight)
Subject: NT Perl 5 question - registry
Message-Id: <32faf530.1795905@news.cableol.net>
I'm using perl v5.001 which comes with the 3.51 RK. In the NT
extensions, there are some calls which claim to be able to read the
registry security ACL's. (NTRegGetSecurity/NTRegSetSecurity).
The HTML documentation on these says that the calling user must have
the right 'SE_SECURITY_NAME' to use these calls. I have tried using
these, but get 'access denied' messages and Dr.Watson logs, but
nothing of any diagnostic value.
I can't find any reference to SE_SECURITY_NAME in the SDK, NT docs,
Technet etc. Any ideas, anyone?
ADVthanxANCE
------------------------------
Date: 7 Feb 1997 06:13:15 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Parm/Option parsing.
Message-Id: <slrn5flhrh.vd8.dave@fast.thomases.com>
On Thu, 06 Feb 1997 18:23:05 +0000, Nick Weavers <weav@apollo.havant.ibm.com> wrote:
> # How does this idea sound to other perl writers
> ?
> # We invent a new way of specifying a scripts parms/options
> using
> # HTML like tags, Then we stick the stuff at the end of our script
> files
> # after an __END__ token. Someone writes a wizo module to wind though
> @ARGV
> # and check the parms string against the specs (issuing appropriate
> # messages for non compliances).
Or perhaps base it on Pod::Usage?
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Thu, 06 Feb 1997 23:33:37 -0700
From: Adam Richards <arichards@postoffice.worldnet.att.net>
To: Steinar Moen <stemo@powersim.no>
Subject: Re: Perl on Microsoft IIS, NT Server 4.0
Message-Id: <32FACCC1.4CC5@postoffice.worldnet.att.net>
There are two ways to invoke perl scripts with
IIS2.0
one is using the DLL which is supposed to be faster,
the other is to use the perl.exe directly.
I have tried both, and see no performance difference.
I prefer to use the perl.exe %s association that was
recommended to you because it is more reliable and
give access to the server environmental variables.
adam
------------------------------
Date: 7 Feb 1997 06:13:21 GMT
From: neilb@zetnet.co.uk (Neil S. Briscoe)
Subject: Re: Perl vs Korn Shell
Message-Id: <memo.970207061152.6927C@zetnet.co.uk>
In article <slrn5fl2vq.3mt.kinge@king.oklahoma.net>, kinge@oklahoma.net
(Ed King) wrote:
> I'm at the point where I want to write some simple programs for my
> private use. I bought the Bolsky book entitled "The New Korn Shell" and
> the author maintains the Korn shell is the greatest thing since sliced
> bread. I want to know if Korn shell scripting or Perl is more
> versatile. If I just want to invest time learning one which one should
> it be and why.
>
You have asked the same question in comp.lang.korn have you? What do you
mean "There isn't such a news group!"?
;-)) Sorry for such a response - but you did ask for it - use Perl.
Regards
Neil
------------------------------
Date: Thu, 06 Feb 1997 22:50:45 -0800
From: ehsan zarrabi <ezarrabi@direct.ca>
Subject: perl?
Message-Id: <32FAD0C5.67DE@direct.ca>
How do I run this Perl Script.
#!/usr/bin/perl
##############################################################################
# SSI Random Image Displayer Version
1.2 #
# Copyright 1996 Matt Wright
mattw@worldwidemart.com #
# Created 7/1/95 Last Modified
11/4/95 #
# Scripts Archive at:
http://www.worldwidemart.com/scripts/ #
##############################################################################
# COPYRIGHT
NOTICE #
# Copyright 1996 Matthew M. Wright All Rights
Reserved. #
#
#
# SSI Random Image may be used and modified free of charge by anyone
so #
# long as this copyright notice and the comments above remain intact.
By #
# using this this code you agree to indemnify Matthew M. Wright from
any #
# liability that might arise from it's
use. #
#
#
# Selling the code for this program without prior written consent
is #
# expressly forbidden. In other words, please ask first before you try
and #
# make money off of my
program. #
#
#
# Obtain permission before redistributing this software over the
Internet or #
# in any other medium. In all cases copyright and header must remain
intact.#
##############################################################################
# Define Variables
$basedir = "http://your.host.xxx/path/to/images/";
@images = ("first_image.gif","second_image.jpg","third_image.gif");
@urls = ("http://url_linked/to/first_image",
"http://url_linked/to/second_image",
"http://url_linked/to/third_image");
@alt = ("First WWW Page","Second WWW Page","Third WWW Page");
##############################################################################
# Options
$uselog = "1"; # 1 = YES; 0 = NO
$logfile = "/path/to/log/file";
$date = `/usr/bin/date`; chop($date);
$link_image = "1"; # 1 = YES; 0 = NO
$align = "left";
$border = "2";
# Done
##############################################################################
srand(time ^ $$);
$num = rand(@images); # Pick a Random Number
# Print Out Header With Random Filename and Base Directory
print "Content-type: text/html\n\n";
if ($link_image eq '1' && $urls[$num] ne "") {
print "<a href=\"$urls[$num]\">";
}
print "<img src=\"$basedir$images[$num]\"";
if ($border ne "") {
print " border=$border";
}
if ($align ne "") {
print " align=$align";
}
if ($alt[$num] ne "") {
print " alt=\"$alt[$num]\"";
}
print ">";
if ($link_image eq '1' && $urls[$num] ne "") {
print "</a>";
}
print "\n";
# If You want a log, we add to it here.
if ($uselog eq '1') {
open(LOG, ">>$logfile");
print LOG "$images[$num] - $date - $ENV{'REMOTE_HOST'}\n";
close(LOG);
}
------------------------------
Date: Fri, 7 Feb 1997 06:06:26 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: perl?
Message-Id: <2s5fd5.8m.ln@localhost>
Your Subject: sucks you know.
Please put a subject in your Subject:
ehsan zarrabi (ezarrabi@direct.ca) wrote:
: How do I run this Perl Script.
Would reading the perlrun man page help with running perl? It might...
If you want to run it in a WWW environment, then it would
make sense to ask in a WWW newsgroup.
: # COPYRIGHT
^^^^^^^^^
You are supposed to READ these things you know...
: NOTICE #
: # Copyright 1996 Matthew M. Wright All Rights
: Reserved. #
: #
: #
: # SSI Random Image may be used and modified free of charge by anyone
: so #
: # long as this copyright notice and the comments above remain intact.
: By #
: # using this this code you agree to indemnify Matthew M. Wright from
: any #
: # liability that might arise from it's
: use. #
: #
: #
: # Selling the code for this program without prior written consent
: is #
: # expressly forbidden. In other words, please ask first before you try
: and #
: # make money off of my
: program. #
: #
: #
: # Obtain permission before redistributing this software over the
: Internet or #
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
A copyright violation distributed to tens of thousands of people.
My, you are rather ...ummm, bold...
(please excuse my harshness if, by chance, you actually DID obtain
Mr. Wright's permission)
: # in any other medium. In all cases copyright and header must remain
: intact.#
: ##############################################################################
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 7 Feb 1997 08:23:40 GMT
From: sd@powerpress.com (Simon Dale)
Subject: Re: Script to Find-replace
Message-Id: <sd-0702970026480001@avm.vip.best.com>
About a month ago, I posed this same question on this group, the only
diference being, I showed my attempts at writing the code, and asked what
I was doing wrong. whithin, a few hours, I had recieved about six E-mails
with very helpfull assistance, and was able with their kind help to put
together a very usefull script that does just what you describe.
So I'll make the same offer to you now. Show us the code you have been
working on, and you will be surprised at all the help you will recieve...
In article <5ddhhq$pp0$1@newsin-1.starnet.net>, ficken@mobot.org (Keven D.
Ficken) wrote:
I am looking for a script that will search through all of the files in
a directory tree and replace a specified character string with another
string. I have been unable to make heads or tails of the CPAN to find
one. I am hoping someone can direct me to such a script.
Thanks,
Keven
ficken@mobot.org
------------------------------
Date: 7 Feb 1997 13:07:35 GMT
From: tim@pipex.net (Tim Goodwin)
Subject: Re: simultaneous dbmopen
Message-Id: <5df9en$fnl@join.news.pipex.net>
In article <32F954EC.7327@creativeaccess.com.au>,
James Murray <jaymez@creativeaccess.com.au> wrote:
>I've written a simple cgi perl script
>which uses a dbmopen call.
>
>Everything's fine, until it comes to a point where
>simultaneous calls are made to the same script.
>
>One processes opens the dbm file successfully, other processes can't
>accesses the file.
Sounds like dbmopen has decided to use GDBM_File. The gdbm library only
permits one database writer at the same time, and the dbmopen interface
doesn't give you any way to say that you only want read access to the
database.
You should use tie, which gives you much better control.
use GDBM_File;
tie %hash, GDBM_File, $gdbm, GDBM_READER, undef or
die "$0: can't tie to $gdbm: $!\n";
Tim.
--
Tim Goodwin | "A language needs both intestines and guts." -- Larry Wall
------------------------------
Date: 7 Feb 1997 13:29:29 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Sort on third element of an Multi-Dim Array
Message-Id: <5dfanp$51t@news-central.tiac.net>
In article <5ddapt$qj2@fridge-nf0.shore.net>,
Nathan V. Patwardhan <nvp@shore.net> wrote:
>Rick Thornley (thorsoft@cdsnet.net) wrote:
>
>: I need to print the third element in sorted order. Could someone provide
>: an example of how to sort this array on the third element and then print
>: the third element?
>
>Ahh, so glad you asked. Someone posted a solution to this problem about
>a week ago, and perhaps even yesterday. :-) Please search www.dejanews.com
>for comp.lang.perl.misc sort element and you'll be golden!
How would I do that at a site where store & forward is allowed (e.g. mail
and news) but TCP/IP connections to the outside world are not allowed or
possible? I know I can do ftp by mail in a bind, but more and more
places are getting selective about where people get to surf (for better
or for worse...)
I'm sure I've seen solutions to similar problems, but a solution to *this*
problem escapes me...
I think the FAQ is a pretty good resource 'cos it's possible to skim
through it and let a few key words and phrases settle in - then when you
come across a problem you have an inkling of where to go and look for a
solution.
An article by Andrew Langmead suggested:
galahad@netins.net (STEVE) writes:
>I have an array of arrays, like this:
>@LoL = ( ["Tom", "3237"], ["Brad", "7345"], ["Bruce","9219"]);
>I can access it and get things out just fine, but have been having trouble
>sorting the whole thing by the first element in each array.
[...]
Perl's sort() takes an optional code block or subroutine name that you
can use to control how elements get sorted.
@final = sort { $a->[0] cmp $b->[0]} @LoL;
for $name (@final) {
print "$name->[0] $name->[1]\n";
}
Notice that @final is getting copies of the references to the data.
After the call to sort(), @final and @LoL will be two arrays pointing
to the same data.
So changing the sort block index and using something like
@list = sort {$a->[2] cmp $b->[2]} @list
foreach $element (@list) {
print "$element->[2]\n";
}
might work. Something similar to the "Schwartzian Transform" might also
work for you, the Transform is described in Tom's FMTEYEWTK on Sorting (at
http://www.perl.com/perl/everything_to_know/sort.html amongst other
places), maybe
foreach $item (map {$_->[2]} sort {$a->[2] cmp $b->[2]} @list) {
print "$item\n";
}
(which doersn't leave you with a sorted list...) does enough? The perl
data sctructures cookbook (perldsc) documentation might be helpful if
anything is unclear.
The FAQ which can be found in the Comprehensive Perl Archive Network (CPAN
- master ftp site at ftp.funet.fi under /pub/languages/perl/CPAN or
through the multiplexor at http://www.perl.com/CPAN/ or even more directly
through http://www.perl.com/FAQ) and contains questions and answers about
sorting hashes by value which might be tangentially useful.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V7 Issue 910
*************************************