[29044] in Perl-Users-Digest
Perl-Users Digest, Issue: 288 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 1 03:10:00 2007
Date: Sun, 1 Apr 2007 00:09:05 -0700 (PDT)
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, 1 Apr 2007 Volume: 11 Number: 288
Today's topics:
attn: morton - extremely peaceful news server - awmu r <nashwan@lentucky.co.uk>
Re: convert wikipedia to html? <please@nospam.net>
Re: How to make send key ([tab] [tab]Text [Enter]) in s <bart.lateur@pandora.be>
Re: Llama book exercise <please@nospam.net>
new CPAN modules on Sun Apr 1 2007 (Randal Schwartz)
Re: Number of days between 2 dates <please@nospam.net>
Re: Shifting Away anno4000@radom.zrz.tu-berlin.de
Re: Shifting Away <uri@stemsystems.com>
Re: Shifting Away <please@nospam.net>
Re: Shifting Away <uri@stemsystems.com>
Re: Shifting Away <please@nospam.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 31 Mar 2007 23:14:23 GMT
From: obadiah <nashwan@lentucky.co.uk>
Subject: attn: morton - extremely peaceful news server - awmu rem - (1/1)
Message-Id: <521923451U38224j478z915E966288a413666824q8i94398866M@news.lentucky.co.uk>
Hi everyone
With some of the fastest connections around it's no wonder people love it and keep coming back.
Take a look, I know you'll love it as much as I do.
Great prices and support await you as you travel into the beautiful world of premium nntp access.
Streaming audio and video
Blazing fast downloads
Convenient thumbnail indexes
2,000,000 new posts each day
Keyword searchable
800 GIGS of new multimedia content each day
Very long retention
Thanks! I hope to see you at http://www.newsdude.net soon. See you there.
Godrunitpel zogpalihnak mi cun keflivodmif vi ...
------------------------------
Date: Sat, 31 Mar 2007 23:30:17 -0700
From: Xiong Changnian <please@nospam.net>
Subject: Re: convert wikipedia to html?
Message-Id: <please-3700DC.23301731032007@free.teranews.com>
In article <1173032973.454043.282960@i80g2000cwc.googlegroups.com>,
"dt" <ppc@cheapbooks.com> wrote:
> is there an easy way to convert a WIKI page to html by querying the
> site, keeping all the formatting?
Um, this may not be what you want to hear, but why not just install
MediaWiki, the engine that drives Wikipedia in the first place? It's GPL
freeware.
You can hook into it from your script if you want to do something it
doesn't do. Meanwhile, you've got a complete install so you can do
anything you could if you were "at" WP itself. Be Jimbo!
If you just want to customize the way in which the HTML page is
composed, check out "skins".
--
Xiong Changnian
xiong102ATxuefangDOTcom
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Sat, 31 Mar 2007 20:27:18 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: How to make send key ([tab] [tab]Text [Enter]) in some program (Internet Explorer or Notepad)?
Message-Id: <1rgt035u83ffa2luh96m4a4ktj9f0rpqh7@4ax.com>
max wrote:
>How to make send key ([tab] [tab]Text [Enter]) in some program (Internet
>Explorer or Notepad)?
Use the module Win32::GuiTest, and from that module, use the function
SendKeys.
<http://search.cpan.org/perldoc?Win32::GuiTest>
You must be working on Windows, you're probably using ActivePerl, then
use PPM to install the above module.
--
Bart.
------------------------------
Date: Sat, 31 Mar 2007 23:49:44 -0700
From: Xiong Changnian <please@nospam.net>
Subject: Re: Llama book exercise
Message-Id: <please-D8BE79.23494431032007@free.teranews.com>
In article <1173777825.551301.214420@p10g2000cwp.googlegroups.com>,
"PerseP" <persep@gmail.com> wrote:
> I think it's a bit contradictory...
There's More Than One Way To Do It.
Of course, we all tend to react to that much freedom by saying, from
time to time:
Do It This Way Only.
Sometimes, we're right.
--
Xiong Changnian
xiong102ATxuefangDOTcom
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Sun, 1 Apr 2007 04:42:09 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Apr 1 2007
Message-Id: <JFsyE9.20B4@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
BatchSystem-SBS-0.30
http://search.cpan.org/~alexmass/BatchSystem-SBS-0.30/
a Simple Batch System
----
CGI-FCKeditor-0.02
http://search.cpan.org/~shiraiwa/CGI-FCKeditor-0.02/
FCKeditor For OOP Module
----
Crypt-GPG-1.62
http://search.cpan.org/~agul/Crypt-GPG-1.62/
An Object Oriented Interface to GnuPG.
----
Gtk2-Ex-FileLocater-0.01
http://search.cpan.org/~hooo/Gtk2-Ex-FileLocater-0.01/
----
Gtk2-Ex-FileQuickFind-0.01
http://search.cpan.org/~hooo/Gtk2-Ex-FileQuickFind-0.01/
find an icon on the system
----
JSON-XS-1.01
http://search.cpan.org/~mlehmann/JSON-XS-1.01/
JSON serialising/deserialising, done correctly and fast
----
Log-Dispatch-2.17
http://search.cpan.org/~drolsky/Log-Dispatch-2.17/
Dispatches messages to one or more outputs
----
Net-Frame-Layer-LOOP-1.00
http://search.cpan.org/~gomor/Net-Frame-Layer-LOOP-1.00/
LOOP layer object
----
Net-XMPP-1.02
http://search.cpan.org/~hacker/Net-XMPP-1.02/
XMPP Perl Library
----
Pod-HtmlEasy-0.09
http://search.cpan.org/~gleach/Pod-HtmlEasy-0.09/
Generate easy and personalized HTML from PODs, without extra modules and on "the flight".
----
Proc-Fork-0.4
http://search.cpan.org/~aristotle/Proc-Fork-0.4/
Simple, intuitive interface to the fork() system call
----
Roku-RCP-0.01
http://search.cpan.org/~batman/Roku-RCP-0.01/
Object approach to controlling RCP enabled Roku products, such as the Roku SoundBridge.
----
Roku-RCP-0.02
http://search.cpan.org/~batman/Roku-RCP-0.02/
Object approach to controlling RCP enabled Roku products, such as the Roku SoundBridge.
----
Roku-RCP-0.03
http://search.cpan.org/~batman/Roku-RCP-0.03/
Object approach to controlling RCP enabled Roku products, such as the Roku SoundBridge.
----
Spreadsheet-ParseExcel-0.30
http://search.cpan.org/~szabgab/Spreadsheet-ParseExcel-0.30/
Get information from Excel file
----
Sub-ArgShortcut-1.0
http://search.cpan.org/~aristotle/Sub-ArgShortcut-1.0/
simplify writing functions that use default arguments
----
Thesaurus-0.23
http://search.cpan.org/~drolsky/Thesaurus-0.23/
Maintains lists of associated items
----
Wx-0.72
http://search.cpan.org/~mbarbon/Wx-0.72/
interface to the wxWidgets cross-platform GUI toolkit
----
Wx-Perl-ListCtrl-0.02
http://search.cpan.org/~mbarbon/Wx-Perl-ListCtrl-0.02/
a sensible API for Wx::ListCtrl
----
Wx-Perl-ProcessStream-0.08
http://search.cpan.org/~mdootson/Wx-Perl-ProcessStream-0.08/
access IO of external processes via events
----
eBay-API-0.22
http://search.cpan.org/~ebay/eBay-API-0.22/
Perl SDK for eBay Web services Interface
----
ponfish-0.02
http://search.cpan.org/~dclee/ponfish-0.02/
----
ponfish-0.03
http://search.cpan.org/~dclee/ponfish-0.03/
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sat, 31 Mar 2007 23:04:03 -0700
From: Xiong Changnian <please@nospam.net>
Subject: Re: Number of days between 2 dates
Message-Id: <please-4C8487.23040331032007@free.teranews.com>
In article <1173117544.434937.276570@t69g2000cwt.googlegroups.com>,
"Bill H" <bill@ts1000.us> wrote:
> (...someone has to ask the stupid questions)!
Bill, I've read every bit of standard Perl doc I can lay my hands on and
a lot that's not. Quite often I don't understand what I'm reading but I
read anyway; some docs I've read a dozen or more times. I'm not saying
you need to do this but I'll share with you that despite my doing my
homework, I've still been taken to task here. The folks in this group
can be very helpful but they can be very short. Suggest you try to avoid
stupid questions -- you're right, they have to be asked; but then, so
they have, already.
--
Xiong Changnian
xiong102ATxuefangDOTcom
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: 31 Mar 2007 20:29:00 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Shifting Away
Message-Id: <577ukcF29jl14U1@mid.dfncis.de>
Uri Guttman <uri@stemsystems.com> wrote in comp.lang.perl.misc:
> >>>>> "XC" == Xiong Changnian <please@nospam.net> writes:
>
> XC> In article <slrnf0s4vm.9s8.hjp-usenet2@yoyo.hjp.at>,
> XC> "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>
> XC> When you deliberately pass refs to params, you must explicitly deref
> XC> them inside the sub. Therefore, there is a bit of confusion involved
> XC> when saying that Perl passes all params as refs. It's true; but a little
> XC> bit deeper in the machinery, the ref is dereffed for you. That's
> XC> probably an inexact statement but that's not the issue. As you say,
> XC> Peter, it *is* call-by-ref, even if the syntax says you're just passing
> XC> a scalar.
>
> ok, let's try to clear up some stuff. first off all sub args are passed by
> alias, not exactly by ref.
Here lies the terminological difficulty.
Traditionally, two (or more) styles of parameter passing are
distinguished: "by value", and "by reference", where "by reference"
allows the routine to change a value for the calling program and
"by value" does not. In this terminology, Perl's parameter passing
is clearly "by reference". Unfortunately, "reference" has a distinct
meaning in Perl terminology, and it is *not* the mechanism by which
Perl manages parameter passing, though conceivably it could be.
Instead, as you rightly say, Perl uses "aliasing" to realize its
parameter passing "by reference".
Terminology is that way.
[good stuff snipped]
Anno
------------------------------
Date: Sat, 31 Mar 2007 20:44:41 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Shifting Away
Message-Id: <x7slbkzx4m.fsf@mail.sysarch.com>
>>>>> "a" == anno4000 <anno4000@radom.zrz.tu-berlin.de> writes:
a> Uri Guttman <uri@stemsystems.com> wrote in comp.lang.perl.misc:
>> >>>>> "XC" == Xiong Changnian <please@nospam.net> writes:
>>
XC> In article <slrnf0s4vm.9s8.hjp-usenet2@yoyo.hjp.at>,
XC> "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>>
XC> When you deliberately pass refs to params, you must explicitly deref
XC> them inside the sub. Therefore, there is a bit of confusion involved
XC> when saying that Perl passes all params as refs. It's true; but a little
XC> bit deeper in the machinery, the ref is dereffed for you. That's
XC> probably an inexact statement but that's not the issue. As you say,
XC> Peter, it *is* call-by-ref, even if the syntax says you're just passing
XC> a scalar.
>>
>> ok, let's try to clear up some stuff. first off all sub args are passed by
>> alias, not exactly by ref.
a> Here lies the terminological difficulty.
a> Traditionally, two (or more) styles of parameter passing are
a> distinguished: "by value", and "by reference", where "by reference"
a> allows the routine to change a value for the calling program and
a> "by value" does not. In this terminology, Perl's parameter passing
a> is clearly "by reference". Unfortunately, "reference" has a distinct
a> meaning in Perl terminology, and it is *not* the mechanism by which
a> Perl manages parameter passing, though conceivably it could be.
a> Instead, as you rightly say, Perl uses "aliasing" to realize its
a> parameter passing "by reference".
a> Terminology is that way.
yep. and the OP is locked in on the wrong terms.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sat, 31 Mar 2007 21:51:45 -0700
From: Xiong Changnian <please@nospam.net>
Subject: Re: Shifting Away
Message-Id: <please-3D2960.21514131032007@free.teranews.com>
In article <x7d52p2zww.fsf@mail.sysarch.com>,
Uri Guttman <uri@stemsystems.com> wrote:
> first off all sub args are passed by
> alias, not exactly by ref.
Yes. I think we can hammer at this distinction all night long without
letting any more light into the room. I've tried to make it abundantly
clear that an alias is not, as Perl defines it, a ref(erence). However,
Perl does implement param passing via call-by-reference, generally
speaking. Otherwise, it would not be possible to do anything within a
sub that could clobber a param within the calling context.
Somebody at this point might say that an evil demon might pass a param
*value*, then look to see if $_[$i] had been changed and if so, go back
and put the new value back in the old mailbox. I don't know anything
about Perl internals but I'll bet a dollar to a doughnut that this is
not the case. Rather, I'll bet that $_[$i] points directly to the
mailbox itself. Please correct me if I'm wrong.
At this, my chosen level of abstraction, there are only two ways to pass
a param to a sub: call-by-reference or call-by-value. Perl does the
former. Am I mistaken? If so, how?
> it isn't deliberate or accidental,
> but all the time.
It is deliberate (on the part of the Perl maintainers) and it is all the
time. When somebody writing code in Perl fails to understand this
mechanism he may, by accident, screw up -- and if foolish, blame Perl,
if wise, study and learn. When somebody who understands it makes
deliberate use of it, he may thank Larry Wall, wisely, or compliment
himself, foolishly.
Have I finally and for all time covered these bases explicitly and
without ambiguity? I wrote:
> XC> (This distinction is important to me....)
... and so it is. It is crystal clear in my mind -- both that params are
not automatically refs, as defined by Perl; and that @_ is a list of
parameters that are passed by the mechanism of call-by-reference. One
thing is not the other; I don't know how to make it any clearer. I've
done my best and I'm sorry if I've still come up short.
May the heavens guide the poor man who stumbles onto this thread,
thinking about passing a Perl ref as a param. It certainly can be done
(and often is) and this has nothing to do with the alias nature of @_.
> @_ aliases are not refs. you
> think that because they refer to the original
> value that this is pass by reference but it is
> not the same as most times you copy the args and
> then they become pass by value.
If you copy the value, that doesn't make the calling mechanism
call-by-value. A language that implements parameter passing via
call-by-value will not (by default) pass anything to the sub that will
allow it to modify anything outside the sub (except, perhaps, global
variables and a return value, neither of which are enabled by the
parameter passing mechanism). That is:
use pseudocode;
sub foo (whang:integer) {
whang = 47;
};
main {
counter = 1;
foo (counter);
print counter;
};
... will print 1, not 47. It *has* to print 1, because foo just does not
have any way at all to get *at* counter. When foo wakes up, it sees the
value 1 in whang, which it can use or ignore but cannot jimmy in any way
to reach "beyond" and grab hold of counter.
A language that implements pass-by-reference will print 47. That's all;
there is no in-between. An alias is a high-level abstraction that
encapsulates a reference -- not a Perl ref, not something that can be
interpreted as a Perl ref or explicitly dereffed. An alias is implicitly
dereffed when used.
Let me say again (in case it helps) that my primary orientation is way
down the ladder. When a sub invokes in most languages, it pops its
params off the stack. Now, at the moment of the pop, that word popping
off the stack is either the value that the calling routine had in "mind"
when deciding to call the sub; or that popped word is a pointer into the
heap or possibly another part of the stack, at which location the actual
value is found. The first case is call-by-value; the second
call-by-reference.
> ... you must come to an understanding
> of the actual topic first before
> you flame away and babble incoherently.
I believe I understand *this* point as clearly as possible; that leaves
a great deal of room for my education.
I've read others of this gentleman's posts and while it's not clear to
me whether he knows his stuff or not, he *seems* to me to lean rather
hard into other posters who don't appear to speak his language, his way.
Either way, I certainly don't want to insult him -- or anyone else. Yet
I would appreciate being allowed the same courtesy and I'm afraid I'm
not going to get it.
Am I right, in which case I should from now on ignore him? Or am I a
babbling fool? I leave it to the group to set me straight.
--
Xiong Changnian
xiong102ATxuefangDOTcom
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Sun, 01 Apr 2007 00:30:26 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Shifting Away
Message-Id: <x7hcs0wtjh.fsf@mail.sysarch.com>
>>>>> "XC" == Xiong Changnian <please@nospam.net> writes:
XC> In article <x7d52p2zww.fsf@mail.sysarch.com>,
XC> Uri Guttman <uri@stemsystems.com> wrote:
>> first off all sub args are passed by
>> alias, not exactly by ref.
XC> Yes. I think we can hammer at this distinction all night long
XC> without letting any more light into the room. I've tried to make
XC> it abundantly clear that an alias is not, as Perl defines it, a
XC> ref(erence). However, Perl does implement param passing via
XC> call-by-reference, generally speaking. Otherwise, it would not be
XC> possible to do anything within a sub that could clobber a param
XC> within the calling context.
the light needs to be shown inside your head. no one else has a problem
with how perl handles sub args. so stop making claims that make no
sense.
XC> Somebody at this point might say that an evil demon might pass a param
XC> *value*, then look to see if $_[$i] had been changed and if so, go back
XC> and put the new value back in the old mailbox. I don't know anything
XC> about Perl internals but I'll bet a dollar to a doughnut that this is
XC> not the case. Rather, I'll bet that $_[$i] points directly to the
XC> mailbox itself. Please correct me if I'm wrong.
*boggle*
XC> At this, my chosen level of abstraction, there are only two ways to pass
XC> a param to a sub: call-by-reference or call-by-value. Perl does the
XC> former. Am I mistaken? If so, how?
you chosen level is wrong. you write perl code as if it was always call
by value. you pass refs if you want call by ref. sometimes you can use
the alias nature of @_ to do call by ref but that IS NOT THE COMMON
CASE. so drop it already and ignore that case. it doesn't matter to
almost all the perl code out there. a very very tiny fraction uses @_ as
a call by ref. and hopefully only by those who understand why it is
useful
>> it isn't deliberate or accidental,
>> but all the time.
XC> It is deliberate (on the part of the Perl maintainers) and it is all the
XC> time. When somebody writing code in Perl fails to understand this
XC> mechanism he may, by accident, screw up -- and if foolish, blame Perl,
XC> if wise, study and learn. When somebody who understands it makes
XC> deliberate use of it, he may thank Larry Wall, wisely, or compliment
XC> himself, foolishly.
no. most perl coders never see that nor will that. most coders are
taught to copy @_ to lexical vars and that is call by value. simple and
safe and proper.
XC> ... and so it is. It is crystal clear in my mind -- both that params are
XC> not automatically refs, as defined by Perl; and that @_ is a list of
XC> parameters that are passed by the mechanism of call-by-reference. One
XC> thing is not the other; I don't know how to make it any clearer. I've
XC> done my best and I'm sorry if I've still come up short.
no you have made it clear you understand the difference. what you have
not made clear is whether you understand that the alias nature of is NOT
IMPORTANT. no one calls perl a pass by ref lang. its common style is
pass by value. that is what matters not how it is implemented.
XC> May the heavens guide the poor man who stumbles onto this thread,
XC> thinking about passing a Perl ref as a param. It certainly can be done
XC> (and often is) and this has nothing to do with the alias nature of @_.
no. they will see our replies to you and realize that common perl is
pass by value.
>> @_ aliases are not refs. you
>> think that because they refer to the original
>> value that this is pass by reference but it is
>> not the same as most times you copy the args and
>> then they become pass by value.
XC> If you copy the value, that doesn't make the calling mechanism
XC> call-by-value. A language that implements parameter passing via
XC> call-by-value will not (by default) pass anything to the sub that will
XC> allow it to modify anything outside the sub (except, perhaps, global
XC> variables and a return value, neither of which are enabled by the
XC> parameter passing mechanism). That is:
if you code in a pass by value style which is the recommended and taught
style it is a pass by value language. you have obviously never used PL/I
or algol or lisp or other pass by ref langs but which were largely used
in a pass by value style.
XC> A language that implements pass-by-reference will print 47. That's all;
XC> there is no in-between. An alias is a high-level abstraction that
XC> encapsulates a reference -- not a Perl ref, not something that can be
XC> interpreted as a Perl ref or explicitly dereffed. An alias is implicitly
XC> dereffed when used.
not if you copy from the alias first as is always taught and commonly
done. that is what matter. language conventions are just as important as
syntax and implementation. no language lives alone. perl is a pass by
value language because that is the convention. period. end of
discussion. nothing you say matters about this.
XC> Let me say again (in case it helps) that my primary orientation is way
XC> down the ladder. When a sub invokes in most languages, it pops its
XC> params off the stack. Now, at the moment of the pop, that word popping
XC> off the stack is either the value that the calling routine had in "mind"
XC> when deciding to call the sub; or that popped word is a pointer into the
XC> heap or possibly another part of the stack, at which location the actual
XC> value is found. The first case is call-by-value; the second
XC> call-by-reference.
it doesn't matter what you think or how it is implemented. it is pass by
value by convention. rinse. repeat.
XC> I've read others of this gentleman's posts and while it's not clear to
XC> me whether he knows his stuff or not, he *seems* to me to lean rather
XC> hard into other posters who don't appear to speak his language, his way.
XC> Either way, I certainly don't want to insult him -- or anyone else. Yet
XC> I would appreciate being allowed the same courtesy and I'm afraid I'm
XC> not going to get it.
which gentleman?
XC> Am I right, in which case I should from now on ignore him? Or am I a
XC> babbling fool? I leave it to the group to set me straight.
you an ignore anyone you want. most will be ignoring you. few ignore me
or maybe more should. but i do know what call by value is and how perl
is a call by value language no matter how it is implemented
underneath. and i also said @_ is aliased for SPEED and RAM reasons but
copies are made of the args for SAFETY reasons. perl is both a floor wax
and a dessert topping.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sat, 31 Mar 2007 22:57:59 -0700
From: Xiong Changnian <please@nospam.net>
Subject: Re: Shifting Away
Message-Id: <please-8CB231.22575931032007@free.teranews.com>
In article <577f2vF2bvrpmU1@mid.dfncis.de>,
anno4000@radom.zrz.tu-berlin.de wrote:
> Pardon the pedantry...
There's a group whose official motto is "too much pedantry is just
enough". I'll go so far as to say that there's little room for muddy
thinking in computer programming. But -- just to rock the boat -- one
reason for high-level languages is to allow the programmer a little
leeway. ("Do What You Want".)
> One-shot for loops aren't that exotic in Perl.
No; I see them here and there and I've even implemented a switch/case
with such a thing. I'd like to think that when I do this, I *want* an
alias -- that's why I did it.
>"for" (but not the non-word "foreach")
Say, are there two armed camps of Perl monks throwing gazillion megawatt
lightning bolts at one another over for/foreach? Reminds me of how to
liven up a Saturday night: Go to the gray-collar bar nearest the city
daily at shift change and shout "When should I use an en dash?"
I use foreach when iterating over a list and for when constructing a
traditional for loop. I know they're synonyms and that's cool.
> It proves that what shift() returns *is* an lvalue and can be used to
> clobber the actual parameter.
Well, I'm enlightened; thank you. I think I'd have to try pretty hard to
get stuck in that crack but it's always good to know what surprises
lurk.
I guess that shift() = 13 really "shouldn't" raise an exception, then.
Stuffy guys take away all the fun toys.
> Perl's "postmodern", non-orthogonal design entails lots and lots of
> edge cases where the actual behavior can't be derived from general
> principles, but is geared to the particular case. It is often
> distracting and sometimes impossible to discuss all that may be
> relevant to a topic.
Um, well, at the risk of opening Pandora's Box, I'll say that I'm
extremely interested in all the edges, all the time. Perl's actual
design isn't all that's postmodern; so are the docs. I come from the
school where every last detail of operation is spelled out in the man,
one token per page. I can't quite quash the creeping suspicion that some
issues are glossed over in Perl docs because *nobody's* completely sure
what beautiful syntax the interpreter will accept. Besides, X might
change in a future implementation.
So, I really appreciate your willingness to dig out these edge
conditions and discuss them.
If I have one petty objection to Perl, it's that it tries so hard to Do
What I Want that some pretty crummy code still works, instead of holding
my idiocy up to the glaring light of fatal error. I'm an "all warnings,
all the time" guy, at least for now.
In my first few revisions of my learning project, I tested all the
params I shifted off and died if there weren't enough of them. I've
become a bit less paranoid now but it's hard to let go of formal params.
I think Perl may be the language that finally demands doc-as-you-go.
> If I were to discuss all ramifications I'd have to mention the
> possibility that the same parameter could appear a second time
> in the argument list and the sub could still change that.
Well, okay, but from my point of view, that's not an issue.
sub foo {
my $this = shift;
$_[0] = 'Floyd';
my $that = $_[0];
$this . $that;
};
my $param = 'Larry';
my $return = foo ($param, $param);
... will return 'LarryFloyd'. It doesn't matter which one's Pink. Yes,
$param got clobbered but I *did* that; it didn't "just happen".
I think we got onto this topic because I said I didn't generally care to
mix shift with $_[$i] -- I've done it but not as a daily thing. I prefer
to shift off onto my variables if I'm writing a big sub; if I'm going
for small and fast, I'll stick with @_.
If anything, the potential interactions between these two methods seem
to me to provide a foundation for my (frankly) instinctive tropism. I
can see how someone else might see it as entirely natural. I think it
makes most sense to mix-and-match when shifting off a few params for
processing "here", then passing the remaining @_ to another sub.
You mentioned that you like assigning in one fell swoop:
my ($A, $B, $C) = @_;
I don't, although it's more compact and I generally like compact. I much
prefer to put each "declaration" on a line by itself, perhaps with
comment. Maybe, after time passes, I'll take this particular thumb out
of my mouth.
--
Xiong Changnian
xiong102ATxuefangDOTcom
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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.
#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 V11 Issue 288
**************************************