[7354] in Perl-Users-Digest
Perl-Users Digest, Issue: 979 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 5 05:19:41 1997
Date: Fri, 5 Sep 97 02:00:36 -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 Fri, 5 Sep 1997 Volume: 8 Number: 979
Today's topics:
Re: "#!/path_to_perl -w" causes shell to be invoked <rootbeer@teleport.com>
(no subject) <erich@flm.mw.tu-muenchen.de>
@INC and LWP Modules <darrylc@eznet.com>
CGI Will not recognise if or unless statements. <dexterp@acay.com.au>
Re: CGI Will not recognise if or unless statements. (Bart Lateur)
Re: complex pattern?!? it shouldn't be, i think :) <usenet-tag@qz.little-neck.ny.us>
Re: flock() problem <rootbeer@teleport.com>
Re: Help! Book needed!! <seay@absyss.fr>
Re: Help! How to make http request from perl CGI? <rootbeer@teleport.com>
HELP: How can I clear <STDIN> ? (Weihan Chang)
Re: How does split find its argument? <rootbeer@teleport.com>
Re: How does split find its argument? (Jahwan Kim)
Learning perl <erich@flm.mw.tu-muenchen.de>
Re: NET::NNTP Woes <zenin@best.com>
Re: perl and XEmacs <zenin@best.com>
Re: Perl Online Docs <eike.grote@theo.phy.uni-bayreuth.de>
Perl's support on Win NT <Larry_P_Nguyen@qmail2.sp.trw.com>
Re: Perl's support on Win NT <pvhp@forte.com>
Q: Textoutput with TTF as a Bitmap?? <mail@blue-orange.de>
run two action <sue_chen@ix.netcom.com>
Re: security of input in reg exp? <rootbeer@teleport.com>
Re: Shakespearian insult program <stuartc@ind.tansu.com.au>
Re: shell commands <rael@zx80.dnai.com>
Simple Q about Win32::AdminMisc <oshaugbj@uwec.edu>
Re: split question <dshoyt@worldnet.att.net>
Re: SQL access to Access via Perl? (Mike Heins)
Re: stat on win95 <rootbeer@teleport.com>
Using sendmail from NT <lai@cs.auc.dk>
Re: Win 95 Perl & Tk <pvhp@forte.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 4 Sep 1997 19:39:02 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Kipp E. Howard" <kipp.e.howard@boeing.com>
Subject: Re: "#!/path_to_perl -w" causes shell to be invoked
Message-Id: <Pine.GSO.3.96.970904193435.22463X-100000@julie.teleport.com>
On Thu, 4 Sep 1997, Kipp E. Howard wrote:
> I am trying to help our administrators get all machines within our lab
> up tothe same version of perl (5.003). (I know 5.004 is ready, willing
> and able but we would like to wait for a few months of inernal testing
> of 5.004 so we can confirm that 5.004 does not produce additional
> warnings. After that time, we will definitely upgrade to 5.004. In the
> mean time we would like to have 5.003 available on all platforms.)
I won't argue with that (though I want to :-) but I'll say that there's no
reason you can't have 5.004 available as well, which could be handy.
> We installed perl in the following directory structure:
>
> /site/sw/perl-5.003/bin
Be careful that your full path to perl won't exceed 32 characters, if
that's the limit for the #! line on your system. (Of course, if you can
make /usr/bin/perl a symlink to the binary, everything should be fine.)
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 05 Sep 1997 08:28:00 +0200
From: Erich Kreiselmaier <erich@flm.mw.tu-muenchen.de>
Subject: (no subject)
Message-Id: <340FA670.79FA@flm.mw.tu-muenchen.de>
I am new to perl programming. Does anyone have a recommendation for
free available documentation.
Thanks
Erich
--
==============================================================================
------- | | |\ /| Erich Kreiselmaier
| | | | \/ | TU Muenchen
| | | | | Lehrstuhl fuer Fluidmechanik
| | | | | 85747 Muenchen
| \___/ | |
Tel: (49) 89 289 16125
Fax: (49) 89 289 16151
e-mail: erich@flm.mw.tu-muenchen.de
==============================================================================
------------------------------
Date: Fri, 5 Sep 1997 05:11:17 GMT
From: Darryl Caldwell <darrylc@eznet.com>
Subject: @INC and LWP Modules
Message-Id: <EG0rqu.3Gw@linex6.linex.com>
I'm on a Unix system running SUN and Perl 5.004
My ISP let's me have a shell account and let's me run perl apps. I have
successfully used New::NNTPClient and CGI.pm with no problems but I am
having trouble getting the LWP modules to work. I have program that uses
LWP::Simple. The modules are within a personal directory and I have tried
both of these methods:
BEGIN { unshift (@INC, List }
use lib List;
But I am still getting "BEGIN can't find LWP/Simple in @INC..."
It is my understanding that these methods direct perl to recursively
search through the directory given for the necessary modules. I have also
commented out the use module directive to LWP::Simple to run test a
snippet of the program in the debugger - -just to see if the correct path
is showing up in the @INC list. It's there, but perl still isn't seeing
the modules.
Darryl Caldwell Oikiasuchou School
___________________________________________________
The Practice Hall: http://www.eznet.com/bravo/ph/ph.html
Myth & Martial Culture
------------------------------
Date: Fri, 05 Sep 1997 15:01:09 +0000
From: Dexter Plameras <dexterp@acay.com.au>
Subject: CGI Will not recognise if or unless statements.
Message-Id: <34101EB5.615BCEF8@acay.com.au>
Hi
I am having Trouble composing a cgi script in perl with if or unless
statements.
My System is
NCSA HTTPd Server 1.5.2
Free Bsdi 2.1.5
Perl 5.002
This is the code excert of the code that is causeing the problem.
if(!defined($Username)
{
&err("$Param1","$ETC1","ETC2"); # &err Prints a cgi form
}
When running the Code on the command line it runs fine it produces html
formatted documents.
But when running the form on the web it returns
500 Server error
......etc
When I use this code it runs fine on both the command line and on the
web.
### if(!defined($Username)
### {
&err("$Param1","$ETC1","ETC2"); # &err Prints a cgi form
### }
I believe it has to do with the logic statements if, unless, elsif,
....etc.
Any clues would apprieciated.
Dexterp Plameras
------------------------------
Date: Fri, 05 Sep 1997 07:42:47 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: CGI Will not recognise if or unless statements.
Message-Id: <340fb7b1.474661@news.tornado.be>
Dexter Plameras <dexterp@acay.com.au> wrote:
> if(!defined($Username)
> {
> &err("$Param1","$ETC1","ETC2"); # &err Prints a cgi form
> }
You forgot a closing parenthese:
if(!defined($Username))
{ ...
Now, let us now if you still have problems after fixing that.
HTH,
Bart.
------------------------------
Date: 5 Sep 1997 03:34:55 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: complex pattern?!? it shouldn't be, i think :)
Message-Id: <eli$9709042311@qz.little-neck.ny.us>
Jeff Rosenfeld <jeffro@fore.com> wrote:
> Well, I'm not fluent with HTML but the examples presented so
Then you should *NOT* be attempting this problem. HTML comments
are FUBAR.
> far are not all that hard to deal with (yes, the more observant
> will notice that I cheated a little to handle nested angle brackets):
But you only handle nested brackets and not the (near) arbitrary text
allowed in a comment.
> % perl5 -pe '1 while s/<([^<"]|\"(\\.|[^\\"])*\")*?>//g'
> a <img src= "rt-arrow.gif" alt= "==>" >b
Quoted text is trivial as you noticed.
> a <!-- <This line is a (single) valid HTML 2.0 comment> --> b
Have some more valid HTML comments to play with (each is single
line for readibility, do not assume it will be so in a web page):
<!-- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->
<!-- <<<<<<<<<<<<<<<!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->
<!-- <<< -- -- >>!!>> ---- <<<<<<<<<<<<<<<<<<<<<<<<<! -->
<!-- <"< -- -- ">">"> ---- <<<""<<<<<<!<<<<<<----<<<< -->
<!-- <-> -- -- <----< ---- >----> ---- <----< ---- >> -->
Before you even attempt these I recommend you spend some time studying
the specs[1]. It is a foolish task to attempt to understand the
subtleties of a system when only looking at trivial examples.
I'd venture that a single regexp that could deal with matching valid
HTML markup is possible, I'd also venture that it would not be anywhere
near the fastest to code or maintain of the possible methods.
[1] RFC 1866 is the only document I -- and most others -- would
recognize as authoritative on HTML 2.0. I do not know much about
the later HTML versions.
Elijah
------
exclusively codes HTML 2.0 web pages
------------------------------
Date: Thu, 4 Sep 1997 20:05:44 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Farzad Mansour <zod@home.net>
Subject: Re: flock() problem
Message-Id: <Pine.GSO.3.96.970904200430.22463e-100000@julie.teleport.com>
On Thu, 4 Sep 1997, Farzad Mansour wrote:
> Can someone please point out what is wrong:
> open(FILE,"< /tmp/junk");
You didn't check to see that the open succeeded. Also, you may not be
using version 5.004 of Perl. If you have problems after fixing both of
those potential problems, please post again. Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 05 Sep 1997 10:04:21 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Help! Book needed!!
Message-Id: <340FBD05.790E9FCB@absyss.fr>
Bernhard wrote:
>
> HI!
> Who knows a good BEGINNER (!!) book for learning perl? It could be in
> english or german language.
What do you mean by "beginner"? If you are new to Perl, go get the
camel. If you are new to programming, you have a lot more territory to
cover. (IMnsHO Perl isn't a great first language. YMMV) Start with
the Llama. "man perlbook" for ISBN info. Make sure that you get the
second editon of these books. As the Llama is fairly recent, you may
need to go to the ORA web page (found in perlbook) to get the ISBN. I
think that the Camel has a German version (I know that there is a
French version), dunno about the Llama.
Also TomC has some book reviews at the perl home page. Last time I
checked that web server was down for upgrades. Maybe it will be back up
next week.
- doug
------------------------------
Date: Thu, 4 Sep 1997 21:02:25 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: mgwong@cedar.ca.gov
Subject: Re: Help! How to make http request from perl CGI?
Message-Id: <Pine.GSO.3.96.970904210141.22463p-100000@julie.teleport.com>
On Thu, 4 Sep 1997, Mike Wong wrote:
> I'd like to know how to write a perl CGI script that would make an
> http request for an html document,
You probably want LWP, which you can find on CPAN.
http://www.perl.com/CPAN/
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 05 Sep 1997 02:32:47 GMT
From: han@dataprompt.com (Weihan Chang)
Subject: HELP: How can I clear <STDIN> ?
Message-Id: <5und0v$dku$1@news.netrail.net>
Hi,
This should be a simple question for some of you. Even it is simple
for you, would you please still help me!
My perl script will read 'y' or 'n' from key board in the middle of
execution by doing:
$answer = <STDIN>;
Before the script reach this statement, operator might accedentally
touch the Enter key or space bar and thus make $answer contain
' y\n' or just a '\n'. Neither case would $answer equals to 'y'.
How could I clear the STDIN buffer right before the statement ?
Thanks a lot.
------------------------------
Date: Thu, 4 Sep 1997 20:51:16 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jahwan Kim <jahwan@supernova.math.lsa.umich.edu>
Subject: Re: How does split find its argument?
Message-Id: <Pine.GSO.3.96.970904204217.22463m-100000@julie.teleport.com>
On 5 Sep 1997, Jahwan Kim wrote:
> (1) perl -wne 'print split if /^alias/' < mail-aliases
> works in the way I expect.
That's nice. :-)
> (2)(Main Question) perl -wne 'print split[1] if /^alias/' < mail-aliases
> doesn't.
If I'm not mistaken, that passes a listref to split. The listref is then
compiled as a regexp something like /ARRAY(0xa6c50)/ - which isn't likely
to match your data! :-)
> Isn't this the same as
>
> perl -wne 'print +(split)[1] if /^alias/' < mail-aliases
>
> which is what I want? Apparently, the output tells me it's not.
You're right: It's not the same! You can't take a slice of a function, but
you can take a slice of a literal list - which is what you've done here.
> perl -wne 'print split[1] if /^alias/' <<TEXT
> alias this1that
> TEXT
>
> gives me
>
> alias this1that
As expected. Try splitting on /nomatch/ instead of /ARRAY.../ and you'll
get the same thing.
> (4) None of the above give me any warning.
Arguably, passing a reference when Perl expects a regexp could generate a
warning. (In a future version of Perl, you may be able to pass a ref to a
compiled regexp, I hope, but that should still fail in current versions.)
If you really want this, run perlbug to file a request.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 5 Sep 1997 05:21:28 GMT
From: jahwan@supernova.math.lsa.umich.edu (Jahwan Kim)
Subject: Re: How does split find its argument?
Message-Id: <slrn60v5mn.4h0.jahwan@supernova.math.lsa.umich.edu>
On Thu, 4 Sep 1997 20:51:16 -0700, Tom Phoenix <rootbeer@teleport.com> wrote:
> On 5 Sep 1997, Jahwan Kim wrote:
[snip]
> > (2)(Main Question) perl -wne 'print split[1] if /^alias/' < mail-aliases
> > doesn't.
>
> If I'm not mistaken, that passes a listref to split. The listref is then
> compiled as a regexp something like /ARRAY(0xa6c50)/ - which isn't likely
> to match your data! :-)
That's it! Thank you for enlightenment. But, ... shouldn't perl give
warnings for non-string argument of split? (No, I don't want it badly :),
but) I think *perl* should do the right thing. But then again, it's just my
thought.
[snip]
Question again: How does perl treat this anonymous array reference in
this case? Convert it to string? What happens, I think, is undocumented
(and doesn't need to be documented).
One more question, if I may:
% perl -wne 'print split a if /^alias/' <<TEXT
alias this1that
TEXT
Unquoted string "a" may clash with future reserved word at -e line 1.
lis this1tht
Good! I get warning! So I found out the first argument of split is always
interpreted as string. (Not that I'm gonna write split : in normal
situations :) But,
% perl -wne 'print split s1 if /^alias/' <<TEXT
alias this1that
TEXT
alias thithat
No warning? Is there a promise that no new perl functions will contain
numbers in it, or is there some explanation why there's no warning?
Cheers,
I-want-more-warnings Jahwan
------------------------------
Date: Fri, 05 Sep 1997 08:33:43 +0200
From: Erich Kreiselmaier <erich@flm.mw.tu-muenchen.de>
Subject: Learning perl
Message-Id: <340FA7C7.4A37@flm.mw.tu-muenchen.de>
I am new to perl programming. Does anyone have a recommendation for
free available documentation or a good book.
Thanks
Erich
--
==============================================================================
------- | | |\ /| Erich Kreiselmaier
| | | | \/ | TU Muenchen
| | | | | Lehrstuhl fuer Fluidmechanik
| | | | | 85747 Muenchen
| \___/ | |
Tel: (49) 89 289 16125
Fax: (49) 89 289 16151
e-mail: erich@flm.mw.tu-muenchen.de
WWW: http://www.flm.mw.tu-muenchen.de/~erich
==============================================================================
------------------------------
Date: 5 Sep 1997 02:44:52 GMT
From: Zenin <zenin@best.com>
Subject: Re: NET::NNTP Woes
Message-Id: <5unrn4$4ql$2@nntp2.ba.best.com>
Bryan Blackburn <blb@fedex.com> wrote:
>snip<
> Also, when you create $nntp, note that options follow the hostname in
> the call to new, ie,
> $nntp = Net::NNTP->new( 'news.ilk.com', Debug => 1 );
> If you turn on warnings (-w switch) Net::NNTP should complain about a
> bad hostname of "Debug".
No, it won't.
> Finally, "use strict;" would complain about Debug being a bare word.
No, it won't. To quote the perlop man page:
"The => digraph is mostly just a synonym for the comma
operator. It's useful for documenting arguments that come
in pairs. As of release 5.001, it also forces any word to
the left of it to be interpreted as a string."
Note the word "forces". It will pass use strict no problem.
--
-Zenin
zenin@best.com
------------------------------
Date: 5 Sep 1997 03:10:51 GMT
From: Zenin <zenin@best.com>
Subject: Re: perl and XEmacs
Message-Id: <5unt7r$4ql$3@nntp2.ba.best.com>
If it was hard to write, dammit it should be hard to read!
IHMO of course, YMMV. :^)
--
-Zenin
zenin@best.com
------------------------------
Date: Fri, 05 Sep 1997 08:56:49 +0200
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: Perl Online Docs
Message-Id: <340FAD31.41C6@theo.phy.uni-bayreuth.de>
Hi,
Erich Kreiselmaier wrote:
>
> I am new to perl programming. Does anyone have a recommendation for
> free available documentation.
Those who are German speaking may take a look at my online Perl
documentation:
http://www.phy.uni-bayreuth.de/~btpa25/perl/perl_main.html
Bye, Eike
--
======================================================================
Eike Grote, Theoretical Physics IV, University of Bayreuth, Germany
----------------------------------------------------------------------
e-mail -> eike.grote@theo.phy.uni-bayreuth.de
WWW -> http://www.phy.uni-bayreuth.de/theo/tp4/members/grote.html
http://www.phy.uni-bayreuth.de/~btpa25/
======================================================================
------------------------------
Date: Thu, 04 Sep 1997 19:13:23 -0700
From: Larry Nguyen <Larry_P_Nguyen@qmail2.sp.trw.com>
Subject: Perl's support on Win NT
Message-Id: <340F6AC3.4E81@qmail2.sp.trw.com>
I'm in the process of selecting a computer language/tool to write CGI
programs. Could some one please let me know what are the best choices
now? How is Perl supported on the Win NT platform? How do I get/purchase
the software?
thanks
------------------------------
Date: Thu, 04 Sep 1997 23:23:04 -0700
From: Peter Prymmer <pvhp@forte.com>
To: Larry_P_Nguyen@qmail2.sp.trw.com
Subject: Re: Perl's support on Win NT
Message-Id: <340FA548.4406@forte.com>
Larry Nguyen wrote:
>
> I'm in the process of selecting a computer language/tool to write CGI
> programs. Could some one please let me know what are the best choices
> now? How is Perl supported on the Win NT platform? How do I get/purchase
> the software?
> thanks
There are several viable options for obtaining perl for NT.
Fortunately the two best options cannot be bought since they are free.
The Activestate port of perl 5.003_07 is available from:
http://www.activestate.com/
The perl-porters port of perl 5.004_02 is available from:
http://www.perl.com/CPAN/authors/Gurusamy_Sarathy/
(which will redirect you to a "nearby" CPAN ftp site.)
There are special documents that discuss perl for NT,
check out http://www.perl.com/ for pointers.
Peter Prymmer
------------------------------
Date: Fri, 05 Sep 1997 10:40:06 +0200
From: Stefan Merath <mail@blue-orange.de>
Subject: Q: Textoutput with TTF as a Bitmap??
Message-Id: <340FC566.50308AD2@blue-orange.de>
Hi,
anybody knows a Perl-Script, which is able to generate a bitmap
(or GIF or something in this way) dependent from a given
TrueTypeFont-File (WinNT), the point-size of the text and of
course the text itsself?
Or at least some ideas, where I could find some helpful Code-
Snippets to convert TTFs in BMPs
Thanks very much
Please answer per e-mail too
Stefan
--
Stefan Merath *********************************** Blue Orange GbR
Reichenberger Str. 59 ----------------------------- 10 999 Berlin
Fon: 030/ 618 56 70 ------------------------- Fax: 030/ 618 56 70
Mail: mail@blue-orange.de ******* Home: http://www.blue-orange.de
------------------------------
Date: Thu, 04 Sep 1997 23:46:26 -0700
From: Sue Chen <sue_chen@ix.netcom.com>
Subject: run two action
Message-Id: <340FAAC1.DFE4C8F@ix.netcom.com>
Does anybody know how to call two actions in the form submit?
Thanks.
------------------------------
Date: Thu, 4 Sep 1997 21:01:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Alex Krohn <alex@gossamer-threads.com>
Subject: Re: security of input in reg exp?
Message-Id: <Pine.GSO.3.96.970904205201.22463n-100000@julie.teleport.com>
On Thu, 4 Sep 1997, Alex Krohn wrote:
> I want to be able to allow people to put input into a reg expression
> and was wondering about any security problems.
That's good to worry about security holes. Are you saying you want a user
of your program to specify the regexp to use?
> if ($item =~ /$userinput/) { blah(); }
>
> I don't want to quote $userinput as I want it to be treated as a reg
> exp. My question is, can users input ` or | or something similiar
> (perhaps even close the reg exp with a /) and execute a command?
No; Perl will not treat the contents of $userinput as executable code.
Even if it has a slash, that won't end the regexp. (But keep reading.)
> Is this safe?
(You sound like a dentist when you say that. :-) No, it's not really
safe. Because a user could (accidentally or intentionally) give you an
invalid regexp, they could crash your program. For example, entering '('
in $userinput would make a fatal error occur.
Fortunately, there's a way to get around that problem, with eval block:
$matches = eval { # Runtime errors in here are trapped
$item =~ /$userinput/;
};
if ($@) {
print "An error occurred: $@\n";
} elsif ($matches) {
blah();
} else {
print "No match.\n";
}
You should probably check whether the /o option to your regular expression
match would be useful. And you can find out more about eval BLOCK in the
perlfunc(1) manpage. Don't miss the perlsec(1) manpage, since you're
interested in security. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 05 Sep 1997 14:00:27 +1000
From: Stuart Cooper <stuartc@ind.tansu.com.au>
Subject: Re: Shakespearian insult program
Message-Id: <yeoen74v290.fsf@kudu.ind.tansu.com.au>
Your program could do with some improvement, Eric, Thou bootless folly-fallen
mumble-news! Consider the guts of the code:
# OLD GUTS
srand;
$word_1 = @column_1[int(rand(48))];
$word_2 = @column_2[int(rand(48))];
$word_3 = @column_3[int(rand(48))];
print "\nThou $word_1 $word_2 $word_3!\n\n";
#
... you've got the constant 48 hard-coded; giving you a random number between
0 and 48. You actually have 50 words in each array but no matter how many
times you run it; your program will never use the last 2 values (array indexes
48 and 49) of your list. Your program will never tell you that you are
Thou yeasty weather-bitten whey-face!
So let's fix it. Use the array size to work out the range of the random number:
if @column1 is 50 element array: $#column1=49.
we want a random integer between 0 and 49.
to do this; let's go for a random fraction between 0 and *50* and then apply
int().
why 0 and 50? because the biggest number you get out of rand(50)
is 49.9999 which int() turns into 49.
#
# NEW GUTS
srand;
$word_1 = $column_1[int($#column_1+1)];
$word_2 = $column_2[int($#column_2+1)];
$word_3 = $column_3[int($#column_3+1)];
print "\nThou $word_1 $word_2 $word_3!\n\n";
#
you can now add new words to the arrays and they'll get picked up by the
program without having to change the 48 constant like you would have before.
The three arrays can have different numbers of words in them too.
Notice also that it's $column_1[] not @column_1[]; the program assigns to and
uses a scalar, Eric, Thou ruttish elf-skinned miscreant!
finally use qw in the array assignments.
@column_1 = qw(
artless
bawdy
beslubbering
# etc etc etc
yeasty
);
this makes it much easier to add new words without having to worry about
double-quoting them and adding the comma at the end of each line. You
could for example read in your favourite Monty Python insults; which for
the most part sound pretty similar to the "Shakesperean" ones.
Eric has this program in his .bashrc Unix startup file so he gets
"the pleasure of a quality insult every time I login". I would
say this is about as often as you need to run this program. If you
feel like running it more often you don't need Perl help;
you need Professional help.
Cheers,
Stuart Cooper.
stuartc@ind.tansu.com.au
------------------------------
Date: 04 Sep 1997 20:19:59 -0700
From: Rael Dornfest <rael@zx80.dnai.com>
Subject: Re: shell commands
Message-Id: <87u3g0fnvk.fsf@zx80.dnai.com>
[posted & cc'd]
David Mossakowski <dmoss@instinet.com> writes:
> I need to create a form on intranet for people to be able to change
> their UNIX passwords. Question is: even if I log in the script as a
> super user can I execute something like: system "yppasswd user_name";
> ? I mean it then asks for the password and then again to retype it.
> Is there a way to type remotely? If not how else can I do this?
While working on a GUI (read: browser) front-end to an easy-to-set-up
server product, I ran into the same difficulty.
The best way I found was to avoid "passwd"/"yppasswd" altogether.
Using a carefully orchestrated combination of RCS and editing of the
passwd file itself, I solved the problem using nothing more than
Perl's innate ability to treat text as text.
Just my $0.02.
Rael
------------------------------------------------------------------------
Rael Dornfest Direct Network Access Email. rael@dnai.com
2039 Shattuck Avenue webmaven@dnai.com
Vice President Suite 206 Web. http://www.dnai.com
and Webmaven Berkeley, CA 94704 Voice. 888.321.DNAI
------------------------------
Date: Thu, 04 Sep 1997 21:32:56 -0500
From: Brian O'Shaughnessy <oshaugbj@uwec.edu>
Subject: Simple Q about Win32::AdminMisc
Message-Id: <340F6F58.BE234012@uwec.edu>
I am using perl to write a script to add 10000 accounts to NT. I would
like them disabled by default. I am attempting to use the following
line:
Win32::AdminMisc::UserSetMiscAttributes($domain,$userName,USER_FLAGS,UF_ACCOUNTDISABLE);
It fails. I am able to run every other function in AdminMisc or
NetAdmin, but whenever I try to set USER_FLAGS...it don't work...
Help??? Thoughts???
Thanks in advance..
Brian O'Shaughnessy
University of Wisconsin - Eau Claire
------------------------------
Date: Thu, 4 Sep 1997 22:19:58 -1000
From: "Dave Hoyt" <dshoyt@worldnet.att.net>
Subject: Re: split question
Message-Id: <5uoe2j$nmj@bgtnsc02.worldnet.att.net>
Paul,
Something like this (untested) should work:
($date, $time, $username, $jobid) = /^(.{8}) (.{4}) (.*) (\d+)$/;
Hope this helps,
Cheers!
Dave
Paul Keller wrote in article <340FFFDD.14FC@cisco.com>...
>Say i have a line to be processes which reads:
>
> 08/27/97 10:00 <username> 14252
>
> I would be able to split by using:
>
> ($date, $time, $username, $jobid) = split(' ', $_);
>
> But if several lines were to read:
>
> 08/27/97 10:00 <firstname middle lastname> 14252
> 08/27/97 10:00 <username> 14252
>
> How would I get split to ignore the spaces occuring between
> the angle braces of the first line so the 4th field is always
> the integer following whatever is enclosed in '<>'?
>
> Many thanks,
> Paul
------------------------------
Date: 5 Sep 1997 04:10:24 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: SQL access to Access via Perl?
Message-Id: <5uo0ng$j12$1@vixen.cso.uiuc.edu>
Jerome O'Neil (joneil@cks.ssd.k12.wa.us) wrote:
:
: Cliff Bradshaw wrote:
: >
: > Anyone know if it's possible to access an Access database on a network
: > via SQL using perl..?
:
: Yes. It is easily done.
But not from a UNIX box, which probably 90%+ of suitable ISPs run.
:
: > The aim is to provide a Web front end to the database.
: >
: > Any advice gratefully received.
:
: Get the Win32:ODBC.pm module from your favorite CPAN site. Read the
: documentation. SQL 'till you drop!
:
That will work if you have an NT-based ISP with an extremely
patient and suitably-talented administrator. Not likely.
I rarely see the alternative strategy mentioned. Set up
an ODBC-capable database like mySQL (free unless you sell the
database code) on the UNIX box, install the apropriate ODBC
driver on your Windows box (mySQL has myodbc), and use it as an
Access data source.
--
Regards,
Mike Heins
This post reflects the
opinion of my employer.
------------------------------
Date: Thu, 4 Sep 1997 19:33:02 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Alex Krohn <akrohn@spc.ca>
Subject: Re: stat on win95
Message-Id: <Pine.GSO.3.96.970904193117.22463W-100000@julie.teleport.com>
On Thu, 4 Sep 1997, Alex Krohn wrote:
> Does stat work with Perl for Win32?
Oughta. :-)
> I've got a list of files from readdir, but only the "." and ".."
> entries seem to give back anything for stat. The rest seem to return
> empty arrays..
>
> Am I doing something wrong?
Probably. :-) If you're asking perl for the stats on 'foobar.txt', how
can it know that you mean the file 'foobar.txt' in the directory you used
during readdir? If you don't specify otherwise, of course, it looks in the
current directory. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 05 Sep 1997 08:40:18 +0200
From: Jesper Lai Petersen <lai@cs.auc.dk>
Subject: Using sendmail from NT
Message-Id: <340FA952.D6014199@cs.auc.dk>
I hope someone can help me out on this one:
I'm writing a script in wich I need to get data from a html form,
process the data
and send the result to a recipient by mail.
The problem is that when using a pipe to postmail.exe, the mail-program
'hangs'.
The readme file that comes with postmail says that this is due to a bug
in perl.
The only soultion seems to be to make a file and let postmail send that
file. However,
due to security reasons this is not acceptable.
Does anyone know a way to send a mail from a perl script on NT without
having to
create a file? Could I use another sendmail program?
-Jesper
-
------------------------------
Date: Thu, 04 Sep 1997 23:12:12 -0700
From: Peter Prymmer <pvhp@forte.com>
To: hcorbin@erols.com
Subject: Re: Win 95 Perl & Tk
Message-Id: <340FA2BC.6DCF@forte.com>
Harold Corbin wrote:
>
> I have just downloaded 00402-bindist04-bc.tar.gz from
> ftp://ftp.cis.ufl.edu/pub/perl/CPAN/ports/win95/Gurusamy_Sarathy/
>
> This is Perl5 with Tk. It seem to work well with Win95, even though the
> install.bat was expecting NT.
>
> I haven't run much yet, just the widget demo and there is only one way
> to describe it - WOW, WOW!!!!!!! Thank You Gurusamy Sarathy and
> everyone who helped make this available.
That is great to hear Harold. Thanks for sharing your success
story with the rest of us. (I think that yours is the first
success report with Win 95 that I have personally seen.)
I am Cc:ing this message to the ptk@lists.stanford.edu list
so that Nick Ing-Simmons and others will get to read of
this good news.
Peter Prymmer
------------------------------
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 979
*************************************