[29042] in Perl-Users-Digest
Perl-Users Digest, Issue: 286 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 31 06:10:07 2007
Date: Sat, 31 Mar 2007 03:09:03 -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 Sat, 31 Mar 2007 Volume: 11 Number: 286
Today's topics:
Re: Fundamental pipe questions <cdalten@gmail.com>
Re: Fundamental pipe questions xhoster@gmail.com
Re: Fundamental pipe questions <cdalten@gmail.com>
Re: Fundamental pipe questions xhoster@gmail.com
Re: Fundamental pipe questions <hjp-usenet2@hjp.at>
Re: Fundamental pipe questions <hjp-usenet2@hjp.at>
Re: Fundamental pipe questions <hjp-usenet2@hjp.at>
Re: Fundamental pipe questions <hjp-usenet2@hjp.at>
How to make send key ([tab] [tab]Text [Enter]) in some <max@xxx.tovle.ct>
new CPAN modules on Sat Mar 31 2007 (Randal Schwartz)
Re: Perl package install dll problems <sisyphus1@nomail.afraid.org>
Re: Question about wizard Perl programmers -- Answers <please@nospam.net>
Re: Shifting Away <please@nospam.net>
Re: Shifting Away <hjp-usenet2@hjp.at>
Re: What are OOP's Jargons and Complexities <asandstrom@accesswave.ca>
Re: What are OOP's Jargons and Complexities <asandstrom@accesswave.ca>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Mar 2007 18:12:34 -0700
From: "Lost Sheep Of the Porn" <cdalten@gmail.com>
Subject: Re: Fundamental pipe questions
Message-Id: <1175303554.367604.276720@y66g2000hsf.googlegroups.com>
On Mar 30, 11:56 am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> ["Followup-To:" header set to comp.lang.perl.misc.]
> On 2007-03-30 14:00, grocery_stocker <cdal...@gmail.com> wrote:
>
> > What's the difference between
> > open(FOO, "=E2=94=82tr =E2=80=99[a-z]=E2=80=99 =E2=80=99[A-Z]=E2=80=99=
");
>
> How did you manage that? "=E2=94=82" is not a pipe ("|" is) and "=E2=80=
=99" is not a
> single quote ("'" is). So that code will indeed not invoke a shell,
> instead it will try to open the file "=E2=94=82tr =E2=80=99[a-z]=E2=80=99=
=E2=80=99[A-Z]=E2=80=99" for reading.
> But I'll assume that the strange characters were introduced by your
> browser or google and that your real code does contain a pipe character
> and single quotes.
>
Yes, the strange characters were introduced by my browser.
> > and
>
> > open(FOO, =E2=80=99=E2=94=82-=E2=80=99, "tr =E2=80=99[a-z]=E2=80=99 =E2=
=80=99[A-Z]=E2=80=99");
>
> None.
>
If both constructs are the same, then how come perlipc rattles on
about how |- is a safe pipe open. I think the section that comes to
mind is
And here=E2=80=99s a safe pipe open for writing:
# add error processing as above
$pid =3D open(KID_TO_WRITE, "|-");
$SIG{PIPE} =3D sub { die "whoops, $program pipe broke" };
if ($pid) { # parent
for (@data) {
print KID_TO_WRITE;
}
close(KID_TO_WRITE) || warn "kid exited $?";
} else { # child
($EUID, $EGID) =3D ($UID, $GID);
exec($program, @options, @args)
|| die "can=E2=80=99t exec program: $!";
# NOTREACHED
}
------------------------------
Date: 31 Mar 2007 01:17:41 GMT
From: xhoster@gmail.com
Subject: Re: Fundamental pipe questions
Message-Id: <20070330211745.069$o7@newsreader.com>
"Lost Sheep Of the Porn" <cdalten@gmail.com> wrote:
>
> Yes, the strange characters were introduced by my browser.
Clearly they are introduced in your posting software, not your browsing
software. Please try to fix that, or people will be less likely to respond
to you.
>
> If both these constructs are the same, then why does perlipc rattle on
> about using |- for safe pipe opens. I think the following from perlipc
> comes to mind.
>
> And here=E2=80=99s a safe pipe open for writing:
>
> # add error processing as above
> $pid =3D open(KID_TO_WRITE, "|-");
Notice that lack of any third (or more) arguments in that pipe open,
and the lack of program name in the 2nd argument.
> $SIG{PIPE} =3D sub { die "whoops, $program pipe broke" };
>
> if ($pid) { # parent
> for (@data) {
> print KID_TO_WRITE;
> }
> close(KID_TO_WRITE) || warn "kid exited $?";
>
> } else { # child
> ($EUID, $EGID) =3D ($UID, $GID);
See here where it mucks around with $EUID? If you used either the
two argument open which contained the command name and all of its arguments
in the 2nd argument, or the 3 or more argument form, then you would not
have an opportunity to do this before the $program got executed. That is
the main thing that makes this safer than the alternative. The second
thing is that by using the multi-argument form of exec, you prevent the
shell from trying to interpret the arguments (this one you could also do,
on sufficiently modern Perls, by using the more than 3 argument pipe open).
> exec($program, @options, @args)
> || die "can=E2=80=99t exec program: $!";
> # NOTREACHED
> }
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 30 Mar 2007 18:53:36 -0700
From: "grocery_stocker" <cdalten@gmail.com>
Subject: Re: Fundamental pipe questions
Message-Id: <1175306016.630960.24700@y66g2000hsf.googlegroups.com>
On Mar 30, 6:17 pm, xhos...@gmail.com wrote:
> "Lost Sheep Of the Porn" <cdal...@gmail.com> wrote:
>
>
>
> > Yes, the strange characters were introduced by my browser.
>
> Clearly they are introduced in your posting software, not your browsing
> software. Please try to fix that, or people will be less likely to respond
> to you.
>
>
>
I keep meaning to take an intro computer science class at the College
of Marin. This school is like down the road from where I work at in
San Rafael, California.
> > If both these constructs are the same, then why does perlipc rattle on
> > about using |- for safe pipe opens. I think the following from perlipc
> > comes to mind.
>
> > And here=E2=80=99s a safe pipe open for writing:
>
> > # add error processing as above
> > $pid =3D open(KID_TO_WRITE, "|-");
>
> Notice that lack of any third (or more) arguments in that pipe open,
> and the lack of program name in the 2nd argument.
>
> > $SIG{PIPE} =3D sub { die "whoops, $program pipe broke" };
>
> > if ($pid) { # parent
> > for (@data) {
> > print KID_TO_WRITE;
> > }
> > close(KID_TO_WRITE) || warn "kid exited $?";
>
> > } else { # child
> > ($EUID, $EGID) =3D ($UID, $GID);
>
> See here where it mucks around with $EUID? If you used either the
> two argument open which contained the command name and all of its arguments
> in the 2nd argument, or the 3 or more argument form, then you would not
> have an opportunity to do this before the $program got executed. That is
> the main thing that makes this safer than the alternative. The second
> thing is that by using the multi-argument form of exec, you prevent the
> shell from trying to interpret the arguments (this one you could also do,
> on sufficiently modern Perls, by using the more than 3 argument pipe open).
>
Peter J. Holzer said in a previous post that doing something like:
open(FOO, '|-', 'tr', '[a-z]', '[A-Z]'); #3 or more argument form of
open
Doesn't spawn a shell.
------------------------------
Date: 31 Mar 2007 02:28:09 GMT
From: xhoster@gmail.com
Subject: Re: Fundamental pipe questions
Message-Id: <20070330222813.301$1V@newsreader.com>
"grocery_stocker" <cdalten@gmail.com> wrote:
> On Mar 30, 6:17 pm, xhos...@gmail.com wrote:
> >
> > See here where it mucks around with $EUID? If you used either the
> > two argument open which contained the command name and all of its
> > arguments in the 2nd argument, or the 3 or more argument form, then you
> > would not have an opportunity to do this before the $program got
> > executed. That is the main thing that makes this safer than the
> > alternative. The second thing is that by using the multi-argument form
> > of exec, you prevent the shell from trying to interpret the arguments
> > (this one you could also do, on sufficiently modern Perls, by using the
> > more than 3 argument pipe open).
> >
>
> Peter J. Holzer said in a previous post that doing something like:
> open(FOO, '|-', 'tr', '[a-z]', '[A-Z]'); #3 or more argument form of
> open
>
> Doesn't spawn a shell.
I think he was wrong. It needs to be more than 3. Exactly three will
still start a shell (or at least it will if it detects any shell special
characters).
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Sat, 31 Mar 2007 08:58:42 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Fundamental pipe questions
Message-Id: <slrnf0s1l2.7u6.hjp-usenet2@yoyo.hjp.at>
On 2007-03-31 01:05, Lost Sheep Of the Porn <cdalten@gmail.com> wrote:
> On Mar 30, 11:56 am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
>> ["Followup-To:" header set to comp.lang.perl.misc.]
>> On 2007-03-30 14:00, grocery_stocker <cdal...@gmail.com> wrote:
>>
>> > What's the difference between
>> > open(FOO, "│tr ’[a-z]’ ’[A-Z]’");
>
>> > and
>>
>> > open(FOO, ’│-’, "tr ’[a-z]’ ’[A-Z]’");
>>
>> None.
>>
>
> If both these constructs are the same, then why does perlipc rattle on
> about using |- for safe pipe opens.
Look again. perldoc perlipc does NOT advocate the use of
open(FOO, '|-', "tr '[a-z]' '[A-Z]'");
as safe. It tells you to either use
open(FOO, '|-')
and then
exec('tr', '[a-z]' '[A-Z]');
in the child or (for perl >= 5.8.0) use the list form:
open(FOO, '|-', 'tr', '[a-z]' '[A-Z]');
just as I did (in the part you snipped).
The difference is safety doesn't come from separating '|-' from the
command name[0], but from separating the arguments from the program
name. Note that perlipc also uses the LIST form of exec - had they used
(exec("tr '[a-z]' '[A-Z]'") instead, the advantage would have been lost.
(In this example, it really doesn't matter since you use a fixed string
hard coded into your script. exec and open only become unsafe if you
construct the arguments from untrusted user input).
hp
[0] In general, open with a MODE is safer than only an EXPR, especially
for '<', and also for '-|' under some circumstances, but I can't
construct a case for '|-'. You should still make a habit of avoiding
the two-argument form of open.
--
_ | Peter J. Holzer | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR | to write clearly is like blaming English for
| | | hjp@hjp.at | the circumlocutions of bureaucrats.
__/ | http://www.hjp.at/ | -- Charlton Wilbur in clpm
------------------------------
Date: Sat, 31 Mar 2007 09:28:41 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Fundamental pipe questions
Message-Id: <slrnf0s3d9.7u6.hjp-usenet2@yoyo.hjp.at>
On 2007-03-31 01:53, grocery_stocker <cdalten@gmail.com> wrote:
> On Mar 30, 6:17 pm, xhos...@gmail.com wrote:
>> "Lost Sheep Of the Porn" <cdal...@gmail.com> wrote:
>> > Yes, the strange characters were introduced by my browser.
>>
>> Clearly they are introduced in your posting software, not your
>> browsing software. Please try to fix that, or people will be less
>> likely to respond to you.
>>
> I keep meaning to take an intro computer science class at the College
> of Marin. This school is like down the road from where I work at in
> San Rafael, California.
I don't think you need a computer science class to use a news reader.
For a start, you could try Thunderbird (it isn't a great newsreader, but
it's ok, simple to use and cross-platform).
hp
--
_ | Peter J. Holzer | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR | to write clearly is like blaming English for
| | | hjp@hjp.at | the circumlocutions of bureaucrats.
__/ | http://www.hjp.at/ | -- Charlton Wilbur in clpm
------------------------------
Date: Sat, 31 Mar 2007 09:31:21 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Fundamental pipe questions
Message-Id: <slrnf0s3i9.7u6.hjp-usenet2@yoyo.hjp.at>
On 2007-03-31 02:28, xhoster@gmail.com <xhoster@gmail.com> wrote:
> "grocery_stocker" <cdalten@gmail.com> wrote:
>> Peter J. Holzer said in a previous post that doing something like:
>> open(FOO, '|-', 'tr', '[a-z]', '[A-Z]'); #3 or more argument form of
>> open
>>
>> Doesn't spawn a shell.
>
> I think he was wrong.
If I had said that I would have been wrong, but I didn't. I was talking
about the list form of open, which has at least 4 arguments:
open FILEHANDLE,MODE,EXPR,LIST
> It needs to be more than 3. Exactly three will
> still start a shell (or at least it will if it detects any shell special
> characters).
Right.
hp
--
_ | Peter J. Holzer | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR | to write clearly is like blaming English for
| | | hjp@hjp.at | the circumlocutions of bureaucrats.
__/ | http://www.hjp.at/ | -- Charlton Wilbur in clpm
------------------------------
Date: Sat, 31 Mar 2007 10:04:04 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Fundamental pipe questions
Message-Id: <slrnf0s5fk.adt.hjp-usenet2@yoyo.hjp.at>
On 2007-03-31 01:17, xhoster@gmail.com <xhoster@gmail.com> wrote:
> "Lost Sheep Of the Porn" <cdalten@gmail.com> wrote:
>>
>> Yes, the strange characters were introduced by my browser.
>
> Clearly they are introduced in your posting software, not your browsing
> software.
His posting software was Google Groups (yes, I looked at his headers
before I suggested that the problem could be related to Google or his
browser). Last time I looked Google groups didn't have an NNTP
interface, so you need a browser to use it.
BTW I just posted a test message via Google groups and it didn't mangle
my single quotes and pipes, so I still think it's his browser or
something else on his computer (maybe he wrote his posting with MS-Word
and pasted it into google groups or something like that).
hp
--
_ | Peter J. Holzer | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR | to write clearly is like blaming English for
| | | hjp@hjp.at | the circumlocutions of bureaucrats.
__/ | http://www.hjp.at/ | -- Charlton Wilbur in clpm
------------------------------
Date: Sat, 31 Mar 2007 09:19:27 +0200
From: "max" <max@xxx.tovle.ct>
Subject: How to make send key ([tab] [tab]Text [Enter]) in some program (Internet Explorer or Notepad)?
Message-Id: <eul21e$m7d$1@ss408.t-com.hr>
How to make send key ([tab] [tab]Text [Enter]) in some program (Internet
Explorer or Notepad)?
Thanks
Max
------------------------------
Date: Sat, 31 Mar 2007 04:42:11 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sat Mar 31 2007
Message-Id: <JFr3qB.vo5@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.
Apache-Quota-0.04
http://search.cpan.org/~drolsky/Apache-Quota-0.04/
Flexible transfer limiting/throttling under mod_perl
----
Apache-SizeLimit-0.91
http://search.cpan.org/~gozer/Apache-SizeLimit-0.91/
Because size does matter.
----
Bio-Phylo-0.16
http://search.cpan.org/~rvosa/Bio-Phylo-0.16/
Phylogenetic analysis using perl.
----
Business-Tax-Canada-0.03
http://search.cpan.org/~agrundma/Business-Tax-Canada-0.03/
perform Canadian GST/HST/PST calculations
----
CGI-FCKeditor-0.01
http://search.cpan.org/~shiraiwa/CGI-FCKeditor-0.01/
FCKeditor For OOP Module
----
CGI-Simple-0.080
http://search.cpan.org/~andya/CGI-Simple-0.080/
A Simple totally OO CGI interface that is CGI.pm compliant
----
Catalyst-Controller-Rose-0.01
http://search.cpan.org/~karman/Catalyst-Controller-Rose-0.01/
RDBO and RHTMLO base classes for Catalyst
----
Catalyst-Plugin-Crypt-CBC-0.01
http://search.cpan.org/~shiraiwa/Catalyst-Plugin-Crypt-CBC-0.01/
Crypt::CBC plugin for Catalyst.
----
Catalyst-Plugin-ParseDateTime-0.01
http://search.cpan.org/~shiraiwa/Catalyst-Plugin-ParseDateTime-0.01/
ASCII String to DateTime Object for Catalyst.
----
Class-DBI-MockDBD-0.01
http://search.cpan.org/~teejay/Class-DBI-MockDBD-0.01/
Mocked database interface for Class::DBI
----
Class-Factory-Util-1.7
http://search.cpan.org/~drolsky/Class-Factory-Util-1.7/
Provide utility methods for factory classes
----
DBIx-DataModel-0.30
http://search.cpan.org/~dami/DBIx-DataModel-0.30/
Classes and UML-style Associations on top of DBI
----
DBIx-MoCo-0.09
http://search.cpan.org/~jkondo/DBIx-MoCo-0.09/
Light & Fast Model Component
----
DateTime-0.37
http://search.cpan.org/~drolsky/DateTime-0.37/
A date and time object
----
FindBin-libs-1.35
http://search.cpan.org/~lembark/FindBin-libs-1.35/
Locate and 'use lib' directories along the path of $FindBin::Bin to automate locating modules. Uses File::Spec and Cwd's abs_path to accomodate multiple O/S and redundant symlinks.
----
Google-Checkout-1.0.3
http://search.cpan.org/~dzhuo/Google-Checkout-1.0.3/
----
JE-0.006
http://search.cpan.org/~sprout/JE-0.006/
Pure-Perl ECMAScript (JavaScript) Engine
----
Lemonldap-Handlers-CAS-1.0
http://search.cpan.org/~egerman/Lemonldap-Handlers-CAS-1.0/
Perl extension for Lemonldap webSSO
----
Lemonldap-Portal-Standard-3.1.2
http://search.cpan.org/~egerman/Lemonldap-Portal-Standard-3.1.2/
Perl extension for the Lemonldap SSO system
----
Lingua-ZH-WordSegmenter-0.01
http://search.cpan.org/~jzhang/Lingua-ZH-WordSegmenter-0.01/
Simplified Chinese Word Segmentation
----
Pod-AxPoint-0.03
http://search.cpan.org/~tlinden/Pod-AxPoint-0.03/
Generate AxPoint XML slideshow from POD source.
----
Pod-AxPoint-0.04
http://search.cpan.org/~tlinden/Pod-AxPoint-0.04/
Generate AxPoint XML slideshow from POD source.
----
Pod-S5-0.05
http://search.cpan.org/~tlinden/Pod-S5-0.05/
Generate S5 slideshow from POD source file.
----
Pod-S5-0.06
http://search.cpan.org/~tlinden/Pod-S5-0.06/
Generate S5 slideshow from POD source file.
----
Pod-S5-0.07
http://search.cpan.org/~tlinden/Pod-S5-0.07/
Generate S5 slideshow from POD source file.
----
Router-Statistics-0.99_91
http://search.cpan.org/~shamrock/Router-Statistics-0.99_91/
Router Statistics and Information Collection
----
Sepia-0.68
http://search.cpan.org/~seano/Sepia-0.68/
Simple Emacs-Perl Interface
----
Sepia-0.69
http://search.cpan.org/~seano/Sepia-0.69/
Simple Emacs-Perl Interface
----
Sort-SQL-0.02
http://search.cpan.org/~karman/Sort-SQL-0.02/
manipulate SQL sort strings
----
Storable-2.16
http://search.cpan.org/~ams/Storable-2.16/
persistence for Perl data structures
----
Sys-Manage-0.56
http://search.cpan.org/~makarow/Sys-Manage-0.56/
Systems management commands/scripts environment
----
Template-Plugin-RoundRobin-0.02
http://search.cpan.org/~gugod/Template-Plugin-RoundRobin-0.02/
Server data in a round robin manner.
----
Thesaurus-0.22
http://search.cpan.org/~drolsky/Thesaurus-0.22/
Maintains lists of associated items
----
Thread-Pool-Simple-0.20
http://search.cpan.org/~jwu/Thread-Pool-Simple-0.20/
A simple thread-pool implementation
----
WebService-Images-IMGSpot-0.02
http://search.cpan.org/~blom/WebService-Images-IMGSpot-0.02/
upload an image to http://www.imgspot.com/
----
Wx-Perl-ProcessStream-0.07
http://search.cpan.org/~mdootson/Wx-Perl-ProcessStream-0.07/
----
base-ball-v0.0.1
http://search.cpan.org/~dmuey/base-ball-v0.0.1/
"b" all the namespaces under the given one(s)
----
cant-v0.0.1
http://search.cpan.org/~dmuey/cant-v0.0.1/
See if an object or package cant do something
----
dmake-4.8-20070327-SHAY
http://search.cpan.org/~shay/dmake-4.8-20070327-SHAY/
----
eBay-API-0.21
http://search.cpan.org/~ebay/eBay-API-0.21/
Perl SDK for eBay Web services Interface
----
mod_perl-1.30
http://search.cpan.org/~gozer/mod_perl-1.30/
Embed a Perl interpreter in the Apache HTTP server
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 15:39:02 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Perl package install dll problems
Message-Id: <460df3f9$0$4753$afc38c87@news.optusnet.com.au>
"ChrisC" <christopher.m.collins@gmail.com> wrote in message
.
.>
> If you unset PERL_INLINE_JAVA_JINI then you are not testing the JNI
> extension when you run the tests. If I do that then it is all
> successful too. Problem is, I need the JNI extension, and the perl
> interpreter extension, which defaults as 'n' on the perl Makefile.PL.
> But, thanks for the suggestion.
>
Oh ... thanks for taking the time to correct me.
On closer inspection (and having reset PERL_INLINE_JAVA_JNI) I find that
JNI.dll is failing to load because jvm.dll cannot be found.
You can fix that by adding C:/jdk1.5.0_11/jre/bin/server to your path.
(Worked for me - though I don't know whether it's the server or the client
jvm.dll that ought to be put in the path.)
Cheers,
Rob
------------------------------
Date: Fri, 30 Mar 2007 19:17:44 -0700
From: Xiong Changnian <please@nospam.net>
Subject: Re: Question about wizard Perl programmers -- Answers
Message-Id: <please-A48ECE.19174430032007@free.teranews.com>
I see a lot of funny stuff said but few clear answers to the original
poster.
* * *
In article <1173067931.041020.191050@c51g2000cwc.googlegroups.com>,
"LovesHisLittleShad" <jgrace5@gmail.com> wrote:
> Is it my imagination, or is Perl a million
> times harder than other languages?
No; it's much much easier to use, to get a job done, than almost any
other language. Even if you know very little about Perl, you can try to
write a simple program using it -- and have a fair chance of it working.
However, Perl is also extremely powerful and it's difficult to learn to
control that much power. That's only another way of saying that nothing
is free.
Imagine, if you will, a demon or slave who is extremely intelligent and
will do absolutely anything you ask of it. It understands your natural
language but will not do much to infer your *intent* -- what you request
is what you get, not necessarily what you desire.
* The Monkey's Paw:
The charmed paw of a monkey grants three wishes. Its new owner, without
thinking, asks for cash -- and gets it from the insurance when his son
is killed. Anguished, he wishes his son alive again -- and sees the
decaying corpse walking and talking. He uses his third wish to return
his son to the grave.
The owner of the monkey's paw was careless; he tried to use a tool of
great power without thinking clearly. More wisely, he might have used
his first wish to demand an unlimited number of additional wishes (or
extra monkey paws). He might have specified not only cash but the means
by which he wished to receive it. Asking for long life, he might ask
also for health and for the ability to end that life in case of boredom.
The paw is not to blame.
Perl provides more power at less brainpower cost than any other language
I've seen; and I've seen quite a few. Nothing can compensate for a
failure to think.
> ...Perl is the only one that seems greek
> in most chapters, with very little explanation
> of what the people are doing.
Depends on the book but, yes, I agree that there is a sort of rough
assumption in most Perl documentation that the reader has considerable
programming background. Much is taken for granted. That's a shame; I
think Perl is a good place to *begin* for the novice programmer.
I've noticed many places where a Perl feature is explained by saying
"this works the same as the corresponding shell command". That's fine if
you are familiar with *NIX shell; otherwise, you're lost.
O'Reilly's /Learning Perl/ by Schwartz and Phoenix starts off more
gently than some books but even here, I feel, you get stuffed into
things somewhere in the middle and have to find your own ground. To some
extent, I think this is just Perl culture. The assumption is that you're
better off making your own mistakes and forming your own model of how
Perl works, rather than having a model thrust upon you.
It seems as if Perl is often a reaction against the strict structures of
C and other formal languages. For about 50 years, every basic book about
programming covered the same ground in about the same way. Perl books
often seem to delight in violating these conventions. It's more fun but
it's not always more clear.
> ...does the Perl language literally attract
> the wizards of the world to it...?
I'd have to disagree. There have always been proficient programmers who
spend their free time writing weird code. It's exactly equivalent to
puns and word games made up by fluent speakers of English. Perl does
lend itself to this kind of foolishness, though, just as Chinese
(/putonghua/) is the best natural language for making puns.
* * *
If I may venture a suggestion, dive right in. Take a small problem and
code it up. Ignore, for the most part, the advanced idioms and clever
labor-saving approaches; just write code in the most straightforward way
you know. You can write Perl that looks almost exactly like C or Pascal.
When you start to look at code examples, you'll see that Perl syntax is
extremely flexible and not all of the variations are well documented.
You might like to take some snippets and rewrite them in familiar
idioms; then take some of your own code and rewrite them using syntax
you've just learned.
Another tip is to use much more whitespace than you see in the books.
You'll often see code that throws a lot of punctuation marks together,
usually with many braces. Sort this stuff out, balance the braces in
your own mind, and meaning may emerge.
I'm only just learning Perl myself and I've already done a lot with it.
I often find that when I'm frustrated, it's not because Perl is making
me do something weird -- it's that I *think* I have to do something
weird or strained because that's what I've learned in other languages.
But Perl lets me do things the easy way -- if only I try.
Good luck!
--
Xiong Changnian
xiong102ATxuefangDOTcom
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Fri, 30 Mar 2007 18:23:46 -0700
From: Xiong Changnian <please@nospam.net>
Subject: Re: Shifting Away
Message-Id: <please-5E3452.18234630032007@free.teranews.com>
In article <572nr3F2bt8ohU1@mid.dfncis.de>,
anno4000@radom.zrz.tu-berlin.de wrote:
> ...it's harder to demonstrate than I thought.
To recap, I understand you to claim that actual params can be clobbered
within a called sub that shift-s.
> sub x3 { shift() = 13 }
>
> doesn't compile...
Well, here you're trying to assign to shift itself; I believe shift is
never an lvalue.
> sub x1 { $_ = 13 for shift }
That does indeed clobber the actual param. As I understand it, your code
shifts off the first (or only) param -- by definition, not a list --
then treats it as a single-element list; the first (and only) trip
through the foreach loop, $_ is set to the first (and only) element of
that list. And $_ is an alias to the thing itself.
I guess if you try hard enough, you can break anything.
> I had intended to delete
> that sentence and dodge an explanation...
Why? This is what it's all about: finding the edges. Now, I'll be sure
not to do *that*. Thank you.
--
Xiong Changnian
xiong102ATxuefangDOTcom
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Sat, 31 Mar 2007 09:55:34 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Shifting Away
Message-Id: <slrnf0s4vm.9s8.hjp-usenet2@yoyo.hjp.at>
On 2007-03-31 01:05, Xiong Changnian <please@nospam.net> wrote:
> In article <euhch3.1jc.1@news.isolution.nl>,
> "Dr.Ruud" <rvtol+news@isolution.nl> wrote:
>> Xiong Changnian schreef:
>> > The literal 'bang' clobbers the calling context's value ('goodstuff')
>> > of $foo -- bug, feature, or sloppy coder, you decide. In essence,
>> > it's a call-by-reference but no dereffing is expected.
>>
>> You should stop making such statements until you understand why it is
>> like it is.
>> But even if you don't, I won't notice it, goodbye.
>
> Well, no need to be snooty. Enlighten me. I'm not even sure what part of
> my questionable statement offends.
>
> Are you questioning "call-by-reference"? I weaseled with "in essence". I
> don't think it *is* a call-by-value if I *can* clobber it. On the other
> hand, it's not a ref as Perl defines such things.
It is call-by-reference. In other languages which pass parameters by
reference you don't have to explicitely dereference them either.
> It seems to me that the call-by-ref nature of perl is something that can
> be put to use but at times, it's exactly what's not wanted. So if actual
> params get clobbered, you can blame Perl, acclaim Perl, or blame the
> coder.
It wasn't clear who you were blaming of "sloppy coding". Larry Wall or
the coder of the subroutine which clobbers its arguments?
I think we can rule out that the fact that perl uses call-by-reference
is the result of sloppy coding. That was a design decision. We can
debate whether it was a good or a bad decision, but I think there is no
question that Larry thought about whether he wanted to implement
call-by-value or call-by-reference and decided for call-by-reference.
As for the coder of the routine: That may be sloppyness, or it may be
intentional.
> I suppose I should have included the possibility of acclaiming
> the coder for his brilliant decision.
Yes. That possibility does exist. If there would never be a reason for
clobbering an argument then implementing call-by-reference was a mistake
in the first place. You will notice that many of perls built-in
functions do clobber one of their arguments.
hp
--
_ | Peter J. Holzer | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR | to write clearly is like blaming English for
| | | hjp@hjp.at | the circumlocutions of bureaucrats.
__/ | http://www.hjp.at/ | -- Charlton Wilbur in clpm
------------------------------
Date: Sat, 31 Mar 2007 05:20:48 GMT
From: "Arved Sandstrom" <asandstrom@accesswave.ca>
Subject: Re: What are OOP's Jargons and Complexities
Message-Id: <QcmPh.29531$x9.22267@edtnps89>
"Timofei Shatrov" <grue@mail.ru> wrote in message
news:460cc83a.2652073@news.readfreenews.net...
> On Fri, 30 Mar 2007 06:48:05 GMT, "Mike Schilling"
> <mscottschilling@hotmail.com>
> tried to confuse everyone with this message:
>
>>Xah Lee wrote:
>>
>>> So, a simple code like this in normal languages:
>
>>> becomes in Java:
>>
>>Only when written by someone almost entirely ignorant of Java.
>>
>
> Which is the state most people want to be in...
Which based on what I've seen, is the state that most Java programmers are
in. They'd have no idea why Mike said what he did.
AHS
------------------------------
Date: Sat, 31 Mar 2007 05:24:51 GMT
From: "Arved Sandstrom" <asandstrom@accesswave.ca>
Subject: Re: What are OOP's Jargons and Complexities
Message-Id: <DgmPh.29532$x9.17555@edtnps89>
"Mike Schilling" <mscottschilling@hotmail.com> wrote in message
news:SFbPh.10507$JZ3.490@newssvr13.news.prodigy.net...
> bugbear wrote:
>> Er. How about
>>
>> public class test {
>> public static void main(String[] args) {
>> String a = "a string";
>> String b = "another one";
>> StringBuffer c = a + b;
>
> String c (etc.), that is.
My answer, Mike. Since there was never any need for variables "a" and "b" to
be separate, I'd just be blatting out
System.out.println("a stringanother one");
as the solution to this particular problem. It's just a confuscated Hello
World.
AHS
------------------------------
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 286
**************************************