[23949] in Perl-Users-Digest
Perl-Users Digest, Issue: 6150 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 17 21:05:37 2004
Date: Tue, 17 Feb 2004 18:05:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 17 Feb 2004 Volume: 10 Number: 6150
Today's topics:
Re: CGi parameters lost <flavell@ph.gla.ac.uk>
Re: CGi parameters lost <uri@stemsystems.com>
Re: more stripping <gnari@simnet.is>
Re: more stripping <tadmc@augustmail.com>
Re: OPEN( , Get , or slurping problem <noreply@gunnar.cc>
perl and late binding for OLE obj (st)
Posting Usenet News Messages <ignoromnibus@cochon.fr>
Re: Posting Usenet News Messages <tadmc@augustmail.com>
Re: Posting Usenet News Messages <ignoromnibus@cochon.fr>
Problem using/creating nested anonymous arrays moller@notvalid.se
Re: Problem using/creating nested anonymous arrays <noreply@gunnar.cc>
Re: Problem using/creating nested anonymous arrays moller@notvalid.se
Re: T*ent C*rry, wsanford@wallysanford.com, and falsely <tcurrey@no.no.i.said.no>
Re: T*ent C*rry, wsanford@wallysanford.com, and falsely <gnari@simnet.is>
Re: Trent Curry, wsanford@wallysanford.com, and falsely <tcurrey@no.no.i.said.no>
Re: understanding perl "get ($url) " function <gnari@simnet.is>
Re: understanding perl "get ($url) " function <tadmc@augustmail.com>
Re: Why is Perl losing ground? <usenet@morrow.me.uk>
Re: Why is Perl losing ground? <beable+unsenet@beable.com.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 17 Feb 2004 23:01:04 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: CGi parameters lost
Message-Id: <Pine.LNX.4.53.0402172300370.28729@ppepc56.ph.gla.ac.uk>
On Tue, 17 Feb 2004, Gregory Toomey wrote:
> Damu Zhang wrote:
>
> > We are having a CGI issue, our clients send parameters via form POST, but
> > sporadically the values turn be to empty, and it happened all of sunden
> > since early last week. Anyone has the same issue?
>
> Yes, it happens to me every Monday.
You've got an error on line 37.
SCNR
------------------------------
Date: Wed, 18 Feb 2004 01:04:13 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: CGi parameters lost
Message-Id: <x7y8r1w642.fsf@mail.sysarch.com>
>>>>> "AJF" == Alan J Flavell <flavell@ph.gla.ac.uk> writes:
AJF> On Tue, 17 Feb 2004, Gregory Toomey wrote:
>> Damu Zhang wrote:
>>
>> > We are having a CGI issue, our clients send parameters via form POST, but
>> > sporadically the values turn be to empty, and it happened all of sunden
>> > since early last week. Anyone has the same issue?
>>
>> Yes, it happens to me every Monday.
AJF> You've got an error on line 37.
please to be updating your version of PSI::ESP. it is clearly an error
on line 42.
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: Tue, 17 Feb 2004 23:19:55 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: more stripping
Message-Id: <c0u7h8$s1k$1@news.simnet.is>
[please post in text-only]
"Michael Hill" <hillmw@ram.lmtas.lmco.com> wrote in message
news:403284A6.8A63C04B@ram.lmtas.lmco.com...
>
> Don't you _ever_ - and I really mean _ever_ - try to hand-roll this on
> your own. Let CGI.pm do that for you (untested):
you should work on your attributions.
> Sorry, I'd rather "hand roll" it.
> a) If I let modules do everything I need then I'll never remember
anything,
Au contraire, if you use modules to do complex but standard stuff, so you
can remember
what your program is about. your program is not about the intricacies of
HTTP and CGI,
it is about your interaction with the user, and the content of your output.
> b) Modules take up memory ...
> For obvious reasons the modules I use most are Date_Manip.pm and GD.pm
this is really funny. Date::Manip is a real dinosaur of a module. (i like
it, but you
just complained about memory usage of modules).
and also, the idea that you would not use CGI.pm, that takes care of a
complicated
task that one would prefer not to have to know all the details of, but you
use an
enormous module for date manipulations.
gnari
------------------------------
Date: Tue, 17 Feb 2004 15:57:38 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: more stripping
Message-Id: <slrnc353ii.4m3.tadmc@magna.augustmail.com>
Michael Hill <hillmw@ram.lmtas.lmco.com> wrote:
HTML is for machines, we are people.
Please do not post in HTML.
> Don't you _ever_ - and I really mean _ever_ - try to hand-roll this
> on
> your own. Let CGI.pm do that for you (untested):
> Sorry, I'd rather "hand roll" it.
You are too silly to spend time on then, so long.
*plonk*
There are many common security exploits that rely on hand-rolled
form parsing.
If you are not an expert in security, then you should perhaps
consider using code from such a person. Else we'll be hearing
about your system crash on the 6 o'clock news...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 18 Feb 2004 01:04:08 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <c0uar6$1bfkv1$1@ID-184292.news.uni-berlin.de>
Michele Dondi wrote:
> On Tue, 17 Feb 2004 13:08:46 +0100, Gunnar Hjalmarsson
> <noreply@gunnar.cc> wrote:
>>
>>> # untested
>>> open my $file, '<', \$site or die $!;
>>> do_something while <$file>;
>>
>> Well, I tested, and it just made my script hang.
>
> I assumed that $site contains the downloaded page as a string (as
> of the snippet I *quoted* in my post):
>
> my $site = get 'http://www.webbuyeruk.co.uk/links.htm';
Yep. I explained in a reply to Ben the nature of the problem I
encountered.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 17 Feb 2004 17:39:10 -0800
From: samtung1@yahoo.com (st)
Subject: perl and late binding for OLE obj
Message-Id: <b3825b8b.0402171739.4f175738@posting.google.com>
Hi,
Is there any way to make late binding for ole objects?
Perl does not allow for class specification. Is there a package, pm
file that I can modify to make the ole return a child class type?
many thanks,
s.t.
------------------------------
Date: Tue, 17 Feb 2004 17:37:13 -0600
From: Camelback Jones <ignoromnibus@cochon.fr>
Subject: Posting Usenet News Messages
Message-Id: <c0u8pr057q@enews4.newsguy.com>
Well, thanks to Paul Lalli, I can read - and print, file, etc - USENET
messages okay now.
Now I want to move on to posting USENET messages. And, of course, I'm doing
something stupid again. I think I've got a proper list of lines, and I
think I've got the lines formatted properly - at least, I don't see what's
wrong with the list.
Referring to O'Reilly's Pearl Cookbook, #18.4, i ahve slightly modified
$server->postok() or die "Not allowed to post";
# so we CAN post:
@lines=("From: Norbo Quantitator <aintg\@noemail.com>",
"Date: Fri, Feb 13 2004 15:14:13 CST",
"Newsgroups: alt.test",
"Subject: One More Test",
"Message-ID: <433498\@noemail.com>",
"Path: aintg",
" ",
"This is the body of this message.",
"There may be any number of body lines. Or not.",
" "
);
foreach $line (@lines) { print "$line\n";}
$server->post( [ @lines ] ) or die "Can't post: $!\n";
And it dies. "Can't post: " (no $! content).
Once again, I'm sure I'm doing something stupid, but it seems to me I'm
following the rules, and this code follows some in which we log onto a news
reader and select the "alt.test" newsgroup and read the last message... and
it =does= pass the postok() test... and the message format =looks= okay (as
far as I can tell... I've gone back and forth with and witout blank lines,
with and without newlines, and various versions of the required headers...).
--
The greatest unsolved theorem in mathematics is why some people are
better at it than others.
------------------------------
Date: Tue, 17 Feb 2004 18:44:06 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Posting Usenet News Messages
Message-Id: <slrnc35dam.5l0.tadmc@magna.augustmail.com>
Camelback Jones <ignoromnibus@cochon.fr> wrote:
> I think I've got a proper list of lines, and I
> think I've got the lines formatted properly - at least, I don't see what's
> wrong with the list.
> @lines=("From: Norbo Quantitator <aintg\@noemail.com>",
@lines=('From: Norbo Quantitator <aintg@noemail.com>',
I hate backslashes, they slow me down when reading the code.
> "Date: Fri, Feb 13 2004 15:14:13 CST",
'Date: Fri, Feb 13 2004 15:14:13 CST',
I dislike being tricked into looking for variables being
interpolated when there are no variables being interpolated.
Consider using single quotes unless you are going to actually
make use of one of the two extra things that double quotes give
you, namely interpolation and backslash escapes.
> "Newsgroups: alt.test",
> "Subject: One More Test",
> "Message-ID: <433498\@noemail.com>",
> "Path: aintg",
> " ",
^
^
^ you don't want that space character there.
> "This is the body of this message.",
> "There may be any number of body lines. Or not.",
> " "
> );
>
> foreach $line (@lines) { print "$line\n";}
So what will be output? Here's part of it:
Path: aintg\n \nThis is the body of this message.\n
^^^^^
But you need "\n\n" to end the headers, and that sequence is not there.
So the claim "This is the body of this message." is a lie, it
is in the headers of the message.
:-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 17 Feb 2004 19:26:00 -0600
From: Camelback Jones <ignoromnibus@cochon.fr>
Subject: Re: Posting Usenet News Messages
Message-Id: <c0uf5r0lao@enews2.newsguy.com>
Tad McClellan wrote:
> Camelback Jones <ignoromnibus@cochon.fr> wrote:
>
>> I think I've got a proper list of lines, and I
>> think I've got the lines formatted properly - at least, I don't see
>> what's wrong with the list.
>
>> @lines=("From: Norbo Quantitator <aintg\@noemail.com>",
>
>
> @lines=('From: Norbo Quantitator <aintg@noemail.com>',
>
>
> I hate backslashes, they slow me down when reading the code.
>
>
>> "Date: Fri, Feb 13 2004 15:14:13 CST",
>
>
> 'Date: Fri, Feb 13 2004 15:14:13 CST',
>
>
> I dislike being tricked into looking for variables being
> interpolated when there are no variables being interpolated.
No one's "tricking" you, except possibly yourself.
>
> Consider using single quotes unless you are going to actually
> make use of one of the two extra things that double quotes give
> you, namely interpolation and backslash escapes.
>
Given that the backslashes are there and (as far as I know) there's nothing
to interpolate, it won't make any difference, will it? With single quotes,
you don't get the escaped newline, either/
>
>> "Newsgroups: alt.test",
>> "Subject: One More Test",
>> "Message-ID: <433498\@noemail.com>",
>> "Path: aintg",
>> " ",
> ^
> ^
> ^ you don't want that space character there.
Why not? The spec calls for a blank line. What DO you want there?
>> "This is the body of this message.",
>> "There may be any number of body lines. Or not.",
>> " "
>> );
>>
>> foreach $line (@lines) { print "$line\n";}
>
>
> So what will be output? Here's part of it:
>
> Path: aintg\n \nThis is the body of this message.\n
> ^^^^^
>
> But you need "\n\n" to end the headers, and that sequence is not there.
And with single quotes, it won't be there either, it'll just be the
characters "\n\n".
I've gone back and forth, with and without one or more "blank" lines, and,
as stated, with and without newlines as part of the line content. Doesn't
seem to have made a diff so far.
> So the claim "This is the body of this message." is a lie, it
> is in the headers of the message.
No, it's not a lie. It may be incorrect, but it's not a lie - you need to
be able to distinguish those conditions.
If I'm interpreting your comments, should this work?
@lines = ('From: Norbo Quantitator <aintg@noemail.com>',
'Date: Fri, Feb 13 2004 15:14:13 CST',
'Newsgroups: alt.test',
'Subject: One More Test',
'Message-ID: <433499@noemail.com>',
'Path: aintg',
'',
'',
'This is the body of this message.',
'There may be any number of body lines. Or not.',
''
);
It doesn't - perhaps you have an example that does?
>
> :-)
>
>
--
The greatest unsolved theorem in mathematics is why some people are
better at it than others.
------------------------------
Date: Wed, 18 Feb 2004 00:23:07 GMT
From: moller@notvalid.se
Subject: Problem using/creating nested anonymous arrays
Message-Id: <uznbhz141.fsf@notvalid.se>
I'm new to perl but not to programming in general.
I have been trying to put some data into an excel
sheet. And it works fine.... if I hardcode the data.
And I of cource I dont want to do that.
This code works:
my $table = [["040101",11,12,13,14,15],
["040102",21,22,23,24,25],
["040103",31,32,33,34,35],
["040104",41,42,43,44,45],
["040105",51,52,53,54,55]];
$Sheet->Range("A3:E7")->{Value} = $table;
So my (probably stupid) question is:
How do I create the $table array dynamicly?
foreach (sort (keys %My_hash)) {
my $A = $My_hash{$_} { data_a };
my $B = $My_hash{$_} { data_b };
my $C = $My_hash{$_} { data_c };
my $D = $My_hash{$_} { data_d };
my $E = $My_hash{$_} { data_e };
And here I would like to create each "row" in the array
}
I have tried using an normal array like this but this goes wrong.
I get nonsens data in my excel file.
my @arr;
foreach (sort (keys %My_hash)) {
my $A = $My_hash{$_} { data_a };
my $B = $My_hash{$_} { data_b };
my $C = $My_hash{$_} { data_c };
my $D = $My_hash{$_} { data_d };
my $E = $My_hash{$_} { data_e };
push @arr, [$_, $A, $B, $C, $D, $D];
}
$Sheet->Range("A3:E7")->{Value} = @arr;
I'm quite sure ther is somthing basic I'm missing.
Any suggestions apreciated.
------------------------------
Date: Wed, 18 Feb 2004 01:28:08 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Problem using/creating nested anonymous arrays
Message-Id: <c0uc89$1ckdd0$1@ID-184292.news.uni-berlin.de>
moller@notvalid.se wrote:
> I have been trying to put some data into an excel
> sheet.
<snip>
> This code works:
>
> my $table = [["040101",11,12,13,14,15],
> ["040102",21,22,23,24,25],
> ["040103",31,32,33,34,35],
> ["040104",41,42,43,44,45],
> ["040105",51,52,53,54,55]];
>
> $Sheet->Range("A3:E7")->{Value} = $table;
$table is a *reference* to an array of array references.
<snip>
> I have tried using an normal array like this but this goes wrong.
> I get nonsens data in my excel file.
>
> my @arr;
>
> foreach (sort (keys %My_hash)) {
> my $A = $My_hash{$_} { data_a };
> my $B = $My_hash{$_} { data_b };
> my $C = $My_hash{$_} { data_c };
> my $D = $My_hash{$_} { data_d };
> my $E = $My_hash{$_} { data_e };
>
> push @arr, [$_, $A, $B, $C, $D, $D];
> }
>
> $Sheet->Range("A3:E7")->{Value} = @arr;
Try to use a *reference* to the array of array references:
$Sheet->Range("A3:E7")->{Value} = \@arr;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 18 Feb 2004 01:33:17 GMT
From: moller@notvalid.se
Subject: Re: Problem using/creating nested anonymous arrays
Message-Id: <uoerxyxw9.fsf@notvalid.se>
Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
> moller@notvalid.se wrote:
> > I have been trying to put some data into an excel
> > sheet.
>
> <snip>
>
> > This code works:
> > my $table = [["040101",11,12,13,14,15],
> > ["040102",21,22,23,24,25],
> > ["040103",31,32,33,34,35],
> > ["040104",41,42,43,44,45],
> > ["040105",51,52,53,54,55]];
> > $Sheet->Range("A3:E7")->{Value} = $table;
>
> $table is a *reference* to an array of array references.
>
> <snip>
>
> > I have tried using an normal array like this but this goes wrong.
> > I get nonsens data in my excel file.
> > my @arr;
> > foreach (sort (keys %My_hash)) {
> > my $A = $My_hash{$_} { data_a };
> > my $B = $My_hash{$_} { data_b };
> > my $C = $My_hash{$_} { data_c };
> > my $D = $My_hash{$_} { data_d };
> > my $E = $My_hash{$_} { data_e };
> > push @arr, [$_, $A, $B, $C, $D, $D];
> > }
> > $Sheet->Range("A3:E7")->{Value} = @arr;
>
> Try to use a *reference* to the array of array references:
>
> $Sheet->Range("A3:E7")->{Value} = \@arr;
>
Gaah!! I could have sworn I already tried that.
Well it works anyway.
Thanks
------------------------------
Date: Tue, 17 Feb 2004 17:11:37 -0800
From: "Trent Curry" <tcurrey@no.no.i.said.no>
Subject: Re: T*ent C*rry, wsanford@wallysanford.com, and falsely using existing email addresses
Message-Id: <c0ue0o$90k$1@news.astound.net>
Wally Sanford wrote:
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:c0qgba$for$1@mamenchi.zrz.TU-Berlin.DE...
>
>> From his past behavior I wouldn't expect him to use your address
>> again. He seems to pick them up at random for use in one of his
>> campaigns, which lasts until the forgery has become absolutely
>> undeniable. The next
>> time he picks new ones.
>>
>> Anno
>
> Thanks, Anno. Yeah, I spent some time searching around about this
> loon, and I see that he goes by Man*ny Wil*o, Al MacH**ney, R*bin
> G*vens, and a host of others. I think I can tell when he stopped
> using one of them and started using my name as an alias.
>
> Harmless though he may be, you can imagine my dismay, in that I do
> not wish to appear to be any more of a loon than I manage to be on my
> own, nor do I wish to be confused with Uber Loons, lest I get a cool
> reception on some group. Say I revived my interest in Perl and
> unwittingly posted to this group using my actual name? At best, I
> might get support only from the, I'd guess, few that haven't
> killfiled this character. That's why I was trying to munge the
> character's aliases above, in hopes that those with loaded killfiles
> might see this.
I have and never had any association with any one either of you have
just listed. Again, I do not know why I was put in this list, I am jsut
greatfu lto the person that alerted me of this thread.
--
Trent Curry
perl -e
'($s=qq/e29716770256864702379602c6275605/)=~s!([0-9a-f]{2})!pack("h2",$1
)!eg;print(reverse("$s")."\n");'
------------------------------
Date: Wed, 18 Feb 2004 01:22:05 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: T*ent C*rry, wsanford@wallysanford.com, and falsely using existing email addresses
Message-Id: <c0uem7$su6$1@news.simnet.is>
"Trent Curry" <tcurrey@no.no.i.said.no> wrote in message
news:c0ue0o$90k$1@news.astound.net...
> Wally Sanford wrote:
> > "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> > news:c0qgba$for$1@mamenchi.zrz.TU-Berlin.DE...
> >
> >> ...
> I have and never had any association with any one either of you have
> just listed. Again, I do not know why I was put in this list, I am jsut
oops. you wrote 'jsut'. (see other post by Anno on this thread)
> greatfu lto the person that alerted me of this thread.
>
------------------------------
Date: Tue, 17 Feb 2004 17:09:37 -0800
From: "Trent Curry" <tcurrey@no.no.i.said.no>
Subject: Re: Trent Curry, wsanford@wallysanford.com, and falsely using existing email addresses
Message-Id: <c0udt0$90i$1@news.astound.net>
Wally Sanford wrote:
How exactly did you assicate me with this? I have nothing to do with
whom you speak of. I would not even know of this posting has someoen not
alerted me to it.
--
Trent Curry
perl -e
'($s=qq/e29716770256864702379602c6275605/)=~s!([0-9a-f]{2})!pack("h2",$1
)!eg;print(reverse("$s")."\n");'
------------------------------
Date: Tue, 17 Feb 2004 23:31:03 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: understanding perl "get ($url) " function
Message-Id: <c0u861$s31$1@news.simnet.is>
"KK" <kewlkarun@yahoo.com> wrote in message
news:c8fd5039.0402171336.2a6a617a@posting.google.com...
> Hi there,
> I need to access several pages of the website viz.,
> 'www.ieeexplore.ieee.org/Xplore/DynWel.jsp' (only accessable to
> members). unfortunately, I cannot open multiple browsers (more than
> 10) of that website on my PC (a constraint set by the number of
> licenses bought). However, one can navigate as many pages as you wish
> in a single browser.
>
> Coming to the problem, I have a perl program which browses through
> several pages of the above mentioned website through use of get($url)
> function. Doing so, after some executions of get($url) function, I run
> into the problem of limited licenses (mentioned above). Does this
> mean, every time I execute get($url) function, its equivalent to
> opening the url in a new browser? If yes,
> what is the possible alternative to get around this problem?
>
actually, this depends on exactly how the site is tracking sessions.
2 things come to mind: referer and cookies (most likely)
you should figure if the site is using one of these, and alter your
program accordingly
when you have a perl question come back to this group, but
there are other groups more suited to HTTP discussions.
gnari
------------------------------
Date: Tue, 17 Feb 2004 18:50:11 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: understanding perl "get ($url) " function
Message-Id: <slrnc35dm3.5l0.tadmc@magna.augustmail.com>
Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:
> KK (kewlkarun@yahoo.com) wrote:
>: Coming to the problem, I have a perl program
Yes, but you do NOT have a perl (nor Perl) problem.
If you were using Java or Python you would be having the same problem.
>: after some executions of get($url) function, I run
>: into the problem of limited licenses
> It's hard to say without seeing the http traffic between your pc and the
> server.
This is a great tool for seeing that traffic:
Web Scraping Proxy
http://www.research.att.com/~hpk/wsp/
> One technique that a server _might_ be using would be to send a cookie to
> the browser after the first request so that on later requests the server
> knows which browser is contacting it.
> You would have to read the docs for the get($url) function you are using
> to see how to add and receive cookies to/from each request.
He might not even "have to" read the docs, as wsp.pl will write
the Perl code for him!
I love that thing for reverse-engineering my many web scraping tools...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 17 Feb 2004 23:27:07 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Why is Perl losing ground?
Message-Id: <c0u80b$p7p$1@wisteria.csv.warwick.ac.uk>
g_klinedinst@hotmail.com (G Klinedinst) wrote:
> Ben Morrow <usenet@morrow.me.uk> wrote in message news:
>
> > print !($_ % 5) || !($_ % 7) || $_;
> >
<snip>
> > I find all three of those more readable than that mess of brackets and
> > studlyCaps.
>
> Of course you do, however judging from you posts you are an expert at
^^^^^^
hardly :)
> Perl. A language which is aiming for broader acceptance also has to be
> readable and understandable to the vast majority of coders out there.
OK:
use English qw/-no_match_vars/;
print not ($ARG % 5) or not ($ARG % 7 ) or $ARG;
Yes, there is a Perlish trait of being rather functional about things:
making expressions rather than statements, e.g.
print <cond> ? $a : $b;
rather than
if (<cond>) { print $a } else { print $b }
, where possible, which I suppose is probably unfamiliar to people
coming from other (common first-) languages.
> In my opinion english and english-like names, as well as less cryptic
> symbols
At the risk of sounding more pedantic than is necessary :), do you mean
'less-cryptic symbols' or 'fewer cryptic symbols'? If the former, then
yes you could say that Perl's array of $? vars (for instance) is
cryptic, but they are actually no harder to learn than an api; if the
latter, then I would argue that replacing them with named functions
would only alleviate the initial 'what the Hell is that???' shock, and
the api would still need to be learnt.
> > > This GREAT for one-liners, etc but for anything which you have to read
> > > it later, it slows development to a crawl. Even on this newsgroup, if
> > > you try to write readable code, people tell you your variables are too
> > > long, you are using too many methods, etc.
> >
> > ..I don't think so. Examples?
> Sure, from an article you wrote:
> ----------------------------------------------------------------
> >> ltrim( $value ) - Removes leading whitespace from a string.
> >>$value =~ s/^\s*//;
> >> rtrim( $value ) - Removes trailing whitespace from a string.
> >$value =~ s/\s*$//;
> >> trim( $value ) - Combines ltrim() and rtrim().
> >$value =~ s/^\s*(.*?)\s*$/$1/;
> ----------------------------------------------------------------
> Forgive me if I'm wrong but will all of you examples it certainly
> looks like you are advocating Tore not use the functions he wrote,
Well, I'm not advocating *Tore* do one thing or the other: TMTOWTDI,
after all :).
> and instead use regexps that are common to all of perl. If you are
> only saying that these shouldn't be part of the Perl base, then I
> agree with you and please forgive me, but it looks to me like you are
> rewriting everything Tore wrote in regexps rather than function calls
> with names that make sense to him.
I was saying that such things should certainly not be core, and also
perhaps that I would never write them like that. I would also say that
my versions are more readable *to someone familiar with Perl*. A regex
like that is short enough to be comprehended as a single 'word': after
all, it's only got 4 'letter's in it (s/, ^, \s*, and //). I am
certainly would advocate, when one is writing a regex longer than that,
that it be broken into such immediately-comprehensible parts by use of
/x and interpolating variables.
> There is another example which I
> can't find of someone saying basically "after removing excessively
> long variable names here is what your code looks like...".
I have an irresitable urge to insert this quote here, from
linux/Documentation/CodingStyle. True, it's about C, but Perl has a lot
of C heritage:
| C is a Spartan language, and so should your naming be. Unlike Modula-2
| and Pascal programmers, C programmers do not use cute names like
| ThisVariableIsATemporaryCounter. A C programmer would call that
| variable "tmp", which is much easier to write, and not the least more
| difficult to understand.
Yup, arguing from authority is the last recourse of the ignorant...
> Or just wasting time trying to decide on coding guidelines in the
> first place. Yucky.
Such time is never wasted. If it is true that such things are generally
the same between one project and the next, then the job of preparing
guidelines should be a relatively trivial modification of those already
at hand. If it isn't, then at some point you'll find a situation where
the canned 'guidelines' given you by your language-of-choice don't fit.
Ben
--
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t # ben@morrow.me.uk
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.
------------------------------
Date: Wed, 18 Feb 2004 01:17:28 GMT
From: Beable van Polasm <beable+unsenet@beable.com.invalid>
Subject: Re: Why is Perl losing ground?
Message-Id: <ee8yj1ur2v.fsf@dingo.beable.com>
g_klinedinst@hotmail.com (G Klinedinst) writes:
>
> I know people will say that Perl can be object oriented, but of course
> it was an afterthought with Perl. Other languages were designed from
> the ground up to make Objects easy to work with, and not allow a mix
> of procedural and OO. As projects and applications get larger and more
> complex people want to use OOP, so they pick a language which is
> purely OO, and which implements it cleanly.
Have you tried using one of these modules: Class::Struct,
Class::MethodMaker, or Class::MakeMethods? Using one of them makes
writing OO Perl very easy, especially the last two modules (available
from CPAN). There are still a few niggly things, but who knows? Maybe
Perl6 will fix them.
--
Aren't we cutting off our undifferentiated extensions to spite our tentacles!?
-- Peter Willard
http://beable.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 V10 Issue 6150
***************************************