[6666] in Perl-Users-Digest
Perl-Users Digest, Issue: 291 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 13 03:07:17 1997
Date: Sun, 13 Apr 97 00: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 Sun, 13 Apr 1997 Volume: 8 Number: 291
Today's topics:
Any PERL can ignore ^Z characters? (J.T. Daugirdas)
Re: Any PERL can ignore ^Z characters? <rra@stanford.edu>
Re: CGI Module - I have a syntax problem. (David Alan Black)
Re: Getting single keystroke (Joshua Lerner)
Re: Getting single keystroke (D. Black)
HELP: FormMail problems! <PleaseReply@This.NG>
How can I create a C extension to Win32 Perl? (McWilliams)
Re: If Else construct? (Steven W McDougall)
Re: Learning Perl <critter@quack.kfu.com>
Re: Parsing a file backwards (Sitaram Chamarty)
Re: Reply to Ousterhout's reply (was Re: Ousterhout and (Henry Baker)
Re: Transliterate from a pattern? <dbenhur@egames.com>
Re: Transliterate from a pattern? <ajohnson@gpu.srv.ualberta.ca>
Re: Unix and ease of use (WAS: Who makes more ...) (Colin Smith)
Re: Unix and ease of use (WAS: Who makes more ...) (Jettero Heller)
Re: What does "UNIX" stand for.. <imbe@primenet.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Apr 1997 02:52:22 GMT
From: medtext@wwa.com (J.T. Daugirdas)
Subject: Any PERL can ignore ^Z characters?
Message-Id: <5iphp6$3md$2@kirin.wwa.com>
My server is slow, so I ftp my cgi scripts down to my PC and work on
them there using a DOS editor. When I ftp them up, they always
bomb, so I have to go in and delete the ^Z in pico. Apparently
even after the exit; command, the ^Z still bothers PERL.
Doesn't PERL have any command which says "ignore what follows
after this line?"
John Daugirdas
jtdaugir@medtext.com
------------------------------
Date: 12 Apr 1997 21:05:47 -0700
From: Russ Allbery <rra@stanford.edu>
To: medtext@wwa.com (J.T. Daugirdas)
Subject: Re: Any PERL can ignore ^Z characters?
Message-Id: <qumvi5rh8is.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
J T Daugirdas <medtext@wwa.com> writes:
> My server is slow, so I ftp my cgi scripts down to my PC and work on
> them there using a DOS editor. When I ftp them up, they always bomb, so
> I have to go in and delete the ^Z in pico. Apparently even after the
> exit; command, the ^Z still bothers PERL.
> Doesn't PERL have any command which says "ignore what follows after this
> line?"
All text after a line which reads simply:
__END__
is ignored by Perl.
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 13 Apr 1997 02:12:28 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: CGI Module - I have a syntax problem.
Message-Id: <5ipfec$r6j@pirate.shu.edu>
Hello -
gdaswani@mail.odc.net (George Henry C. Daswani) writes:
> if ( $cgi_query->param('$item') eq "" ){
The single quotation marks are causing the expression to
be evaluated as a literal string (namely, '$item').
If you want the value of $item, just use:
...param($item)...
David Black
dblack@icarus.shu.edu
------------------------------
Date: 12 Apr 1997 22:47:13 -0400
From: jlerner@panix.com (Joshua Lerner)
Subject: Re: Getting single keystroke
Message-Id: <5iphfh$1ok@panix3.panix.com>
In article <5ip2bd$njk@argentina.earthlink.net>,
root <root@localhost.localdomain> wrote:
>It's outrageous that perl doesn't have a built-in function to get single
Outrageous?
>I've wasted the last few hours downloading, installing, and trying to
>figure out how to use the term::ReadKey perl module from CPAN. If someone
>could explain this to an irritated newbie, I give my thanks in advance.
Calm down, friend. Read the perlfunc man page (you'll need Perl 5) a
little more closely:
getc Returns the next character from the input file
attached to FILEHANDLE, or a null string at end of
file. If FILEHANDLE is omitted, reads from STDIN.
This is not particularly efficient. It cannot be
used to get unbuffered single-characters, however.
For that, try something more like:
if ($BSD_STYLE) {
system "stty cbreak </dev/tty >/dev/tty 2>&1";
}
else {
system "stty", '-icanon', 'eol', "\001";
}
$key = getc(STDIN);
if ($BSD_STYLE) {
system "stty -cbreak </dev/tty >/dev/tty 2>&1";
}
else {
system "stty", 'icanon', 'eol', '^@'; # ascii null
}
This sample code worked for me. Of course, this assumes you are using
Unix (original _or_ extra krispy).
Good luck,
Joshua Lerner
------------------------------
Date: 12 Apr 1997 21:46:14 -0700
From: alecto@arlington.pe.net (D. Black)
Subject: Re: Getting single keystroke
Message-Id: <5ipoem$rg2@arlington.pe.net>
root (root@localhost.localdomain) wrote:
>It's outrageous that perl doesn't have a built-in function to get single
>keystroke input from the keyboard. Thompson Automation's awk compiler
>(TAWK) has getkey() and even QBasic has inkey$ to do the trick.
>I've wasted the last few hours downloading, installing, and trying to
>figure out how to use the term::ReadKey perl module from CPAN. If someone
>could explain this to an irritated newbie, I give my thanks in advance.
#! /usr/bin/perl
print "\tType all ya want, only the first keystroke counts... \n";
($a,@rest) = split //,<STDIN>;
print "first letter was: $a\n";
------------------------------
Date: Sat, 12 Apr 1997 22:11:21 -0400
From: Peter Myers <PleaseReply@This.NG>
Subject: HELP: FormMail problems!
Message-Id: <335040C9.4DC3@This.NG>
I am using FormMail V-1.5 written in Perl, on a UNIX host server which
implements the sendmail program. I am having the following problems:
1) I placed a textarea box on my HTML form as follows:
<TEXTAREA NAME="Notes" COLS="55" ROWS="6" WRAP="PHYSICAL"></TEXTAREA>
The text written in this text box, only wraps on the HTML form. How
do I
get it to show up wrapped in my E-Mail message?
2) This is the line from the FormMail script, which puts the E-Mail and
Name into the "From:" field in the header of the E-Mail message.
print MAIL "From: $CONFIG{'email'} ($CONFIG{'realname'})\n";
These are the lines in the HTML form, which are to be set:
<input type=text name="realname">
<input type=text name="email">
I don't want to use the email field, just the realname field.
I want to have the "From:" field show either of the following:
A) A certain value which I choose, ie: "From: My Web Site Form"
B) I'd like to use one or combine both of the "Name" fields from
the HTML form, and have them show in the "From:" header.
These are the input fields I'm using:
<INPUT TYPE="text" NAME="First Name">
<INPUT TYPE="text" NAME="Last Name">
When I try to change the script, the resulting E-Mail message
displays
the E-Mail address of my Host Server, followed by the realname
field.
It also places periods in any spaces between names. If I leave the
E-Mail
field blank or delete it from the script, It displays nothing at
all.
3) FormMail has an HTML page which displays the required fields that
were left
blank after filling out the form. At the bottom of this page is a
link (which
I specify) to return you back to the form to fill it out again. The
problem is
that when clicked, this link returns you back to the bottom of the
form (or
whatever position your form page was in when you submitted it) and
also
clears (resets) the form. Instead of just entering the fields you
left blank,
you now must fill out the entire form again.
Thank you for your time, I'd appreciate any help!
Please respond to this newsgroup.
Thanks, Peter M.
------------------------------
Date: Sun, 13 Apr 1997 02:56:18 GMT
From: len@clark.net (McWilliams)
Subject: How can I create a C extension to Win32 Perl?
Message-Id: <5iphq5$3c8@clarknet.clark.net>
I'm have a short piece of C code I would like to include in a Perl Win
32 script. I've looked at perlxstut in an attempt to understand how to
do this. Unfortunately the h2xs utility referred to in perlxstut is
not part of my Win32 Perl installation (5.003_7 build 303). I've
installed gnu_win32 on my system.
Could someone give me some guidance as to how to proceeed from here?
Thanks,
Len McWilliams
Frederick, MD
------------------------------
Date: Sun, 13 Apr 1997 02:53:44 GMT
From: swmcd@world.std.com (Steven W McDougall)
Subject: Re: If Else construct?
Message-Id: <E8K2pK.LwF@world.std.com>
In comp.lang.perl.misc you write:
>> > I usually avoid religious discussions, but I have to do a little
>> > proselytizing here. || can be a bit cryptic to the uninitiate, and has
>> > precedence problems besides. But in perl5 you can write
>> >
>> > $arg eq "-n" or $arg = "-n"
>Um, what about
> $arg = '-n'; # ;-)
Ya got me! All I saw was the control structure; I didn't stop to think
about what the code was actually doing.
>Sure, when the logic is simple this is fine.
And that's where I'm advocating the use of the and/or constructs: for
the simple logic that routines use for ordinary housekeeping tasks:
error checking, parameter conversion, handling boundary cases, etc.
>Now, do:
> if ($x == 7 && $n == 8) {
> if ($y == 4) {
> $z = 100;
> } elsif ($y == 80) {
> $z = 200;
> } elsif ($a < 10) {
> $z = 400;
> }
> } else {
> $y = $a - 200;
> $z = 20;
> }
I agree: this is better as if-else than and/or.
And if this chain of conditions is intrinsic to what your program
does, then if-else is entirely appropriate.
But if I really ran across code like this in a program,
my first suspicion would be that someone had coded up something in
some badly-chosen integers, and that a better data representation
would simplify the logic.
- SWM
------------------------------
Date: Sat, 12 Apr 1997 18:53:38 -0700
From: "Charles F. Ritter" <critter@quack.kfu.com>
Subject: Re: Learning Perl
Message-Id: <33503CA2.D66ED27@quack.kfu.com>
Sriranga R. Veeraraghavan wrote:
>
> My only question is how anyone could get tired of reading
> either the llama book or the camel book. I started learning
> perl two years ago when my mom gave me her perl books. I
> couldn't put them down, perl stopped the pain of shell and awk.
>
> The only other programming book that I have every had as much
> fun reading and doing the problems in was Peter Van der Linden's
> Expert C Programming. I'm hoping that he does a crossover with
> Larry Wall and Randal Schwartz called Expert Perl Programming, with
> a long chapter on obfusicated perl.
>
> ----ranga <sveerara@cisco.com>
Brown noser! :-)
Just kidding. The camel book is pretty good even among the outstanding
O'Reilly animal book series. I had cause - I think - to read some of the
Exploring Expect book. It bored me to tears. Maybe if expect were as
easy to find/install as perl I would have been better able to humor
myself with all of the nice examples.
P.S. Is Randal spoofing someone's news server? ;-)
--
Charles Ritter
Microsoft NT - when they are finally finished it will be the best
documented unix operating system on the market.
------------------------------
Date: Sun, 13 Apr 1997 03:33:09 GMT
From: sitaram@diac.delete.com (Sitaram Chamarty)
Subject: Re: Parsing a file backwards
Message-Id: <33505306.396881204@news.diac.com>
Eryq <eryq@enteract.com> wrote:
>Heather wrote:
>>
>> How do I open a file from within a perl script and parse it from the
>> bottom up, as opposed to top down, which seems to be the default.
>>
>> Thanks,
>> Heather
>
> open FILE,"yourfile" or die "open: $!";
> @lines = reverse(<FILE>);
> close FILE;
>
>Now go through the @lines. Hope you have enough core!
The reverse operation will build an array first, then reverse it into
the @lines array. I *think* its better (memory wise) to do:
open FILE......blah blah
@lines = <FILE>;
while (defined($_ = pop @lines))
{
do your stuff...
}
or
open .....
while (<FILE>)
{
unshift(@lines, $_);
}
(do your stuff on @lines here)
-------------------------------------
Sitaram Chamarty
delete the word "delete" from the domain name - as I'm sure you've
guessed - to get my email address.
Recent spammers who sent me UCE:
mike@icorp.net
voe@icorp.net
------------------------------
Date: Sun, 13 Apr 1997 07:38:31 GMT
From: hbaker@netcom.com (Henry Baker)
Subject: Re: Reply to Ousterhout's reply (was Re: Ousterhout and Tcl ...)
Message-Id: <hbaker-1204972338310001@10.0.2.1>
In article <5ip5km$qhh$1@news.utdallas.edu>, mharriso@utdallas.edu (Mark A
Harrison) wrote:
> Henry Baker (hbaker@netcom.com) wrote:
> : You make a good point about the importance of environments. That's
precisely
> : the advantage of Lisp. You get a uniform picture of the world -- everything
> : is Lisp. You don't have to know anything about machine language,
assemblers,
> : linkers, and all plethora of itty bitty 'tools' with <3-character names.
> : You have the same language for writing macros, the same language for writing
> : system code, the same language for writing scripts, the same language for
> : writing editor extensions, the same language for interacting with windows,
> : etc.
>
> I think this is what was responsible for the diminishing influence
> of Lisp... It's all-or-nothing, violating the principle "interoperate
> or die."
Well, Lisp _is_ a jealous god. You want productivity, and I told you how to get
it. If that means not cluttering up your system with 25 languages, then you
won't do it if you want productivity.
You start falling prey to a 'productivity' form of Amdahl's Law:
If you are programming in Lisp and another language (C++, say), and about
50% of the system is written in each, then even if Lisp has _infinite_
productivity, you've only speeded things up by a factor of 2. Thus, even
a little bit of a non-Lisp language can really throw a monkey wrench into
the system, given that Lisp is so much more productive than non-Lisp. You
therefore need to _minimize_ the amount of non-Lisp code in order to maximize
your productivity.
Note that adding non-Lisp _libraries_ still screws you up, because a non-Lisp
library can corrupt your memory just as badly as if you weren't running Lisp
at all. Thus, all your productivity goes down the drain as you hunt for the
dangling reference caused by the non-Lisp library.
Number One Myth in Computer Science Today: 'All high level languages are
essentially alike, with only minor variations in productivity'.
This is the Big Lie promulgated by C/C++, because it convinces management
that there is little to be gained by utilizing a language like Lisp or
Smalltalk or Prolog.
The truth is that there are tremendous variations in the productivity of
different languages. Did you ever notice how nearly all of the studies
of this issue conveniently leave out Lisp, Smalltalk and Prolog?
------------------------------
Date: Sat, 12 Apr 1997 01:07:55 -0700
From: Devin Ben-Hur <dbenhur@egames.com>
To: Jeff Vannest <jefflv@tir.com>
Subject: Re: Transliterate from a pattern?
Message-Id: <334F42DB.6459@egames.com>
[mail&post]
Jeff Vannest wrote:
> It's not even really a transliteration; I want to delete leading and
> trailing spaces from a string.
[snip clunky code]
> but it looks WAY too clunky for me (although it works).
This is generally considered the clearest and most
efficient way to strip leading & trailing spaces from
a string:
$str =~ s/^\w+//; $str =~ s/\w+$//;
If you really mean spaces only and not general whitespace,
change the \w to a space.
HTH
--
Devin Ben-Hur <dbenhur@egames.com>
eGames.com, Inc. http://www.egames.com/
eMarketing, Inc. http://www.emarket.com/
"It's people like you wot cause unrest!"
------------------------------
Date: Sat, 12 Apr 1997 22:02:44 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Transliterate from a pattern?
Message-Id: <33504CD4.19C8D893@gpu.srv.ualberta.ca>
Devin Ben-Hur wrote:
! >
! > [mail&post]
! Jeff Vannest wrote:
! > It's not even really a transliteration; I want to delete leading and
! > trailing spaces from a string.
! [snip clunky code]
! > but it looks WAY too clunky for me (although it works).
!
! This is generally considered the clearest and most
! efficient way to strip leading & trailing spaces from
! a string:
! $str =~ s/^\w+//; $str =~ s/\w+$//;
!
! If you really mean spaces only and not general whitespace,
! change the \w to a space.
!
! HTH
! --
! Devin Ben-Hur <dbenhur@egames.com>
! eGames.com, Inc. http://www.egames.com/
! eMarketing, Inc. http://www.emarket.com/
! "It's people like you wot cause unrest!"
of course you meant \s* and not \w+ right?
$str=~s/^\s*//;
$str=~s/\s*$//;
regards
andrew
------------------------------
Date: 9 Apr 1997 20:48:17 GMT
From: colin@mellifluous.europe.dg.com (Colin Smith)
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <5igvah$6ob@mojo.europe.dg.com>
In article <anthony-0804972321130001@anthony.outshine.com>,
anthony@outshine.com (Anthony Boyd) writes:
> "Tim Behrendsen" <tim@a-sis.com> wrote:
>> Peter Seebach <seebs@solutions.solon.com> wrote:
>> > Tim Behrendsen <tim@a-sis.com> wrote:
>
>> > >Good programmers program for 1) Fun, and 2) Money, and the latter
>> > >inevitably produces better quality over the long haul (obviously
>> > >there can be momentary "blips" here and there).
>> >
>> > This is an assertion you have made frequently, but it contradicts the best
>> > information we have about himan motivation.
>>
>> I would say it's perfectly in line with the information we have
>> about human motivation. It's why Capitalism succeeds where Socialism
>> fails. If humans were more motivated by abstractions such as "wanting
>> to do a good job", Socialism would succeed.
>>
>> But I don't even need to go there. Name one freely available
>> *significant* product that is *clearly* better than *any* commercial
>> product, regardless of price.
A little note in here. Microsofts IIS server is a freeware product even though they
like to say it is commercial, that way they can put it up against Netscapes
web server rather than Apache or NCSA and say they have the largest installed
base of any commercial web server.
>
> Tim, are you *trying* to prove Peter's point? Good free product is
> everywhere, in such abundance that I can't believe you'd think it's not.
> GifBuilder is free and the best GIF animator I've used. Perl is free and
> boy, is it handy. Linux is free and thousands of corporations & SOHOs use
> it. Apache is free and is the world's most popular and (IMHO) most
> reliable Web server. MT NewsWatcher is free, and I'm using it to post
> this instead of my (paid in full) copy of Netscape. Internet Explorer is
> 100% free, and while I HATE the Windows version, the Macintosh version is
> clearly done by people who LOVE what they do. JPEGView on the Mac is free
> and displays JPEGs with better color quality than any other program I
> own. Programmer's File Editor on Windows 95 is a free text editor that is
> syntax-aware, offers line-numbering, etc. Great product.
>
> After all this, I think Peter has a point. Vision and passion makes great
> software -- corporate dollars makes good software.
>
> -Anthony Boyd
--
Archeus Free FRPG - http://www.geocities.com/Area51/3002/
Colin Smith (colin@mellifluous.europe.dg.com)
My opinions are completely my own, bought and paid for.
------------------------------
Date: 13 Apr 1997 03:11:48 GMT
From: heller@nacs.net (Jettero Heller)
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <5ipitk$r8b@tracy.nacs.net>
Michael Craft (jsi@idiom.com) wrote:
: > > You want a more productive capitalism? Scrap the copyright and
: > > patent laws and let the little guy, who has invented *everything*,
: > > unleash his creativity and capitalism will have a fighting chance;
: >
: > Uh -- patents were invented to *protect* the little guy. Otherwise,
: > everytime the "little guy" invented something, the "big guy" would
: > simply use the idea, and blow out the little guy because of much
: > greater resources.
:
: Then what value is the "little guy" if he is unable to compete?
When the "little guy" has invented a product that is patent
protected it is not tough to obtain financing to be able to compete.
: If the patent and copyright laws were revoked the assets of the
: "big guy" would be substantially depleted as it is economic protection
: by the state that gives the "big guys" their awesome power.
WHAT? the assets would be depleted? depleted doing what? protecting
themselves from lawsuits filed by the patent holder? depleted by
spending money on licensing patents? No, if there were no patents
then the little guy that invented something would be steamrolled by
the first large company that stole his secret. . .
gimme a break.
** Heller
follow-ups fixed to protect the little guy.
--
http://www.nacs.net/cgi-bin/heller/jokes
http://www.nacs.net/~heller/
You cannot propel yourself forward by patting yourself on the back.
Today I am feeling ept, ane and sipid.
------------------------------
Date: 12 Apr 1997 22:24:00 -0700
From: "Smith A. Cat" <imbe@primenet.com>
Subject: Re: What does "UNIX" stand for..
Message-Id: <33504F3C.2176@primenet.com>
David Collier-Brown wrote:
> That's fairly close. The joke was ``What do you get when you
> cut the balls off Multics? A Eunuch!" (pronounced unics or unix).
> Unics was used as a possible spelling in some discussions, but
> apparently didn't make it as far as the published manuals.
>
and haven't you noticed the way people look at you funny when they here
you carrying on about "eunuchs" with abnormally exaggerated
enthusiasm??!!
------------------------------
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 291
*************************************