[9159] in Perl-Users-Digest
Perl-Users Digest, Issue: 2777 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 1 08:08:04 1998
Date: Mon, 1 Jun 98 05:02:28 -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, 1 Jun 1998 Volume: 8 Number: 2777
Today's topics:
Re: Sockets and E-mail (Jonathan Stowe)
Re: Statistics for comp.lang.perl.misc (Ronald J Kimball)
Re: system() in NT-Perl <chris.wareham@blackwell.co.uk>
Using perl to post a CGI form (CoRey)
Re: Visibility of "my" vars <metcher@spider.herston.uq.edu.au>
Re: while, each & assoc array (Ronald J Kimball)
Re: while, each & assoc array <ebohlman@netcom.com>
Re: Why can't I my() a typeglob reference? (Ronald J Kimball)
Re: Why is `undef' a unary op and not a list op? <chris.wareham@blackwell.co.uk>
Re: Why is `undef' a unary op and not a list op? <merlyn@stonehenge.com>
Re: Why is `undef' a unary op and not a list op? (Charlie Stross)
Re: Why is `undef' a unary op and not a list op? (Michael Fowler)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 01 Jun 1998 06:57:20 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Sockets and E-mail
Message-Id: <3572418b.2998355@news.btinternet.com>
On Sun, 31 May 1998 13:50:37 GMT, Robert Webb wrote :
>On Sat, 30 May 1998 11:31:13 GMT, Gellyfish@btinternet.com (Jonathan
>Stowe) wrote:
>
>>Have a look at perlfaq9 for an example.
>>
>>You can also use Net::SMTP to do much the same thing with slightly
>>more programmer overhead.
>
>Thanks for that. However, I can't extract the lib file from the CPAN
>archive. WinZip fails miserably and complains that it's an 'invalid
>archive' Can anyone mail me the net::smtp module ?
>
Most recent versions of Winzip should be able to deal with gzipped tar
archives (which is what the majority of modules on CPAN come as). It
is possible that your file got corrupted in transfer or that it came
down as text which would cause some translation. You can however get
Win/DOS versions of both tar and gzip from a a variety of sources.
I wont mail you it though because A) I have got it on this machine at
the moment and B) there are some dependencies which wouldnt be
addressed if you just got smtp.pm. I'd download it again.
>>You might however want to take note of the weapons grade disputation
>>that occurred on this subject here not so long ago.
>
>Ahh... sounds like a good time-waster to me :-) What was the thread
>title?
>
Subject: Ever Wonder Why Not Everyone Uses Modules?
From: Art Cohen <upsetter@shore.net>
Date: 1998/05/04
Message-ID: <6ikmr6$1s6@fridge.shore.net>
Newsgroups: comp.lang.perl.misc
>Rob W
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Fri, 29 May 1998 00:05:00 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <1d9riox.mjre8f1wx7fy6N@bay1-109.quincy.ziplink.net>
Tom Christiansen <tchrist@mox.perl.com> wrote:
> [Tom corrupts another thread into a debate about the FSF...]
I agree with those who feel that the FSF flame war would not be
appropriate for the moderated newsgroup.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 01 Jun 1998 09:38:49 GMT
From: Chris Wareham <chris.wareham@blackwell.co.uk>
Subject: Re: system() in NT-Perl
Message-Id: <357276FC.84BECBCE@blackwell.co.uk>
Jan Setnan wrote:
>
> Hi ..
> I'm running this simple program (dir.pl) :
> $utfil = "d:\\temp\\utfil.txt";
> system(qq(dir > $utfil));
> on a PC with Windows NT 4.0.
> When I run it from the command prompt, it works OK,
> the file utfil.txt is created and it contains the directory listing.
> But when I try to schedule it with "at 12:00 perl dir.pl"
> nothing happens, no file is created.
> What's up ??
>
> Jan
Umm ... why are you using a system() call to do a directory listing
when you could use opendir() and readddir(), and then write it out
to disk. This would save the overhead of a system() call, and be
portable:
#!/usr/bin/perl -w
use strict;
my $listingFile = "/temp/listingFile.txt";
opendir(DIR, ".");
my @listOfFiles = grep !/^\.\.?$/, readdir(DIR);
closedir(DIR);
open(LISTFILE, ">$listingFile") || exit(1);
print LISTFILE @listOfFiles;
close(LISTFILE);
exit(0);
Chris
--
=======================
"It said Windows 95
Windows NT or better on
the box, so Linux must
be supported."
=======================
------------------------------
Date: 1 Jun 1998 08:05:56 GMT
From: cjc9024@omega.uta.edu (CoRey)
Subject: Using perl to post a CGI form
Message-Id: <6ktnd4$4v6$1@news.uta.edu>
Greetings>
i recently stumbled upon
http://babelfish.altavista.digital.com/cgi-bin/translate?
which is a web interface which allows you to xlate between different
romantic languages.
I want a perl/shell script which will automate this for me. i'm
going through e-zine's perl5 book, 1996, so I'm boning up on perl.
I know how to use lynx -source http:.... to get the actual source to
the said page...and I found the table which contains the parameters
which get posted to the server, which control which lang. gets
xlated into what.
I assume I must form an html file which will be sent to altavista?
I'll need to telnet to that site, at port 80, and send the text
to translate, along with the language options, in some fashion.
Is there a module that helps with this?
I am confused on the general process of doing this -- it would be
useful outside of this project also.
--
Corey Carroll cjc9024@omega.uta.edu
LISP / MACRO JUNKIE
------------------------------
Date: Mon, 01 Jun 1998 15:17:45 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Visibility of "my" vars
Message-Id: <35723979.45A4BEAE@spider.herston.uq.edu.au>
[Back for another go, having wandered through the dusky streets of the
perl docs tolling a hand bell and calling out "Bring out your
closures!"]
Tom Christiansen wrote:
>
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
> Jaime Metcher <metcher@spider.herston.uq.edu.au> writes:
<snip>
> :On another, related topic, perlsub has this:
> :
> : sub BEGIN {
> : my $secret_val = 0;
> : sub gimme_another {
> : return ++$secret_val;
> : }
> : }
> :
> :Once again, I think that the second occurrence of $secret_val is a
> :package variable, and different from the first occurence which is a
> :lexical.
>
> No, you're confused.
>
<snip>
You're right. Your mkcounter example is using closures. Is
gimme_another a closure???? The docs on closures seem to mention only
*anonymous* subroutines. I've written a little example script (below).
The two cases give the same output. One uses an anonymous subroutine,
the other does not. I'm finding it difficult to understand why the
first case behaves the way it does; the second case makes sense to me.
Maybe I'm getting compile-time and run-time code confused. The sub
gimme_another declaration is processed at compile time, and saved with
its own copy of $secret_val. Then, when blah is called at run time, it
instantiates another $secret_val. The gimme_another subroutine code
isn't part of the blah subroutine code at all (even though it looks like
it is). So when blah calls gimme_another, it isn't actually calling a
"local" procedure in the pascal sense, it's calling a separate,
package-level routine. How does that sound?
The confusing part about that last paragraph is that the "my
$secret_val" line is executing at both compile time and run time, with
different effects.
#!/usr/bin/perl
# CASE 1
sub blah
{
my $secret_val = 10;
print "blah $b $secret_val ";
sub gimme_another {
print "inner $secret_val ";
return ++$secret_val;
}
return gimme_another;
}
print "Case 1\n";
print "outer ", blah, "\n";
print "gimme ", gimme_another, "\n";
print "outer ", blah, "\n";
print "outer ", blah, "\n";
print "\n";
# CASE 2
{
my $secret_val = 10;
$gimme_another2 = sub {
print "inner $secret_val ";
return ++$secret_val;
};
}
sub blah2{
my $secret_val = 10; # no effect
print "blah2 $b $secret_val ";
return &$gimme_another2();
}
print "Case 2\n";
print "outer ", blah2, "\n";
print "gimme ", &$gimme_another2, "\n";
print "outer ", blah2, "\n";
print "outer ", blah2, "\n";
__END__
The output looks like this:
Case 1
blah 10 inner 10 outer 11
inner 11 gimme 12
blah 10 inner 12 outer 13
blah 10 inner 13 outer 14
Case 2
blah2 10 inner 10 outer 11
inner 11 gimme 12
blah2 10 inner 12 outer 13
blah2 10 inner 13 outer 14
------------------------------
Date: Wed, 27 May 1998 00:19:21 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: while, each & assoc array
Message-Id: <1d9nuwb.1h70tsbqqiw1rN@bay2-63.quincy.ziplink.net>
Paul David Fardy <pdf@morgan.ucs.mun.ca> wrote:
> Beauty is the eye of the beholder, but I'd bet you'd have to think
> harder if your compiler reported
>
> "TheCapiTalizedFunctions" is not declared
>
> than you would if your compiler reported
>
> "the_capi_talized_functions" is not declared
>
> because capitalization doesn't delineate words as well as space
> does.
It is also much easier for non-native speakers of English to maintain
code which uses the style "the_captalized_functions" rather than
"TheCapitalizedFunctions".
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 1 Jun 1998 11:25:43 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: while, each & assoc array
Message-Id: <ebohlmanEtvEEv.54n@netcom.com>
Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
: It is also much easier for non-native speakers of English to maintain
: code which uses the style "the_captalized_functions" rather than
: "TheCapitalizedFunctions".
And it's also much easier for blind programmers who use speech to access
their machines. Screen-reading software can easily be configured to
pronounce underscores; it's much harder to quickly verbalize case changes
within a word (in fact, the only practical way to find out where the case
changes are is to read the word a character at a time, which is slow).
------------------------------
Date: Wed, 27 May 1998 00:19:24 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Why can't I my() a typeglob reference?
Message-Id: <1d9nv4i.1uj68azmaes51N@bay2-63.quincy.ziplink.net>
[posted and mailed]
Martin Gregory <mgregory@asc.sps.mot.com> wrote:
> Why can't I do
>
> open(FH, $FileName) or die;
>
> my $FilePointerThingo = \*FH;
>
> @Contents = <$FilePointerThingo>;
>
> (Am I correct in understaning that I can't do that: somewhere I read
> that you have to use local() instead, which scares me, because I don't
> understand why.)
No, you are not correct. Did you try it?
~> cat > temp
$FileName = 'temp';
open(FH, $FileName) or die;
my $FilePointerThingo = \*FH;
@Contents = <$FilePointerThingo>;
print @Contents;
~> perl temp temp
$FileName = 'temp';
open(FH, $FileName) or die;
my $FilePointerThingo = \*FH;
@Contents = <$FilePointerThingo>;
print @Contents;
~>
What you cannot do is:
my $MyVar = 'Foo';
$Var = \*MyVar;
because type globs are symbol table entries, and my variables are not in
the symbol table.
(Well, you "can" do it, but it wouldn't work how you wanted.)
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 01 Jun 1998 10:00:47 GMT
From: Chris Wareham <chris.wareham@blackwell.co.uk>
Subject: Re: Why is `undef' a unary op and not a list op?
Message-Id: <35727C58.707F140B@blackwell.co.uk>
Mark-Jason Dominus wrote:
>
> I got a surprise today. I wrote
>
> undef $x, &x;
>
> expecting it to undefine the two things.
>
> Instead, though, it undefined $x and *invoked* &x, as if I had written
> it like this:
>
> (undef $x), &x;
>snip<
A very good point. I also assumed it took a list as an argument - it
almost drove me round the bend until I found out it doesn't. Anyways,
what's the chance of one of the Perl maintainers making it take a list
in a future Perl revision?
Chris
--
=======================
"It said Windows 95
Windows NT or better on
the box, so Linux must
be supported."
=======================
------------------------------
Date: Mon, 01 Jun 1998 11:19:02 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Why is `undef' a unary op and not a list op?
Message-Id: <8cg1hpz7xc.fsf@gadget.cscaper.com>
>>>>> "Chris" == Chris Wareham <chris.wareham@blackwell.co.uk> writes:
Chris> A very good point. I also assumed it took a list as an argument - it
Chris> almost drove me round the bend until I found out it doesn't. Anyways,
Chris> what's the chance of one of the Perl maintainers making it take a list
Chris> in a future Perl revision?
The act of "undef"-ing something occurs infrequently enough in my code
that I'd presume most seasoned Perl programmers also use it sparingly.
So, if you find yourself undef'ing things a lot, perhaps you should
look at code written by more seasoned Perl programmers so that you can
find out different ways of doing it.
Just a thought.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 92 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Mon, 01 Jun 1998 11:19:36 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: Re: Why is `undef' a unary op and not a list op?
Message-Id: <slrn6n53oc.qq4.charlie@cs.ed.datacash.com>
In the name of Kibo the Compassionate, the Merciful,
on Mon, 01 Jun 1998 10:00:47 GMT, Chris Wareham
the supplicant <chris.wareham@blackwell.co.uk> inscribed:
>A very good point. I also assumed it took a list as an argument - it
>almost drove me round the bend until I found out it doesn't. Anyways,
>what's the chance of one of the Perl maintainers making it take a list
>in a future Perl revision?
Let me hazard a guess: it won't. Reason: one of the constraints on future
perl revisions is that new language features shouldn't cause legacy code
to break or behave unpredictably. undef $foo, &bar() currently undef's $foo
and calls bar(); making undef into a list operator would break this.
So I suspect we're stuck with it ...
-- Charlie
"Given two unrelated technical terms, an internet search engine
will retrieve only resumes." -- Schachter's Hypothesis
------------------------------
Date: Mon, 01 Jun 1998 11:45:44 GMT
From: wolfm@pobox.alaska.net (Michael Fowler)
Subject: Re: Why is `undef' a unary op and not a list op?
Message-Id: <Ivwc1.1$h13.14219@binary.alaska.net>
On Mon, 01 Jun 1998 11:19:36 GMT, Charlie Stross <charlie@antipope.org> bespoke
regarding Re: Why is `undef' a unary op and not a list op?:
[snip]
>to break or behave unpredictably. undef $foo, &bar() currently undef's $foo
>and calls bar(); making undef into a list operator would break this.
>So I suspect we're stuck with it ...
Can you find any examples of this? It seems to me that that kind of
operation would only be used in obfuscation, it's very unreadable. I'm all
for a list being accepted instead of an expression.
[snip]
Respectfully,
Michael
--
-- --
All my life I wanted to be someone;
I guess I should've been more specific.
-- --
------------------------------
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 2777
**************************************