[8727] in Perl-Users-Digest
Perl-Users Digest, Issue: 2344 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 17 00:07:27 1998
Date: Thu, 16 Apr 98 21:00:27 -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 Thu, 16 Apr 1998 Volume: 8 Number: 2344
Today's topics:
best way to summarize directory info? <syeats@ocean.com.au>
Re: Bill Gates should be invited to O'Reilly's "Free So (Tim Smith)
CD-R index formatter? <syeats@ocean.com.au>
Re: cgi perl ? <rootbeer@teleport.com>
cgi using perl (Yeung Mau Yuen Terence)
Re: cgi using perl <sowmaster@juicepigs.com>
Re: how to remove blanks? <rootbeer@teleport.com>
Re: htaccess & htpasswd help!!! <rootbeer@teleport.com>
Re: Image instead of button in Perl Script <sowmaster@juicepigs.com>
Re: Image instead of button in Perl Script <rootbeer@teleport.com>
Re: info on cookies <ljz@asfast.com>
Multi-tasking/threading <mhchau@cse.cuhk.edu.hk>
Re: Multi-tasking/threading <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Re: PERL aware code editor (Shaun Sides)
Perl library for INI file <huameng@dbs.com.sg>
Perl Oddity (Mark-Jason Dominus)
Re: perl script for tacacs <rootbeer@teleport.com>
Re: Problems running perl from html under NT <rootbeer@teleport.com>
Profane foobar? (was: Re: .= so why not =. ?) <rootbeer@teleport.com>
Re: push a non HTML document to a web browser? (Martien Verbruggen)
putc? (matt dick)
Re: putc? (Gabor)
Re: putc? <rootbeer@teleport.com>
Re: rand($.) (was wc-l in Perl) <rootbeer@teleport.com>
Re: Server Side Include <sowmaster@juicepigs.com>
Re: Setuid and Solaris <rootbeer@teleport.com>
Re: shorten array <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Re: Simple Unix Question, ( Simple for you maybe ) <rootbeer@teleport.com>
test for list membership - searching for the right idio <caw@belloc.med.monash.edu.au>
Re: Wanna laugh? (My First cgi.pm Script) (Mark-Jason Dominus)
x3270 emulator scripts using perl <lloydNoSpam@morpheme.NoSpam.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 14 Apr 1998 23:52:50 +1000
From: syeats <syeats@ocean.com.au>
Subject: best way to summarize directory info?
Message-Id: <35336A32.96CA3DE5@ocean.com.au>
Hi,
Can anyone point me to a perl script for win95/NT that can produce a
formatted summary of a disk directory to be used as the printed index
for a CD-R disc?
Regards,
Simon Yeats,
Real-Time Systems, Vencorp
Melbourne, Australia
------------------------------
Date: 16 Apr 1998 19:25:23 -0700
From: tzs@halcyon.com (Tim Smith)
Subject: Re: Bill Gates should be invited to O'Reilly's "Free Software Summit" (was Re: RMS should be invited to O'Reilly's "Free Software Summit")
Message-Id: <6h6eij$3ej$1@halcyon.com>
Ben Bullock <ben@hayamasa.demon.co.uk> wrote:
>Zenin wrote:
>> Ben Bullock <ben@hayamasa.demon.co.uk> wrote:
>> : I think that the X windows books by themselves are a major part
>> : of o'Reilly's business.
>>
>> Having once worked for Computer Literacy bookstores, I can assure
>> you the X books are nothing close to the bulk of there business.
>
>I didn't say they were. Note that O'Reilly sells copies
Right. You didn't say they were the "bulk" of their business. You said
you thought they were a "major part" of their business. Is it really
necessary to nitpick at this level?
--Tim Smith
------------------------------
Date: Tue, 14 Apr 1998 23:56:16 +1000
From: syeats <syeats@ocean.com.au>
Subject: CD-R index formatter?
Message-Id: <35336B00.74368BFF@ocean.com.au>
Hi,
Can anyone point me to a perl script for win95/nt that can create a
formatted summary report of a directory structure to use as a printed
index for a CD-R disc?
Regards,
Simon Yeats
------------------------------
Date: Fri, 17 Apr 1998 03:20:56 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: ~arthur <star@sonic.net>
Subject: Re: cgi perl ?
Message-Id: <Pine.GSO.3.96.980416202035.29515A-100000@user2.teleport.com>
On Thu, 16 Apr 1998, ~arthur wrote:
> How do I get it to work on the web
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.org/CPAN/doc/manual/html/pod/
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 17 Apr 98 16:47:04 GMT
From: terencey@dns1.chevalier.net (Yeung Mau Yuen Terence)
Subject: cgi using perl
Message-Id: <35378788.0@news.chevalier.net>
Hello
I am a beginner to develop cgi Perl.
I am using NT4 server and Netscape Server. I have already used association
of file extention ".PL" to activate Perl.exe
BUT error came as:
failure:for host xxx.xxx.xxx.xxx trying to POST /shell-cgi/xxx.pl,
cgi-parse-output reports: the CGI program c:\perl\bin\per.exe did not
produce a valid header (name without value: got line "<html>")....
What header I should used?
The cgi program simply
print "Content type...
print "<html....
....
------------------------------
Date: Thu, 16 Apr 1998 22:20:57 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: Yeung Mau Yuen Terence <terencey@dns1.chevalier.net>
Subject: Re: cgi using perl
Message-Id: <3536BC89.13CA@juicepigs.com>
Yeung Mau Yuen Terence wrote:
>
> Hello
>
> I am a beginner to develop cgi Perl.
> I am using NT4 server and Netscape Server. I have already used association
> of file extention ".PL" to activate Perl.exe
Error #1 is using active state. It is old and bare. Go to CPAN and
download the current port by Gurusamy Sarathy.
> BUT error came as:
>
> failure:for host xxx.xxx.xxx.xxx trying to POST /shell-cgi/xxx.pl,
> cgi-parse-output reports: the CGI program c:\perl\bin\per.exe did not
^^^^^^^
#2 If you cut and pasted the error you spelled perl wrong in your
registry.
> produce a valid header (name without value: got line "<html>")....
#3 This says that the http server is reading <HTML> in the header. More
than likely you didn't put a double newline after the Content-type
header.
> What header I should used?
>
> The cgi program simply
> print "Content type...
> print "<html....
> ....
#4 nobody can help you if you post everything as ...
#5 this should have been posted to a cgi or http server newsgroup. There
is nothing perl specific about it.
--
Bob Trieger | Titanic: big boat, bigger
sowmaster@juicepigs.com | iceberg, big deal
------------------------------
Date: Fri, 17 Apr 1998 02:56:25 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Dan Baker <dtbaker_@flash.net>
Subject: Re: how to remove blanks?
Message-Id: <Pine.GSO.3.96.980416195517.11254I-100000@user2.teleport.com>
On Thu, 16 Apr 1998, Dan Baker wrote:
> for the real NEW newbie, it would help if responders include the URL to
> the FAQs. You went to all the trouble to post the page, but not the full
> URL. I know I'm willing to go do some reading, but sometimes don't know
> where to go to RTFM. ;)
Actually, first time posters already get that information mailed to them.
And if they've missed it, it's hard to look for the Perl FAQ without
finding it. (Although you might find the old one... :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 17 Apr 1998 03:45:12 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: keith <keith@cca.munet.edu>
Subject: Re: htaccess & htpasswd help!!!
Message-Id: <Pine.GSO.3.96.980416204442.29515D-100000@user2.teleport.com>
On Thu, 16 Apr 1998, keith wrote:
> I have a form that submits a user name, I then want to take that name
> and use the htpasswd command to add them to a user list with a password.
There's a module on CPAN which should help you to do this. Good luck with
it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 16 Apr 1998 22:09:25 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
Subject: Re: Image instead of button in Perl Script
Message-Id: <3536B9D5.7247@juicepigs.com>
Brad Atkins wrote:
>
> I've been trying to get an image instead of a normal form button in a
> web based email client. The problem is, that with certain functions
> (everything except logging in) the Script does not fetch the datum.
And somehow this has something, anything to do with perl?
--
Bob Trieger | Titanic: big boat, bigger
sowmaster@juicepigs.com | iceberg, big deal
------------------------------
Date: Fri, 17 Apr 1998 03:52:05 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: batkins@tamrockcanada.ca
Subject: Re: Image instead of button in Perl Script
Message-Id: <Pine.GSO.3.96.980416204926.29515F-100000@user2.teleport.com>
On Thu, 16 Apr 1998, Brad Atkins wrote:
> Subject: Image instead of button in Perl Script
>
> I've been trying to get an image instead of a normal form button in a
> web based email client. The problem is, that with certain functions
> (everything except logging in) the Script does not fetch the datum.
>
> Any Suggestions?!
First, you should use a subject line which has to do with the topic of
your posting.
Second, you should probably debug your script. I'd give more specific
advice, but I can't see what your script needs from what you've posted. If
you can show us just the two or three lines of Perl code which aren't
doing what you think they should, we can try to help you.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 16 Apr 1998 23:29:49 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: info on cookies
Message-Id: <ltyax5unv6.fsf@asfast.com>
comdog@computerdog.com (brian d foy) writes:
> In article <ltyax6k2j8.fsf@asfast.com>, Lloyd Zusman <ljz@asfast.com> posted:
>
> >Tom Phoenix <rootbeer@teleport.com> writes:
>
> >> > or else Gilles Chong is unaware of the name of this variable and is
> >> > trying to learn this in order to access cookies in Perl-based cgi
> >> > scripts (my interpretation).
> >>
> >> Which is to say, not a Perl-specific problem...
> >
> >But there is an elegant, Perl-based solution to it.
>
> oh really? which one would that be? you do it the same way in other
> languages, so it's not Perl specific. perhaps you haven't read the
> cookie info referenced in the CGI Meta FAQ.
The solution I gave made use of the Perl "CGI" module which made use
of a method called "cookie()" which returns a reference to a hash that
contains the cookie values indexed by the cookie keys. If you didn't
see this post of mine, I'm sure it's in Deja News by now, or if you
wish, I would be happy to email a copy of it to you. It seems to me
that a couple aspects of the solution I suggested are Perl specific:
(1) the use of the Perl "CGI" module and its "cookie()" method.
(2) the fact that the results are returned in a Perl hash for
ease of access.
Of course the underlying mechanism for accessing cookies is the same
no matter what language is used to write a CGI program, and of course
it is generally possible to write code that is similar to the "CGI"
module in these other languages. However, the solution I offered made
use of Perl constructs and a Perl module to hide this underlying
mechanism from the programmer in a clearly Perl-specific way.
And I believe that the Perl "CGI" module indeed provides an elegant
interface for handling this case (and other similar cases).
> [ ... ]
>
> dilemma - do you give the starving fish or do you teach them to fish?
> if people knew how to find information on their own, they wouldn't
> need to ask questions. most of finding something is knowing where to
> look.
>
> glad to hear that you are perpetuating people's dependent behaviour.
I have been helping people with programming-related questions in this
manner for over 25 years, and I have never encountered anyone who uses
my helpfulness as an excuse to avoid working or to avoid learning on
his or her own. And no one has ever gotten dependent on my help.
Over the past 9-10 years when I have been in a position to offer help
to people who post questions in technical usenet newsgroups, it seems
like maybe 30%-40% of the time I do so, I never hear from the person
again. Of the remaining 60%-70% of the cases, most just write back to
thank me, to chit-chat, and to share technical information or other
things with me in return. There are a few others who do write back a
second or maybe even third time to pose more questions or to ask for
clarification, but none of these people has ever adopted a "please
help me so I can avoid helping myself" attitude, and they stopped
writing once the needed clarification had been communicated.
And to the best of my recollection, 100% of the people who have taken
the time to communicate with me about the help I gave them were
self-motivated people who believed in the value of working towards
learning instead of relying on others to do things for them.
Therefore, I don't have any experience over all these years where
anyone has become dependent on my help or has somehow been encouraged
to develop a freeloading attitude towards learning because of my
providing information or pointers to them.
Maybe I'm just lucky, or maybe there's something about the way I help
and communicate with people that lets them know that they won't get
very far with me if they are anything less than self-starters who love
to work towards their own learning. But whatever the reason(s) may
be, I can't say that I have ever experienced what you are referring
to.
I know that I cannot generalize from my own experiences to yours or
anyone else's, and I would certainly believe you if you told me that
your own experiences with people whom you've helped in the past do not
always correspond to mine.
But unless or until I start having experiences of my own where people
I offer help to become dependent on me or use my help as an
encouragement towards a freeloading attitude, I must reject the
validity of your claim that my choices in the way I help people here
or elsewhere "are perpetuating people's dependent behaviour."
And even if I do some day run into the rare person who responds to my
help in this manner, I will deal with that person on an individual
basis and not project that one person's attributes onto everyone else
who might subsequently be seeking to learn something that I happen to
be familiar with.
Therefore, I will continue to help people as I have been doing.
Perhaps you should just killfile me if you don't like to see me doing
this in comp.lang.perl.misc.
--
Lloyd Zusman
ljz@asfast.com
------------------------------
Date: 17 Apr 1998 02:42:17 GMT
From: Sleep <mhchau@cse.cuhk.edu.hk>
Subject: Multi-tasking/threading
Message-Id: <6h6fi9$naq@eng-ser1.erg.cuhk.edu.hk>
Hail , I want to ask : Can Perl multi-threading as what java does?
Any reference about that ?
thanx for attention.
Regards,
Chau.
------------------------------
Date: Thu, 16 Apr 1998 20:08:25 -0700
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: Multi-tasking/threading
Message-Id: <6h6h2l$r7l@bgtnsc03.worldnet.att.net>
Sleep wrote in message <6h6fi9$naq@eng-ser1.erg.cuhk.edu.hk>...
>Hail , I want to ask : Can Perl multi-threading as what java does?
>Any reference about that ?
>
>thanx for attention.
>
>Regards,
>Chau.
Not yet, but it's slated for the next major release, or so I hear.
------------------------------
Date: 17 Apr 1998 02:15:22 GMT
From: arch@abts.net (Shaun Sides)
Subject: Re: PERL aware code editor
Message-Id: <slrn6jct9o.hj2.arch@vellinost.abts.net>
Original message by: Glenn Schworak <Glenn.J.Schworak@state.or.us>
Date: Thu, 16 Apr 1998 07:06:52 -0700
Subject: PERL aware code editor
> Hi, I am use to using a C editor that has a few nice features. The one I
> like most is the fact that comments and code are given two different
> colors while editing (not saved that way).
>
> I am wondering if there are such editors developed for PERL that will
> run under the Windows 95 environment. Also, are there any UNIX based
> programs that can do this by serving ANSI color codes to a telnet
> session?
You might give Boxer, by David Hamel, a try. It's a DOS test
editor, with full color syntax highlighting, all the bells and
whistles, and even the ability to interact with the Win95
clipboard. I use it heavily. It supports perl, as well as
pretty much any other language you care to use.
IIRC, the url for it is http://www.boxersoftware.com
UltraEdit is also pretty good, but seemed limited to me compared
with Boxer.
--
Shaun L. Sides arch@abts.net
Business web site http://www.abts.net/~arch
Showershoe web site http://www.abts.net/~arch/showershoe
Recreational web site http://sara.mmlc.nwu.edu/~arch
------------------------------
Date: Fri, 17 Apr 1998 11:29:30 +0800
From: James Lim <huameng@dbs.com.sg>
Subject: Perl library for INI file
Message-Id: <3536CC9A.C665C115@dbs.com.sg>
Is there any library for reading/writing INI file format out there?
Thanks.
------------------------------
Date: 16 Apr 1998 23:10:12 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Perl Oddity
Message-Id: <6h6h6k$ncb$1@monet.op.net>
Keywords: bellyache Berra inaudible toolsmith
My program, `py', writes yacc-style parser programs in Perl.
That's not what's odd.
What's odd is the way it does it. It looks at the debugging output of
`bison -v' and steals the state tables from there.
You can read about it in detail at
<URL:http://www.plvoer.com/~mjd/perl/py/>
------------------------------
Date: Fri, 17 Apr 1998 02:45:08 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: "Angela D. Orebaugh" <orebauad@jmu.edu>
Subject: Re: perl script for tacacs
Message-Id: <Pine.GSO.3.96.980416194411.11254F-100000@user2.teleport.com>
On 16 Apr 1998, Angela D. Orebaugh wrote:
> I am writing a perl script to draw reports from the tacacs-accounting
> file for the dial in service. I need to compile information such as
> the username, login and logout times, and time accumulated for statistical
> and billing purposes. Does anyone have any good ideas or suggestions?
> This is the first real perl scripting I have done.
You should probably get the Llama book (Learning Perl) and read through
it, doing at least some of the exercises, before you start in on this
project. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 17 Apr 1998 02:48:26 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Tom Broadstock <tbroadstock@acm.org>
Subject: Re: Problems running perl from html under NT
Message-Id: <Pine.GSO.3.96.980416194750.11254G-100000@user2.teleport.com>
On Thu, 16 Apr 1998, Tom Broadstock wrote:
> I am having problems using the submit button on a html form to call a
> perl script and generate a new html page. How is this done in the NT
> environment using IIS 4.0?
If the docs for your server don't tell you, get a better server. Or, check
with a newsgroup about servers. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 17 Apr 1998 02:39:48 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Profane foobar? (was: Re: .= so why not =. ?)
Message-Id: <Pine.GSO.3.96.980416192603.11254E-100000@user2.teleport.com>
On Thu, 16 Apr 1998, Brad Baxter wrote:
> Okay, following is not a perl question, but most FAQ's and books I've
> read make use of the 'foobar' expression. Considering what this stands
> for, is anyone else out there slightly tired of seeing it, as am I?
> Chances are good that if I routinely used profane variable names in my
> posts, someone would call me on it.
Actually, 'foobar' is the variant (sanitized?) form of 'fubar', to me. And
(to me) 'fubar' stands for "Fouled Up Beyond All Recognition". Nothing
profane there, or maybe I just lack a dirty mind. :-) But a more detailed
etymology is under 'foo' in the Jargon File.
http://www.denken.or.jp/local/misc/JARGON/body-f/foo.html
http://www.denken.or.jp/cgi-bin/JARGON
This seems to support the idea that those metasyntactic variables are not
intrinsically profane. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 17 Apr 1998 02:11:27 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: push a non HTML document to a web browser?
Message-Id: <6h6dof$3b2$1@comdyn.comdyn.com.au>
In article <6h4tmh$a03$1@yeppa.connect.com.au>,
"Paul" <fgculp@YOUKNOWWHATTODO.vianet.net.au> writes:
> Is is possible to open a binary file like MSWord and send it to STDOUT?
# Assuming that you have send the correct HTTP headers
# $file_path contains the path to the file from your SQL server
# You might need to replace the 'die' with something else, since
# this is a CGI
open (FILE, $file_path) || die "Horrible death: $!";
# You only need the following on some OS's, check the documentation.
# perldoc -f binmode
# It won't hurt on the ones that don't need it
binmode(FILE);
print <FILE>;
close(FILE);
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd. | make a better idiot.
NSW, Australia |
------------------------------
Date: 16 Apr 1998 21:20:16 -0500
From: dick@ssd.comm.mot.com (matt dick)
Subject: putc?
Message-Id: <6h6e90$l7v@tako.wwa.com>
Okay, I want to print a single character without a \n. I want to
repeat this behavior in a while loop, once every 30 seconds while
I monitor a file's status. I want to hold off printing a carriage
return until I am out of the while loop.
Problem is, [s]print[f] buffers the stream until the \n. I asked
my Blue Camel and my Blue-black Leopard and neither knows the
answer, the Camel tells me that if I want to do a putc I should
use print. Print is apparently not the answer, however.
Anyone care to share the answer?
matt dick
dick@ssd.comm.mot.com
------------------------------
Date: 17 Apr 1998 03:38:03 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: putc?
Message-Id: <slrn6jdjto.kdk.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, matt dick <dick@ssd.comm.mot.com> wrote :
# Okay, I want to print a single character without a \n. I want to
# repeat this behavior in a while loop, once every 30 seconds while
# I monitor a file's status. I want to hold off printing a carriage
# return until I am out of the while loop.
#
# Problem is, [s]print[f] buffers the stream until the \n. I asked
# my Blue Camel and my Blue-black Leopard and neither knows the
# answer, the Camel tells me that if I want to do a putc I should
# use print. Print is apparently not the answer, however.
#
# Anyone care to share the answer?
The answer is in the Blue Camel, I don't remember where. But ...
Setting the current output handle hot with $| = 1; should do the
trick. :)
------------------------------
Date: Fri, 17 Apr 1998 03:54:10 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: matt dick <dick@ssd.comm.mot.com>
Subject: Re: putc?
Message-Id: <Pine.GSO.3.96.980416205301.29515G-100000@user2.teleport.com>
On 16 Apr 1998, matt dick wrote:
> Problem is, [s]print[f] buffers the stream until the \n.
Check out the magical $| variable. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 17 Apr 1998 03:41:53 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Tom Mornini <tmornini@netcom.com>
Subject: Re: rand($.) (was wc-l in Perl)
Message-Id: <Pine.GSO.3.96.980416202238.29515B-100000@user2.teleport.com>
On Thu, 16 Apr 1998, Tom Mornini wrote:
> In a discussion about picking a random line from a file Tom Phoenix wrote:
>
> > open FILE, $name or die "Can't read '$name': $!";
> > while (<FILE>) {
> > $line = $_ if rand($.) <= 1;
> > }
> > print "One randomly-selected line is $line";
>
> My question is: Why doesn't this hopelessly bias the randomness towards
> the beginning of the file, when rand($.) would be more likely to be <= 1?
It _is_ biased, but towards the end of the file (see my explanation at
http://cpan.perl.org/doc/FMTEYEWTK/random). For relatively small numbers
of lines it should be pretty fair.
> I ran it on a 112,000 line file over 100 iterations, and it seems that
> it biases towards the end of the file, which also makes sense, since
> earlier selections will be written over by later selections...
I'd guess that 112,000 is large compared to your 2**RANDBITS-1. Right?
> If fact, I don't believe this code even guarantees that a line is picked!
You're right, it doesn't. There may be no input, for example! :-)
But if there's input of fewer than, say 1000 lines, that algorithm should
do pretty well. If your file will have many more lines, you may need to
make the randomness a little smarter, but you shouldn't need to change the
basic algorithm. For example, if I knew that I might have hundreds of
thousands of lines, I could use this to get twenty bits of randomness each
time through the loop. (The assumption implicit here had darn well better
be true, though! :-)
my $rand20 = (int(rand 1024) + rand)/1024;
$line = $_ if ($rand20 * $.) <= 1;
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 16 Apr 1998 22:08:01 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
Subject: Re: Server Side Include
Message-Id: <3536B981.7B3D@juicepigs.com>
Abigail wrote:
> SSI is *not* HTML.
Oh yeah. Show me an example of SSI used outside of HTML.
--
Bob Trieger | Titanic: big boat, bigger
sowmaster@juicepigs.com | iceberg, big deal
------------------------------
Date: Fri, 17 Apr 1998 03:10:44 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: wcdw@hotmail.com
Subject: Re: Setuid and Solaris
Message-Id: <Pine.GSO.3.96.980416200055.11254J-100000@user2.teleport.com>
On Thu, 16 Apr 1998 wcdw@hotmail.com wrote:
> 1) Setting $ENV{PATH} to _ANYTHING_ (e.g., '/usr/bin') generates an
> "Insecure PATH in setuid" error.
Is one of the directories listed here world-writable? That would be a big
security hole, of course. Perl is trying to save you from foolish system
administration.
/
/usr
/usr/bin
> 2) The following code does NOT work, but instead generates an "insecure
> dependency in ``" error.
>
> my $bin = '/usr/bin/progname';
> my $str = `$bin $args`;
When $args is not tainted? Hmmm... So, you're claiming that $bin is
tainted? Let's check. Between those two lines, add these. (Don't worry,
these are not killing anything - although perl may warn you about using a
string as a number.)
kill 0, $bin; # Die if $bin is tainted
kill 0, $args; # Die if $args is tainted
Which one gives you a complaint about insecure dependency? If $bin is
tainted, it may be a bug in Perl. In that case, cut your code down to a
small case which demonstrates the errant behavior, and post it here.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 16 Apr 1998 20:05:07 -0700
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: shorten array
Message-Id: <6h6gsg$pmg@bgtnsc03.worldnet.att.net>
~arthur wrote in message <35369554.717E@sonic.net>...
>Hi,
>
>I have a Perl program (thanks David Black) that picks a random word in
a
>game. If you play the game more than once in a row you may get the same
>word. Is there a way that once the word is used it taken out of the
>array?
>
>~arthur
>star@sonic.net
I don't think you really want to shorten the array. Sounds to me like
you want to take a word at random from the first half of the array, use
that as your random word, remove it from its position in the array and
then push() it onto the end of the array. That should keep you from
using the same word for quite a while.
Hope this helps.
--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl
------------------------------
Date: Fri, 17 Apr 1998 03:47:21 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Craig <craigs@3rdstone.net>
Subject: Re: Simple Unix Question, ( Simple for you maybe )
Message-Id: <Pine.GSO.3.96.980416204526.29515E-100000@user2.teleport.com>
On Thu, 16 Apr 1998, Craig wrote:
> open(FILE, "some_real_file");
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
> foreach($line, @my_data) {
Do you know what that is doing? You never set $line to anything...
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 17 Apr 1998 13:44:02 +1000
From: "Chris Wright" <caw@belloc.med.monash.edu.au>
Subject: test for list membership - searching for the right idiom
Message-Id: <6h6j6i$ci2$1@towncrier.cc.monash.edu.au>
We newbies are encouraged in the FAQ:
> Please do not use
>
>
> $is_there = grep $_ eq $whatever, @array;
> or worse yet
>
>
> $is_there = grep /$whatever/, @array;
and examples are given of better methods "If you are going to make this
query many times and the values are arbitrary strings" and other methods for
integers. These involve the generation of various forms of inverted indexes.
What's the right way to test for list membership in a one-off way.
ie
if e in string:
do_something_pythonish
thanks for any help
chris wright
------------------------------
Date: 16 Apr 1998 21:59:02 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Wanna laugh? (My First cgi.pm Script)
Message-Id: <6h6d16$mp9$1@monet.op.net>
Keywords: finny gatekeep partner schizomycetes
In article <6h66i0$rgk$7@marina.cinenet.net>,
Craig Berry <cberry@cinenet.net> wrote:
> while (<HEADER>) {
> print $_;
> }
>
>That can be written as: print <HEADER>;
I think that's bad advice. That reads every line in the file into
memory before it prints anything out.
Maybe you meant
print while <HEADER>;
?
------------------------------
Date: Thu, 16 Apr 1998 19:26:14 -0700
From: Lenny Bruce Lee <lloydNoSpam@morpheme.NoSpam.com>
Subject: x3270 emulator scripts using perl
Message-Id: <3536BDC6.8D44982D@morpheme.NoSpam.com>
Has anyone used perl or a perl module with the x3270 terminal emulator.
I'm running x3270 v3.1.1.6 attaching to a mainframe Isanyone using the
x3270for scripting to a mainframe? I have tried to reach Paul Mattes but
the address x3270@cnt.com is undeliverable. Would love to find some
example scripts.
thanks,
-lloyd
--
"Guns don't kill people. Physics kills people."
-Dick on 3rd Rock From The Sun
------------------------------
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 2344
**************************************