[8879] in Perl-Users-Digest
Perl-Users Digest, Issue: 2496 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 4 21:06:46 1998
Date: Mon, 4 May 98 18:00:42 -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 Mon, 4 May 1998 Volume: 8 Number: 2496
Today's topics:
#PERL the IRC Channel on Efnet. (Excession)
Re: Adding 600 users to a Linux password file <webmaster@fccjmail.fccj.org>
Re: ANSI Colour in Perl <rra@stanford.edu>
Re: cd with a perl-script (Martien Verbruggen)
Re: cgi-lib.pl or CGI.pm? <upsetter@shore.net>
Re: cgi-lib.pl or CGI.pm? (Martien Verbruggen)
condition to subroutine <graham@contact.com.au>
Re: condition to subroutine <sowmaster@juicepigs.com>
Re: condition to subroutine <jdf@pobox.com>
Re: CPAN & Module gripes (was Re: Ever Wonder...?) <rra@stanford.edu>
Re: Creating a text file from form variables (Martien Verbruggen)
Re: Determining Disk Space (Martien Verbruggen)
Re: Directory usage in Perl for win32 (Martien Verbruggen)
Embedded systems programming <mrazzak@cse.unl.edu>
Re: Ever Wonder Why Not Everyone Uses Modules? <rra@stanford.edu>
Re: Hello people, want to learn Perl ? (Bryan Miller)
Re: Hello people, want to learn Perl ? <webmaster@fccjmail.fccj.org>
Re: How do I reuse functions in several programs? <jdf@pobox.com>
Re: How do I reuse functions in several programs? (Martien Verbruggen)
Interactive Chem Test <michealj@bellsouth.net>
Re: is it possible to parameterize a class name? <jdf@pobox.com>
Re: Length of a variable (Martien Verbruggen)
Re: Max length of a string (Martien Verbruggen)
Padding a string to be a fixed length <needcrew@tiac.net>
Re: Padding a string to be a fixed length <jdf@pobox.com>
Re: Passing type AV * ? (Charles DeRykus)
Re: Perl Randomness Question..any pointers? (Martien Verbruggen)
perlio.h error using cc?? <xxx@xxx.xxx>
Personal Web Server <nervick@bewellnet.com>
Re: Pre-extending a hash? (jeremy howard todd)
Re: Splain a regex to me rpearce@fastlane.net
Re: sum/display sparse 3D array <lr@hpl.hp.com>
Translating crontab(5) file to a format that can be com (Alan Barclay)
trouble with Win32::Process npolonsk@hotmail.com
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 05 May 1998 00:23:03 GMT
From: daclay@NOSPAMzip.com.au (Excession)
Subject: #PERL the IRC Channel on Efnet.
Message-Id: <35504bd3.17885176@news.zip.com.au>
There are some good network resources for Perl. HTTP://www.perl.com,
HTTP://www.perl.org, and of course, CPAN. Then there are newsgroups such
as this one, where you can ask questions and get snappy answers from people
who have managed to see your bleat in the dark.
Then there is IRC (Inter Relay Chat). EFNET's #perl channel is pretty
damned good. If you ask a FAQ question unwittingly, the bot sends you off
to look at the required function; if you ask a sensible question, you'll
probably get a sensible answer, or a lead to where you could find a
sensible answer.
There are some caveats though -- asking a question about the currently
forbidden topics (pretty well HTTP, WWW and CGI are considered bad topics)
will get you kicked from the channel. Not reading the FAQs or the books
(Llama, Camel, MRE, etc) even after being prompted, is liable to get you
kicked if you keep asking the same simple question. And using most any
script to highlight your message (bold, colours, underlines, auto-aways)
will get you kicked.
That's all cool, one can cope with various rules that have evolved over the
life of a particularly popular IRC channel, one can phrase one's questions
in interesting ways and get one, two, or many interesting responses. There
are people in there who write books about the language, so generally there
is a -resource- which can be used by Perl programmers to solve their
problems. Or at least help to solve their problems.
But there is the inevitable pitfall of IRC to contend with -- the trigger
happy Operators of the channel. #perl is pretty egalitarian -- fully 70%
of the channel (with 60 or more members in it) has Ops status. People are
usually logical about their decisions, and usually you have to work at it
to get yourself banned from the channel (see above asking about CGI or WWW
or using an Autoaway script ).
Then there are the people who just love to kick others from the channel,
for a wide variety of reasons
Some examples:
you have been kicked off #perl by x (nickname too lame)
you have been kicked off #perl by x (flooding)
you have been kicked off #perl by x (No WWW, Can't you read the topic?)
you have been kicked off #perl by x (we don't like Win32)
you have been kicked off #perl by x (we especially hate NT)
you have been kicked off #perl by x (don't paste code without asking)
you have been kicked off #perl by x ( whoomp! there it is!)
you have been kicked off #perl by x ( Autojoin sucks)
you have been kicked off #perl by x ( fix your script)
You get the gist ...
And along with the kicks, come the bans. A number of channel regulars like
to use 'ban' as their warning message to any would-be querent:
11:54 <newuser> "Hi, do you know how to set the mode of a file in perl?"
11:54<chanreg> newuser: yes!
11:54 * chanreg sets mode -o+b newuser@scum.pond.com
11:54 * chanreg has kicked newuser from #perl (go away, you bother me)
Anyone who is an IRC regular would instantly recognise this form of
behaviour -- the channel-god syndrome: "Thou shalt do as I say, or I shall
ban thee on whim!" With most IRC channels (and IRC networks) it's par for
the course, or in the classic words of Monty Python; "It's all about
growing up and being British". There isn't a whole lot an individual can
do when they are banned; worrying about bans is probably totally invalid in
the IRC scheme of things. "Anarchy that works" ... well, not quite.
HOWEVER, when a useful resource (#perl) is lorded over by a very few
op-wielding monomaniacs, then one has to question the validity of "the gods
that be" that allow such occurrences to continue unabated.
Case in point: Someone I know was visiting #perl, and managed in the space
of five minutes to mention Windows NT, and was instantly kickbanned. Now
that's just plain rude. Foolishly I berated the egomaniac in question (a
16 year old tyro who goes by the name of 'amagosa') with a pithy yet
accurate comment. Here's the edited log transcription (no words have been
modified, just a bunch of other lines deleted.)
*** Log file opened: 2/05/98 16:08:43
<rebeccar> NT's a real os!
amagosa sets mode: -o+b rebeccar *!*rebeccar@*.org.au
amagosa has kicked rebeccar from #perl (NT can't fork(). It is not A Real
OS (tm))
<Excession> amagosa the #perl godlet. <implied 'sheesh'>
amagosa sets mode: -o+b Excession *!*dac2@*.zip.com.au
*** Log file closed: 2/05/98 16:31:32
So master Jeff Wheeler (amagosa) has determined that NT sucks (fair enough,
we all hold differing opinions about different operating systems) and so
removes the ability for a #perl person to ask their question(s). Upon
being told that he's misusing his ban, he promptly bans yours truly.
I suppose I asked for it, really. I mean, pointing out that amagosa was
acting like a spoilt brat with a god-complex was obviously way over the
top. I should have just sat back and gone with the flow. Really, it's
easier that way. Silly me. It's just IRC, who cares anyway?
Well, the silly boy had banned me in a silly incompetent way, so I just
moseyed back in, and got instantly kickbanned for 'ban evasion', a *far*
more serious crime in #perl. One which has the backing of, well, a bot or
two, which those with the previously proved sucking power may get access to
in order to enforce their mighty will, even when they're away from the
channel. C'est la vie, another day, another ban.
A few days later I go to ask a question, or perhaps answer one, in #perl,
and imagine my complete lack of surprise to find that the #perl watchdog
('select') bans me on entry.
*** Log file opened: 5/05/98 6:13:16
select sets mode: +b *!*dac@*.zip.com.au
*** Log file closed: 5/05/98 6:13:16
No problem, change my ident, and come back in whining :-). Several lines
of text go by:
*** Log file opened: 5/05/98 6:14:24
<Dac> Someone should really teach amagosa about ego.
<^Pudge> ex, do you know why you were banned?
<Dac> yes pudge
<Dac> Amagosa got upset when I said that he was a #perl godlet :-)
amagosa sets mode: -o+b Dac *!*freeb@*.zip.com.au
*** Log file closed: 5/05/98 6:15:23
The boy is peeved, and all too ready to give in to hate! I speak with a
few of the #perl regulars, and succeed in nothing -- Amagosa has the god
given right to ban people (after all, someone called him a godlet!) and
he's sticking to his petulant little trigger finger like a demented Biplane
pilot, and is going to ban Excession or Dac or whoever -forever-.
*** Log file opened: 5/05/98 6:20:09
<^Pudge> now, play nice, kids.
<Dac> amagosa: please consider /ignore.Thankyou.
amagosa sets mode: -o+b Dac *!*freeb@*.zip.com.au
*** Log file closed: 5/05/98 6:20:39
About this time I tried to talk with the boy, only to be greeted with stony
silence. Such is life. What else can one expect from a teenager?
He's very proud of his web page (www.chronos.toldyouso.com) and his
'company' and his 'clients', so it would appear that he has some clues
stashed away. But apparently if you attack his gigantic ego, well, he has
the god-given, unrevokable, unarguable right to silence you in a channel
where he is a regular, a wielder of power, and a verified legend in his own
lunchtime.
It's only IRC. It doens't really matter.
But it certainly shows you that the garden of knowledge is polluted by
hyper-arrogant proto-humans with all the considered responsibility of
deranged apes, and the applied common sense of gooney birds.
Amagosa, this one's for you.
Have a nice day.
Dac
aka Excession.
[please note that this was NOT crossposted to alt.flame, or
comp.lang.perl.moderated.flame.the.crap.out.of.the.whiners!]
---
David Andrew Clayton # Please remove NO_SPAM when
dac@NOSPAM.pcug.org.au # sending email replies.
I post therefore I am. #
------------------------------
Date: Mon, 04 May 1998 22:39:21 GMT
From: Bill 'Sneex' Jones <webmaster@fccjmail.fccj.org>
Subject: Re: Adding 600 users to a Linux password file
Message-Id: <354E41DE.85794785@fccjmail.fccj.org>
Wiebe de Wolf wrote:
> First of all: I have to use the Perl4 which is provided by my Internet
I would recommend a new ISP.
> Once again I would like to ask you if there isn't a simple answer - like
> the one I discribed.
No, there isn't a simple answer. Any answer would be very Perl 5 or
very platform specific. So if, based upon the responses recieved,
you could not figure out how to attack it; you should think about
hiring someone to do it.
I have a program which will read an input file in the format of
userid:Real Name Comment:passwd
I have used it to create thousands of users in Linux and Solaris.
However, it is very Perl 5 and requires TCL/Expect.
I also have an old Perl 4 script (from over a year ago when I had
no idea how to even spell perl), I did not write it but hacked it
out of a Perl book I found; it will do basically the same thing.
But after having it nuke my shadow file I decided to write my own.
Let me know via e-mail only if you want to try out the Perl 4
version on your own system...
:-)
-Sneex-
____________________________________________________________________________
Bill Jones | FCCJ Webmaster | Voice 1-904-632-3089 | Fax 1-904-632-3007
Florida Community College at Jacksonville | 501 W. State St. | Jax, FL 32202
mailto:webmaster@fccjmail.fccj.org | http://webmaster.fccj.org/Webmaster
------------------------------
Date: 04 May 1998 17:02:33 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: ANSI Colour in Perl
Message-Id: <m3ra29oa92.fsf@windlord.Stanford.EDU>
John Porter <jdporter@min.net> writes:
> wadr, the correct spelling is the one which finds the package, if you're
> doing a text-based search. 'color' finds it, 'colour' does not.
I'll see about fixing this. :)
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 4 May 1998 23:19:42 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: cd with a perl-script
Message-Id: <6iliee$mi$5@comdyn.comdyn.com.au>
In article <354D7446.250CD97A@stk.co.at>,
Michael Pokerschnig <michael.pokerschnig@stk.co.at> writes:
> Hi,
>
> I want to change to a sub-directory, using a perl script. The script
> calculates this directory using reversal parsing of some softlinks and
> searching for a filename. If the script finds the file it should set the
> current working dircetory
> of the shell from which it was called.
# perldoc perlfaq
# perldoc perlfaq8
I {changed directory, modified my environment} in a perl
script. How come the change disappeared when I exited the
script? How do I get my changes to be visible?
[snip of 8 line signature. You might consider trimming it a bit]
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 4 May 1998 22:08:29 GMT
From: Art Cohen <upsetter@shore.net>
Subject: Re: cgi-lib.pl or CGI.pm?
Message-Id: <6ile8t$3di@fridge.shore.net>
brian d foy <comdog@computerdog.com> wrote:
: In article <354E293A.DBC1FFE@shell.com>, Yong Huang <yong@shell.com> posted:
:>Thanks, Sir. I wonder if you could give me a more specific example or reason
:>why CGI.pm is better than cgi-lib.pl. That is, I don't seme to be fully
:>convinced yet.
: use whatever you want. if you prefer to use ancient technology, it's
: completely up to you. make sure that you use Mosaic to test your
: scripts, though.
Very funny, but of course you know that the browser type wouldn't have any
affect on the script.
And I still haven't seen anyone explain why, exactly, cgi-lib.pl is out of
date (the CGI spec hasn't changed) or what the specific bugs in it are.
I've been using it for years with no problems.
--Art
National Ska/Reggae Calendar: www.ziplink.net/~upsetter/ska/calendar.html
Boston Ska Home Page: www.ziplink.net/~upsetter/ska/index.html
------------------------------
Date: 4 May 1998 22:44:22 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: cgi-lib.pl or CGI.pm?
Message-Id: <6ilgc6$mi$1@comdyn.comdyn.com.au>
In article <354E293A.DBC1FFE@shell.com>,
Yong Huang <yong@shell.com> writes:
> Thanks, Sir. I wonder if you could give me a more specific example or reason
> why CGI.pm is better than cgi-lib.pl. That is, I don't seme to be fully
> convinced yet.
What is unconvincing about CGI.pm being more reliable, less buggy,
still supported, part of the standard distribution, having better
debugging capabilities, being more flexible? What is unconvincing of
CGI.pm even having a cgi-lib 'compatibility' mode which allows you to
still use your old code? I don't get it. Did you read any of responses
you got?
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Tue, 05 May 1998 09:24:02 +1000
From: Graham Wallace <graham@contact.com.au>
Subject: condition to subroutine
Message-Id: <354E4E11.7E8BCE50@contact.com.au>
In a newbie and having a lot of fun with perl. But after doing what I
thought was a simple condition to subroutine line I have come up to a
brick wall. I can't find the answer in any of the books or data bases I
have searched.
What I would like to do is is a simple jump to a subroutine on a
specific condition like
If $variable eq "xyz" { &subroutine }
I keep getting coding errors for this line, I'm sure there is a simple
way around it, but I can't find it. Please help
Graham
------------------------------
Date: Mon, 04 May 1998 19:29:17 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: Graham Wallace <graham@contact.com.au>
Subject: Re: condition to subroutine
Message-Id: <354E4F4D.2D12@juicepigs.com>
Graham Wallace wrote:
>
> In a newbie and having a lot of fun with perl. But after doing what I
> thought was a simple condition to subroutine line I have come up to a
> brick wall. I can't find the answer in any of the books or data bases I
> have searched.
>
> What I would like to do is is a simple jump to a subroutine on a
> specific condition like
>
> If $variable eq "xyz" { &subroutine }
>
> I keep getting coding errors for this line, I'm sure there is a simple
> way around it, but I can't find it. Please help
A statement just isn't a statement without the great taste of semicolon.
if (...) { &sub(); } or &sub() if (...);
If you are passing no value to the subroutine throw some empty
parenthesis on there for decoration and don't forget your semicolon.
HTH
--
Bob Trieger | Titanic: big boat, bigger
sowmaster@juicepigs.com | iceberg, big deal
------------------------------
Date: 04 May 1998 20:22:26 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Graham Wallace <graham@contact.com.au>
Subject: Re: condition to subroutine
Message-Id: <sompldf1.fsf@mailhost.panix.com>
Graham Wallace <graham@contact.com.au> writes:
> If $variable eq "xyz" { &subroutine }
That line isn't in Perl. "if" is a keyword, spelled in lower case
only. The conditional phrase of an "if" structure must be in
parentheses. This is documented in perlsyn.
C:\> perldoc perlsyn
But you really ought to be reading the book _Learning Perl_ instead.
if ($something eq 'xyz') { &subroutine }
or
&subroutine if $something eq 'xyz';
# no parens needed when used as modifier
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 04 May 1998 16:52:46 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: CPAN & Module gripes (was Re: Ever Wonder...?)
Message-Id: <m3u375oapd.fsf@windlord.Stanford.EDU>
Ilya Zakharevich <ilya@math.ohio-state.edu> writes:
> Why do you care? Just
> perl -MCPAN -e 'install "Bundle::libwww"'
Am I the only person who thinks this sort of automagic installation
process being proposed as the solution for all ills sounds more like
Microsoft than like Perl?
Don't get me wrong. CPAN.pm is a wonderful thing, and I've recommended
that friends of mine use it to get modules they need. I've never used it,
though, because I have my own ideas on how to handle local source trees,
thanks much, and can do without CPAN.pm building new ones for me. One
can't have one's cake and eat it too; CPAN.pm works great if you *want*
automagic, but CPAN should be usable for those of us who *don't* want
automagic as well.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 4 May 1998 23:41:17 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Creating a text file from form variables
Message-Id: <6iljmt$10n$2@comdyn.comdyn.com.au>
In article <354DB097.E79D1C62@es.co.nz>,
Matt McKenzie <jasmatt@es.co.nz> writes:
> ok....here's a tricky one
how is it tricky?
> 1. I want to take two variables from a form. i.e $username and $password
use CGI;
> 2. Use a small perl script to create a .txt file named after the
> $username. i.e. username.txt.
# perldoc -f open
# perldoc -f print
# perldoc -f close
> 2. chmod the text file to 666
# perldoc -f chmod
> 3. insert 2 lines into the .txt file containing the $username and
> $password.
# perldoc -f open
# perldoc -f print
# perldoc -f close
# perldoc perlfaq5
How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the
beginning of a file?
> 4. place this file in a specified dir.
open it in the right directory to start with. Why do you want to
create it somewhere else than where it actually has to live?
use File::Copy;
# perldoc -f unlink
if it's on the same file system, you can probably use
# perldoc -f rename
> I've had some documentation to do this, but for the life of me I can't
> find it again.
Errr... It comes with perl. See above.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 4 May 1998 23:01:57 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Determining Disk Space
Message-Id: <6ilhd5$mi$2@comdyn.comdyn.com.au>
In article <6ij5bj$qas$1@news2.triton.net>,
"Jeff Wilcox" <jeff@jwpc.com> writes:
> I'm trying to calculate how much disk space is taking in a directory and all
> of it's subdirs.. What's the fastest way to calculate this?
The fastest way is probably by using one of the tools that comes with
the OS. The fastest way in perl is probably by opening each directory,
counting blocks or bytes (whichever you want to know about), and
recursing down into the structure. Of course, you will need to take
all the quirks of your OS's file system into account: do you want
symlinks followed? Do you want the number of bytes that the files take
up on disk, or do you want the file sizes?
Anyway, there was a thread about this recently. read that.
http://www.dejanews.com/
search: "~g comp.lang.perl.misc & ~s disk space
Martien
PS. next time, maybe you should try dejanews first. You are bound to
not be the first one to ask a basic question like that.
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 4 May 1998 23:16:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Directory usage in Perl for win32
Message-Id: <6ili8g$mi$4@comdyn.comdyn.com.au>
In article <Pine.NXT.3.96.980503235221.29753A-100000@support.tamu.edu>,
Mike Marziani <marz@tamu.edu> writes:
> use File::Find;
> @ARGV = ('.') unless @ARGV;
> my $sum = 0;
> find sub { $sum += -s }, @ARGV;
> print "@ARGV contains $sum bytes\n";
That looks remarkeably like something that I once saw attributed to
Tom Christiansen. I am glad you think so much along the same lines :)
> But what is the best way to read in the list of directories and apply this
> function to each directory in turn? I am sort of new to perl (but not to
> programming) so if this is some info readily available in the docs, please
> point me to it.
# perldoc -f opendir
# perldoc -f readdir
# perldoc -f closedir
> Thanks in advance,
No problem,
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Mon, 04 May 1998 19:49:11 -0500
From: Mohammad Razzak <mrazzak@cse.unl.edu>
Subject: Embedded systems programming
Message-Id: <354E6207.28E1@cse.unl.edu>
Hi!
Can anybody enlighten me on the concept of Embedded systems programming?
Some explanations with examples would be appreciated.
Regards;
naim
------------------------------
Date: 04 May 1998 16:47:35 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <m3wwc1oay0.fsf@windlord.Stanford.EDU>
Brian Mathis <brianm@kodak.com> writes:
> I'm sorry for the inconveinence. I usually send an email reply, as well
> as a newsgroup one, for courtesy of the original poster. [...] Quit
> your whining, it's not like you were spammed or anything.
Go get a dictionary and look up the word "courtesy."
E-mail cc's of posted articles that do not indicate clearly that they have
also been posted are inherently evil, and people who do that fully deserve
to be yelled at.
As for the original topic of this thread, I agree with Tom; why not just
pipe through sendmail? It's considerably more reliable, more portable on
Unix machines, and certainly just as secure.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 4 May 1998 23:49:50 GMT
From: millerb@millerb.fc.hp.com (Bryan Miller)
Subject: Re: Hello people, want to learn Perl ?
Message-Id: <6ilk6u$bsu@fcnews.fc.hp.com>
Eric Hagen (ehagen@Hawaii.Edu) wrote:
: Could be an interesting study in "most common mistakes made" though.
: I'm a "newbie" myself, and I laugh at scripts I made half a year ago.
: I know this has been covered time and time again. BUT.
: I have searched the net for a cookbook style site, while the docs are
: GREAT, and there is a lot out there, I really would love to see a site
: that has a starting example, then a list discussion fo the pros and cons
: of the topic, and different ways of doing it.
Actually there is a Perl Cookbook coming out via O'Reilly authored
by Tom Christiansen & Nathan Torkington that is meant to be out by August.
Probably worth the wait...
Bryan
------------------------------
Date: Tue, 05 May 1998 00:48:20 GMT
From: Bill 'Sneex' Jones <webmaster@fccjmail.fccj.org>
Subject: Re: Hello people, want to learn Perl ?
Message-Id: <354E6018.63ACB21A@fccjmail.fccj.org>
Bryan Miller wrote:
>
> Actually there is a Perl Cookbook coming out via O'Reilly authored
> by Tom Christiansen & Nathan Torkington that is meant to be out by August.
> Probably worth the wait...
>
> Bryan
My local Barnes & Nobles is a little slow
on the ordering & shipping process :(
-Sneex-
____________________________________________________________________________
Bill Jones | FCCJ Webmaster | Voice 1-904-632-3089 | Fax 1-904-632-3007
Florida Community College at Jacksonville | 501 W. State St. | Jax, FL 32202
mailto:webmaster@fccjmail.fccj.org | http://webmaster.fccj.org/Webmaster
------------------------------
Date: 04 May 1998 18:41:03 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Keith Vertrees <keith@comcore.com>
Subject: Re: How do I reuse functions in several programs?
Message-Id: <bttdy580.fsf@mailhost.panix.com>
Keith Vertrees <keith@comcore.com> writes:
> This is a multi-part message in MIME format.
> --------------A24E06DEA59FCEC0E35B3A41
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
Please go to your Netscape settings and tell it to turn off MIME
posting. Most of us strongly prefer to read plain text.
> If I want to write a subroutine that is used in multiple Perl
> programs, how do I do it?
Exactly as outlined in the perlmod document.
C:\> perldoc perlmod
> Modules seem like they might be the answer, but all that I can
> "easily" find out about modules is that they go into files with a
> .pm suffix.
By "easily," you seem to mean, "without reading the docs!"
> How do I tell my Perl program where it can file the file
> that has the .pm suffix so that it can use the function from the file
> with the .pm suffix?
See several questions in perlfaq8, beginning with "How do I keep my
own module/library directory?"
> From what I can tell about modules, they're written by really smart Perl
> people to do all kinds of systemy stuff, but they're hard for a novice
> user to deal with.
Well, it's true that in order to *cluefully* create a new Perl module,
it's helpful to know about symbol tables, BEGIN blocks, and other
topics that are more advanced than, say, the print() builtin.
However, anyone can copy and paste the module template given in the
perlmod doc, and thereby create a working module. I don't *recommend*
that you do so until you get an understanding of how it works.
> Tell me I'm wrong...
I'll tell you that I disagree with you. I think that your expectation
that creating a module be one of the "easy" things (in Larry Wall's
scheme) is not realistic. Take your time, read the Llama all the way
through, read the Camel many times, and learn.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 5 May 1998 00:03:51 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How do I reuse functions in several programs?
Message-Id: <6ill17$15a$1@comdyn.comdyn.com.au>
In article <354E2ECD.4D06F7A4@comcore.com>,
Keith Vertrees <keith@comcore.com> writes:
> This is a multi-part message in MIME format.
> --------------A24E06DEA59FCEC0E35B3A41
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
Please don't do this, Usenet is a plain text medium. vcards don't have
any meaning here.
>
> I'm new to Perl, and while I can see how it really does make some stuff
> that should be easy easy, it seems to make some easy stuff hard. If I
> want to write a subroutine that is used in multiple Perl programs, how
> do I do it? Modules seem like they might be the answer, but all that I
> can "easily" find out about modules is that they go into files with a
> .pm suffix. How do I tell my Perl program where it can file the file
> that has the .pm suffix so that it can use the function from the file
> with the .pm suffix? In C, this would be accomplished by linking a .o
> file or via a #include statement.
Read the following:
# perldoc perlsub
# perldoc perlmod
# perldoc -f use
# perldoc -f require
# perldoc -f do
You'll find that writing a module doesn't need any wizardry. In your
case it might be simpler to just use 'require' or 'do', although the
experience of writing a module might be a good thing.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Mon, 04 May 1998 22:08:07 GMT
From: MICHAEL KOGAN <michealj@bellsouth.net>
Subject: Interactive Chem Test
Message-Id: <354E3C47.4545DBBD@bellsouth.net>
--------------ECFEE8C7AE311948BC4472A7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I have no idea about how to begin but perhaps some kind person might
help
I'm look for a template that I can enter questions into and have
students practice their
chemistry homework. There a lots of sites out there with questions but
an interactive
question base with instant feed back would be "the great leap forward"
for high school students. Any Ideas where I can find something simple?
--------------ECFEE8C7AE311948BC4472A7
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
I have no idea about how to begin but perhaps some kind person might help
<BR>I'm look for a template that I can enter questions into and have students
practice their
<BR>chemistry homework. There a lots of sites out there with questions
but an interactive
<BR>question base with instant feed back would be "the great leap forward"
for high school students. Any Ideas where I can find something <B><I>simple</I></B>?</HTML>
--------------ECFEE8C7AE311948BC4472A7--
------------------------------
Date: 04 May 1998 18:47:28 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: edb@interport.net
Subject: Re: is it possible to parameterize a class name?
Message-Id: <90ohy4xb.fsf@mailhost.panix.com>
fakeuser@fakemail.com (Ed.Q.Bridges) writes:
> i'd like to do something like this:
>
> #!/usr/bin/perl
> $class_name = shift;
> use ($class_name);
This has been asked a bunch of times recently. Maybe it ought to be
added to the FAQ list... Search DejaNews for the subject line
"*Really* dynamic function loaing?" There's a thorough answer in that
thread. You should also
C:\> perldoc -f use
which will explain to you that use Foo; is a synonym for
BEGIN { require Foo; import Foo }
> please cc responses to edb@interport.net
You'd make that a lot easier if you wouldn't put that silly fake
address in your headers.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 4 May 1998 23:11:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Length of a variable
Message-Id: <6ilhvo$mi$3@comdyn.comdyn.com.au>
In article <millers3-0305982239430001@d173.pm5.sonic.net>,
millers3@sonic.net (Leonard Miller) writes:
> $length = rindex($foo,"");
Very creative, and only slightly slower than length().
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 4 May 1998 23:36:31 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Max length of a string
Message-Id: <6iljdv$10n$1@comdyn.comdyn.com.au>
In article <6ikfgr$7vj$1@ratatosk.uio.no>,
kjetil.skotheim@usit.uio.no (Kjetil Skotheim) writes:
> In short: Using one 20MB string fails, but 50 1MB strings is ok.
>
> Any explaination to this?
Maybe that one 20 MB string requires a malloc of 20 MB, which needs 20
MB of contiguous memory. 50 strings of one MB need 50 mallocs of 1 MB,
which will use 50 blocks of 1 MB memory.
Your system probably just didn't have one clean block of 20 MB free at
that moment.
I haven't actually looked at the perl code, but I suspect that that is
the underlying problem.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Mon, 4 May 1998 20:05:22 -0400
From: "Mad Max" <needcrew@tiac.net>
Subject: Padding a string to be a fixed length
Message-Id: <6ill3o$oov@news-central.tiac.net>
I am new to perl and am trying to figure out how to pad a string with spaces
to be a fixed length. I.E.
$data = "My test String";
$leftOver = length($data) - $maxLength
I then want to add $leftOver number of spaces to the string.
Thanks
MIke
------------------------------
Date: 04 May 1998 20:25:49 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: "Mad Max" <needcrew@tiac.net>
Subject: Re: Padding a string to be a fixed length
Message-Id: <pvhtld9e.fsf@mailhost.panix.com>
"Mad Max" <needcrew@tiac.net> writes:
> I then want to add $leftOver number of spaces to the string.
You want the x operator, documented in perlop (and in _Learning
Perl_).
$string .= ' ' x $leftOver;
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Mon, 4 May 1998 22:22:19 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Passing type AV * ?
Message-Id: <EsGE57.FEq@news.boeing.com>
In article <354CBFF6.41C67EA6@cs.yale.edu>,
Kaleem Siddiqi <siddiqi-kaleem@cs.yale.edu> wrote:
>> ....
>> av_store(array, xx + yy * width, SvREFCNT_inc(val));
>>
>
>Thanks for the tip! Can you tell me why its necessary
>to increment the reference count to val, i.e., SvREFCNT_inc(val) ?
>
Purely a guess, but, the garbage collector seems to get
a bit too zealous if you don't do this. Here's what use
diagnostics and -w reveals if you don't bump the ref
count:
Attempt to free unreferenced scalar at ./test.pl line 20 (#1)
(W) Perl went to decrement the reference count of a scalar to see if it
would go to 0, and discovered that it had already gone to 0 earlier,
and should have been freed, and in fact, probably was freed. This
could indicate that SvREFCNT_dec() was called too many times, or that
SvREFCNT_inc() was called too few times, or that the SV was mortalized
when it shouldn't have been, or that memory has been corrupted.
HTH,
--
Charles DeRykus
------------------------------
Date: 4 May 1998 23:26:03 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl Randomness Question..any pointers?
Message-Id: <6iliqb$mi$6@comdyn.comdyn.com.au>
In article <6ijva1$54r@suriname.earthlink.net>,
mercuryz@mail.alabanza.com (MercuryZ) writes:
> course shows up in the address field. Is it possible to have
> the address field show 12we4rf.cgi and still point to area1_1a.cgi?
You mean you've got different cgi's for different areas? Oh well.
Simply rename the file. Use symbolic links. Use some URI translation
features of your web server. Use one main cgi that executes others.
Neither of these have anything at all to do with perl. You should ask
this in one of the comp.infosystems.www.* groups.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Mon, 04 May 1998 14:58:57 -0700
From: JDS <xxx@xxx.xxx>
Subject: perlio.h error using cc??
Message-Id: <354E3A21.78DDEA68@xxx.xxx>
We just installed 5.004.04 on Solaris.
I'm trying to compile and run a simple C test
that #includes perl.h.
Using CC, I get syntax error on line 137 of perlio.h.
If I use GCC all is fine.
Can I still use CC with 5.004.04?
thank you,
JDS
------------------------------
Date: Mon, 4 May 1998 18:39:50 -0600
From: "Nervick" <nervick@bewellnet.com>
Subject: Personal Web Server
Message-Id: <354e5fd5.0@news.bewellnet.com>
I'm using MS Personal Web Server on my computer at home. I have made the
correct associations is the "Script Map" part of the registry, and have
execute permissions in the correct directories. The problem is that
'require( "cgi-lib.pl" )' doesn't work! the following message appears:
cannot locate cgi-lib.pl in @INC.
The file is in the correct directory and the file is called "cgi-lib.pl" not
"CGI-lib.pl" or "Cgi-Lib.pl". I looked at @INC and it is as it should be. I
don't know what's wrong! Please help!
------------------------------
Date: 4 May 1998 23:25:42 GMT
From: jhtodd@students.uiuc.edu (jeremy howard todd)
Subject: Re: Pre-extending a hash?
Message-Id: <6ilipm$knu$1@vixen.cso.uiuc.edu>
Tom Phoenix <rootbeer@teleport.com> writes:
>If you have a rough idea of how many hash buckets you'll need, you may
>assign to keys(%hash) directly. (If you don't know what hash buckets are,
>don't worry; just use the number of keys you'd expect.)
Thanks, I thought this was just what I was looking for, but I
noticed practically no speedup for 100,000+ elements, and I'd rather not
overestimate and allocate more space than is strictly necessary. The slow
bits must be somewhere else...
-jht
--
Jeremy Todd Computer Programmer _,/
jhtodd@uiuc.edu ITCS On-line Development <__ \_.---.
http://www.cen.uiuc.edu/~jhtodd/ College of ACES, UIUC \_ / \
Zupfe Boy and Night Owl (And Kangaroo Aficianado) \)\ /\.\
=========================================================== // \\
"M-O-O-N, that spells moon" - Tom Cullen ,/' `\_,
------------------------------
Date: Mon, 04 May 1998 16:52:53 -0600
From: rpearce@fastlane.net
Subject: Re: Splain a regex to me
Message-Id: <6ildbm$ul3$1@nnrp1.dejanews.com>
In article <6ikjdn$u0j$1@nnrp1.dejanews.com>#1/1,
kathryn.nelson@usa.net wrote:
> i.e. /[ab].+:(\s*)/
> "starts with the letter a or b followed by one or more characters followed
> by a colon and zero or more whitespaces which are remembered as $1..."
>
I'm not positive, but the above would find the pattern whether it started with
a or b, or if a or b started in the middle of the string.
/^[ab].+:(\s*)/ would limit it to "starts with a or b".
Right?
Rick...
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 4 May 1998 15:02:36 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: sum/display sparse 3D array
Message-Id: <6ildu4$44d@hplntx.hpl.hp.com>
RHS Linux User wrote in message
<6ilbco$9p5$1@armitage.nervana.montana.edu>...
>THE GOAL:
> For a list of files that represent sparse 3D arrays
>(of 100 x 100 x 100 integers) sum the values of all indecies that
>contain a value. Ignore those indecies that contain no value in any
input file.
>
>PUNCHLINE:
>Is there a way to display the sums without indexing
>through all 1,000,000 possible slots, where (because these are sums of
sparse
>arrays that are geometrically similar) most indecies have no value.
There is a capability called multi-dimensional array emulation that is
made-to-order for this purpose notationally. See the description of the
"$;" ($SUBSCRIPT_SEPAATOR) variable, Blue Camel p. 133.
However, as recommended there, you should probably instead build hashes
of (refs to) hashes of (refs to) hashes, where the hash keys are the
appropriate indices for each dimension of the array. Then you can loop
over the keys of each hash appropriately.
See 'Hashes of Hashes', p. 270, or perldoc perldsc.
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 5 May 1998 00:45:20 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Translating crontab(5) file to a format that can be compared to dates
Message-Id: <894329119.495442@elaine.drink.com>
I'm looking to read in a crontab(5) file, and use this in some date
math, then re-write the crontab file based upon the adjusted times.
I'm sure I'm not the first person to do this, but I cannot find any
pre-existing module to do this on CPAN, or anywhere else.
Anyone got existing code which isn't on CPAN, or shall I start rolling
my own?
------------------------------
Date: Mon, 04 May 1998 17:36:22 -0600
From: npolonsk@hotmail.com
Subject: trouble with Win32::Process
Message-Id: <6ilft7$228$1@nnrp1.dejanews.com>
I am trying to launch a download program by creating a new process. The
download program takes the download script as a variable.
When done by hand I can launch the program with the script file as the
varible and the download program opens up and starts the script file.
The program is called Procomm Plus (from quarterdeck) if I can't get a
response here, I'll be forced to drag information out of their support group
(which really isn't that bad).
The program launches, but doesn't start the script file. It's as if I'm doing
something wrong with the arguments part of the syntax for Win32::Process.
The script file is amb.wax
Any help will be appriciated!
--Nathan
Here's the code:
use Win32;
use Win32::Process;
Win32::Process::Create($p,"c:\\progra~1\\procom~1\\programs",
"c:/prg/src/amb/amb.wax",
1,CREATE_NEW_CONSOLE,
"c:\\prg\\src\\amb");
$p->Wait(INFINITE) || die $!;
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
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 2496
**************************************