[32737] in Perl-Users-Digest
Perl-Users Digest, Issue: 4001 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 26 03:09:41 2013
Date: Fri, 26 Jul 2013 00:09:04 -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 Fri, 26 Jul 2013 Volume: 11 Number: 4001
Today's topics:
[OT] Content-Transfer-Encoding: vs. Usenet <oneingray@gmail.com>
Content-Transfer-Encoding: vs. Usenet <oneingray@gmail.com>
Re: Content-Transfer-Encoding: vs. Usenet <ahk@chinet.com>
Re: Content-Transfer-Encoding: vs. Usenet <ahk@chinet.com>
Re: Content-Transfer-Encoding: vs. Usenet <ahk@chinet.com>
Re: Content-Transfer-Encoding: vs. Usenet <rweikusat@mssgmbh.com>
Re: Content-Transfer-Encoding: vs. Usenet <hjp-usenet3@hjp.at>
Re: Content-Transfer-Encoding: vs. Usenet <ahk@chinet.com>
Re: Content-Transfer-Encoding: vs. Usenet <ahk@chinet.com>
Re: Content-Transfer-Encoding: vs. Usenet <ben@morrow.me.uk>
Re: Content-Transfer-Encoding: vs. Usenet <ahk@chinet.com>
No more than N element of an array (Tim McDaniel)
Re: No more than N element of an array <rweikusat@mssgmbh.com>
Re: No more than N element of an array <rweikusat@mssgmbh.com>
Re: No more than N element of an array <ben@morrow.me.uk>
Re: No more than N element of an array <derykus@gmail.com>
Re: Restart Perl Application upon KDE Restart <ahk@chinet.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 25 Jul 2013 19:30:49 +0000
From: Ivan Shmakov <oneingray@gmail.com>
Subject: [OT] Content-Transfer-Encoding: vs. Usenet
Message-Id: <87wqoeqvx2.fsf_-_@violet.siamics.net>
>>>>> Adam H Kerman <ahk@chinet.com> writes:
[...]
> If you think this discussion is off topic, why did YOU
> post a followup to it in this newsgroup?
Because it's a well-established part of the netiquette.
Yet another way to keep the subscribers of the (irrelevant)
group the conversation is being moved from is to send a separate
followup to it, announcing the followup posted [1].
Those still interested in the discussion are encouraged to
subscribe to either news:news.software.readers or
news:comp.mail.mime. (Which I will post my followups to this
thread to, if any, from now on. And sorry for the noise.)
[1] news:8761vysavb.fsf@violet.siamics.net
--
FSF associate member #7257
------------------------------
Date: Thu, 25 Jul 2013 15:19:05 +0000
From: Ivan Shmakov <oneingray@gmail.com>
Subject: Content-Transfer-Encoding: vs. Usenet
Message-Id: <87d2q6sm52.fsf_-_@violet.siamics.net>
>>>>> Adam H Kerman <ahk@chinet.com> writes:
[Cross-posting to news:news.software.readers and setting
Followup-To: there. Adding news:comp.mail.mime, on a second
though.]
[...]
> In any event, I agree with Ben and continue my boycott of MIME on
> Usenet, not that anyone cares.
Personally, I don't care about non-MIME articles, as long as
they're pure-ASCII. The only issues with forgoing MIME
completely I'm aware of are:
* pure-ASCII is simply not enough for the majority (90% or so)
of the world population; (this isn't a problem should Usenet
be though of as a kind of pure-English sect; but it isn't);
* use a non-compliant newsreader to quote MIME-compliant
messages, and havoc will ensue.
> The syntax of the CTE header, which is used to indicate a type of
> unencoded data
Is it?
> OR a mechanism of encoding, is ungrammatical to my ear.
--
FSF associate member #7257
------------------------------
Date: Thu, 25 Jul 2013 13:59:27 +0000 (UTC)
From: "Adam H. Kerman" <ahk@chinet.com>
Subject: Re: Content-Transfer-Encoding: vs. Usenet
Message-Id: <ksravv$f56$1@news.albasani.net>
Ivan Shmakov <oneingray@gmail.com> wrote:
>>>>>> Shmuel (Seymour J ) Metz <spamtrap@library.lspace.org.invalid> writes:
>>>>>> on 07/21/2013 at 05:13 PM, Ben Morrow <ben@morrow.me.uk> said:
>
> [Cross-posting to news:news.software.readers and setting
> Followup-To: there.]
>
> >>>> Content-Transfer-Encoding: 7bit
>
> >>> !
>
> >> Well, strictly speaking CTE isn't valid on Usenet,
>
> > It may not be valid for 1036, but it is certainly valid for 5536.
> > Unencoded ISO 8859-1 isn't valid for either.
>
> Nowadays, I'd assume that every other newsreader out there is
> going to either support the full range of charsets, whether
> encoded or not, or to have little to no MIME support whatsoever.
>
> Thus, the issue is rather the RFCs' failure to document the
> existing practice, and not some incompliance. (Even though
> unencoded data in general may clash with the NNTP provision that
> any non-ASCII data transferred should be in UTF-8.)
>
> But the whole point is moot, as "7bit" ISO-8859-1 is just a
> fancy name for ASCII, which is valid since well before MIME.
Here I was, innocently reading news.software.readers, when I came across
this crosspost written by a self-declared topic moderator. I don't read
this newsgroup looking for redirected flames and arguments from another
newsgroup, so this isn't appreciated.
Furthermore, coming into the middle of this snark fest, I have no idea
who said what as "Ivan Shamkov" doesn't trouble himself with the niceties
of matching quoting levels in the body of the level with quoting levels
in attribution ilnes. According to "Ivan", "Shmuel" and "Ben" both wrote
quotes at the same quoting level.
Nor is "Ivan" aware of the concept of an unindented left margin, even for
quote characters indicating quoting level.
No followup to my article would be on topic anywhere but in a revenge froup
for "Ivan", so I've directed followups to the correct newsgroup.
------------------------------
Date: Thu, 25 Jul 2013 17:40:03 +0000 (UTC)
From: "Adam H. Kerman" <ahk@chinet.com>
Subject: Re: Content-Transfer-Encoding: vs. Usenet
Message-Id: <ksrntj$hs0$1@news.albasani.net>
Ivan Shmakov <oneingray@gmail.com> wrote:
>>>>>> Adam H Kerman <ahk@chinet.com> writes:
This quote level in attribution does not match the quote level for the
quoted remarks written by me.
> [Cross-posting to news:news.software.readers and setting
> Followup-To: there. Adding news:comp.mail.mime, on a second
> though.]
Not playing followup games. If you think this discussion is off topic,
why did YOU post a followup to it in this newsgroup?
>[...]
>>In any event, I agree with Ben and continue my boycott of MIME on
>>Usenet, not that anyone cares.
> Personally, I don't care about non-MIME articles, as long as
> they're pure-ASCII. The only issues with forgoing MIME
> completely I'm aware of are:
> * pure-ASCII is simply not enough for the majority (90% or so)
> of the world population; (this isn't a problem should Usenet
> be though of as a kind of pure-English sect; but it isn't);
> * use a non-compliant newsreader to quote MIME-compliant
> messages, and havoc will ensue.
My newsreader expects me to add headers, if necessary. If I must quote
an article with non-ASCII characters, I cut them. Typically, this happens
when I encounter articles written by Google Groups users to which
non-plain-text characters have been added (like non-breaking spaces).
Not to mention, Google Groups implements MIME badly.
If I absolutely must quote the 8-bit character, I add MIME headers to
declare the character set. Otherwise my articles are pure ASCII.
>>The syntax of the CTE header, which is used to indicate a type of
>>unencoded data
> Is it?
Yes, Ivan, with a literal read, it is used to indicate unencoded data
type despite the header's name, according to RFC 2045 Section 6.2:
Content-Transfer-Encodings Semantics
. . . Three transformations are currently defined: identity,
the "quoted-printable" encoding, and the "base64" encoding.
The domains are "binary", "8bit" and "7bit".
The Content-Transfer-Encoding values "7bit", "8bit", and
"binary" all mean that the identity (i.e. NO) encoding
transformation has been performed. As such, they serve simply
as indicators of the domain of the body data, and provide
useful information about the sort of encoding that might be
needed for transmission in a given transport system. . . .
>>OR a mechanism of encoding, is ungrammatical to my ear.
------------------------------
Date: Thu, 25 Jul 2013 21:54:18 +0000 (UTC)
From: "Adam H. Kerman" <ahk@chinet.com>
Subject: Re: Content-Transfer-Encoding: vs. Usenet
Message-Id: <kss6qa$dtc$2@news.albasani.net>
Ivan Shmakov <oneingray@gmail.com> wrote:
>>>>>> Adam H Kerman <ahk@chinet.com> writes:
>>>>>> Ivan Shmakov <oneingray@gmail.com> wrote:
>>>>>> Adam H Kerman <ahk@chinet.com> writes:
Followup posted to comp.lang.perl.misc as that's where the thread is. I can't
think of anything ruder than changing newsgroups in the middle of a thread
so that the reader sees only some of the articles.
I continue to object to your attribution lines and your refusal to use
correct quoting levels so the reader can readily tell who said what.
>[...]
> >> [Cross-posting to news:news.software.readers and setting
> >> Followup-To: there. Adding news:comp.mail.mime, on a second
> >> though.]
>[...]
> > If you think this discussion is off topic, why did YOU
> ... And when Followup-To: is then ignored, is the expectation
> that two wrongs will make a right? Or is a failure of one
> poster to behave is a license to do so for everyone else?
Setting Followup-To is a suggestion, not a directive. The author of the
followup is still responsible for determining where to post.
> > post a followup to it in this newsgroup?
> Because it's a well-established part of the netiquette (which,
> IIRC, you've been pointed at before): when moving a conversation
> to another newsgroup, keep the subscribers of the former one
> informed. One simple way to do it is as follows: add the
> relevant groups to Newsgroups:, copy the result to Followup-To:,
> remove the irrelevant ones from the latter (only.)
> Yet another way is to send a separate followup to the irrelevant
> newsgroup, which is what I'm going to do for this response.
There is no well-established part of netiquette that "Ivan Shmakov" has
either the role or responsibility to act as topic censor in any unmoderated
newsgroup. Please provide a list of names of anyone who has ever asked you
to moderate an unmoderated newsgroup.
>[...]
> >> The only issues with forgoing MIME completely I'm aware of are:
> >> * pure-ASCII is simply not enough for the majority (90% or so) of
> >> the world population; (this isn't a problem should Usenet be though
> >> of as a kind of pure-English sect; but it isn't);
> >> * use a non-compliant newsreader to quote MIME-compliant messages,
> >> and havoc will ensue.
> > My newsreader expects me to add headers, if necessary. If I must
> > quote an article with non-ASCII characters, I cut them. Typically,
> > this happens when I encounter articles written by Google Groups users
> > to which non-plain-text characters have been added (like non-breaking
> > spaces).
> ... Which reminds me of the thing I've used to call the
> "American Usenet" attitude.
The A in ASCII stands for American.
It might have been useful in the 1960's to have included Chinese
characters or even to include all charactes used by languages that
use Latin characters, but coding space was extremely limited and most
characters in use by others got left out.
However, I don't see what your anti-American sentiment has to do with
what I wrote. I commented that Google Groups creates articles with
non-plain-text characters, which under no circumstances belong in
Usenet articles, no matter what language they were written in. I cut
such characters from quotes, which then allows me to post a followup in
nothing but ASCII.
I don't know why you would have a problem with that, but you're quite a
strange bird.
> Naturally, I wouldn't expect one participating in
> news:tw.bbs.soc.politics, news:pl.comp.os.linux, or
> news:alt.russian.z1 to find a non-MIME newsreader all that
> convenient.
Why not? My newsreader provides default headers for articles. All anyone
would have to do is add the necessary MIME headers to the default set.
Then I'd post in compliant MIME if I really needed to declare a character
set.
I like the flexibility. Nothing about this newsreader requires the author
to post in ASCII. The newsreader uses an outside program as text editor
in the composer anyway, so the author would simply use a text editor
appropriate for his own use.
------------------------------
Date: Thu, 25 Jul 2013 23:04:00 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: Content-Transfer-Encoding: vs. Usenet
Message-Id: <87vc3y5mb3.fsf@sapphire.mobileactivedefense.com>
"Adam H. Kerman" <ahk@chinet.com> writes:
> Ivan Shmakov <oneingray@gmail.com> wrote:
>>>>>>> Adam H Kerman <ahk@chinet.com> writes:
>>>>>>> Ivan Shmakov <oneingray@gmail.com> wrote:
>>>>>>> Adam H Kerman <ahk@chinet.com> writes:
>
> Followup posted to comp.lang.perl.misc as that's where the thread is. I can't
> think of anything ruder than changing newsgroups in the middle of a thread
> so that the reader sees only some of the articles.
The assumption that 'the reader' necessarily enjoyed the fact that he
went looking a for something Perl-related but found another instance
of this tripe instead is wrong.
------------------------------
Date: Fri, 26 Jul 2013 01:36:26 +0200
From: "Peter J. Holzer" <hjp-usenet3@hjp.at>
Subject: Re: Content-Transfer-Encoding: vs. Usenet
Message-Id: <slrnkv3djq.u8a.hjp-usenet3@hrunkner.hjp.at>
[Fup2 poster. This is off-topic here and I'm not going to try to find
out where it is on-topic]
On 2013-07-25 21:54, Adam H. Kerman <ahk@chinet.com> wrote:
> Followup posted to comp.lang.perl.misc as that's where the thread is. I can't
> think of anything ruder than changing newsgroups in the middle of a thread
> so that the reader sees only some of the articles.
I consider it very rude that you continue to try to push this thread
into a group where it is clearly off-topic.
> There is no well-established part of netiquette that "Ivan Shmakov" has
> either the role or responsibility to act as topic censor in any unmoderated
> newsgroup. Please provide a list of names of anyone who has ever asked you
> to moderate an unmoderated newsgroup.
Neither has anyone appointed you moderator of the groups you are trying
to "protect". Just stop it.
hp
--
_ | Peter J. Holzer | Fluch der elektronischen Textverarbeitung:
|_|_) | Sysadmin WSR | Man feilt solange an seinen Text um, bis
| | | hjp@hjp.at | die Satzbestandteile des Satzes nicht mehr
__/ | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel
------------------------------
Date: Fri, 26 Jul 2013 00:02:24 +0000 (UTC)
From: "Adam H. Kerman" <ahk@chinet.com>
Subject: Re: Content-Transfer-Encoding: vs. Usenet
Message-Id: <ksseaf$rh2$3@news.albasani.net>
Rainer Weikusat <rweikusat@mssgmbh.com> wrote:
>"Adam H. Kerman" <ahk@chinet.com> writes:
>>Ivan Shmakov <oneingray@gmail.com> wrote:
>>>>>>>> Adam H Kerman <ahk@chinet.com> writes:
>>>>>>>> Ivan Shmakov <oneingray@gmail.com> wrote:
>>>>>>>> Adam H Kerman <ahk@chinet.com> writes:
>>Followup posted to comp.lang.perl.misc as that's where the thread is. I can't
>>think of anything ruder than changing newsgroups in the middle of a thread
>>so that the reader sees only some of the articles.
>The assumption that 'the reader' necessarily enjoyed the fact that he
>went looking a for something Perl-related but found another instance
>of this tripe instead is wrong.
Do you know how to score a thread whose Subject is Content-Transfer-Encoding
and clearly not Perl related?
I wasn't speaking for you. I'm the reader in question. I didn't want to
see Ivan's portions of the thread in news.software.readers, and I'm not
posting followups as directed by Ivan.
------------------------------
Date: Fri, 26 Jul 2013 02:07:56 +0000 (UTC)
From: "Adam H. Kerman" <ahk@chinet.com>
Subject: Re: Content-Transfer-Encoding: vs. Usenet
Message-Id: <ksslls$f2g$1@news.albasani.net>
Peter J. Holzer <hjp-usenet3@hjp.at> wrote:
>[Fup2 poster. This is off-topic here and I'm not going to try to find
>out where it is on-topic]
>On 2013-07-25 21:54, Adam H. Kerman <ahk@chinet.com> wrote:
>>Followup posted to comp.lang.perl.misc as that's where the thread is. I can't
>>think of anything ruder than changing newsgroups in the middle of a thread
>>so that the reader sees only some of the articles.
>I consider it very rude that you continue to try to push this thread
>into a group where it is clearly off-topic.
It was topic drift here.
>>There is no well-established part of netiquette that "Ivan Shmakov" has
>>either the role or responsibility to act as topic censor in any unmoderated
>>newsgroup. Please provide a list of names of anyone who has ever asked you
>>to moderate an unmoderated newsgroup.
>Neither has anyone appointed you moderator of the groups you are trying
>to "protect". Just stop it.
I simply chose not to follow Ivan's re-direction. I get to do that.
I'm the author.
------------------------------
Date: Fri, 26 Jul 2013 04:46:52 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Content-Transfer-Encoding: vs. Usenet
Message-Id: <c289ca-e41.ln1@anubis.morrow.me.uk>
[I apologise for my part in starting this subthread...]
Quoth "Adam H. Kerman" <ahk@chinet.com>:
> Peter J. Holzer <hjp-usenet3@hjp.at> wrote:
> >On 2013-07-25 21:54, Adam H. Kerman <ahk@chinet.com> wrote:
>
> >>Followup posted to comp.lang.perl.misc as that's where the thread is. I can't
> >>think of anything ruder than changing newsgroups in the middle of a thread
> >>so that the reader sees only some of the articles.
>
> >I consider it very rude that you continue to try to push this thread
> >into a group where it is clearly off-topic.
>
> It was topic drift here.
>
> >>There is no well-established part of netiquette that "Ivan Shmakov" has
> >>either the role or responsibility to act as topic censor in any unmoderated
> >>newsgroup. Please provide a list of names of anyone who has ever asked you
> >>to moderate an unmoderated newsgroup.
>
> >Neither has anyone appointed you moderator of the groups you are trying
> >to "protect". Just stop it.
>
> I simply chose not to follow Ivan's re-direction. I get to do that.
> I'm the author.
You're a pillock. Shut up and go away.
Ben
------------------------------
Date: Fri, 26 Jul 2013 04:34:49 +0000 (UTC)
From: "Adam H. Kerman" <ahk@chinet.com>
Subject: Re: Content-Transfer-Encoding: vs. Usenet
Message-Id: <kssu99$c58$1@news.albasani.net>
Ben Morrow <ben@morrow.me.uk> wrote:
>[I apologise for my part in starting this subthread...]
[Yet you posted a followup anyway...]
------------------------------
Date: Thu, 25 Jul 2013 15:29:47 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: No more than N element of an array
Message-Id: <ksrg9b$gv9$1@reader1.panix.com>
A cow-orker is coding something: he gets an array of results, but
wants to take no more than the first 1000 elements. His suggestion was
@results = @results[0 .. (MAXSEARCHRESULTS - 1, $#results)[MAXSEARCHRESULTS - 1 > $#results ]];
He felt it was "awesome". I thought it was way too cute.
Of course there's
@results = @results[0 .. (MAXSEARCHRESULTS - 1 > $#results ? $#results : MAXSEARCHRESULTS - 1)];
It has the same number of uses of variables, just in a different order.
I considered plain @results[0 .. MAXSEARCHRESULTS]. It works if the
array is longer than the limit, but pads with undef if shorter:
$ perl -e 'use strict; use warnings; my @a = (0, 1, 2, 3, 4, 5, 6); @a = @a[0..10]; print join(",", @a), "\n"'
Use of uninitialized value $a[7] in join or string at -e line 1.
Use of uninitialized value $a[8] in join or string at -e line 1.
Use of uninitialized value $a[9] in join or string at -e line 1.
Use of uninitialized value $a[10] in join or string at -e line 1.
0,1,2,3,4,5,6,,,,
I thought of splice.
$ perl -e 'use strict; use warnings; my @a = (0, 1, 2, 3, 4, 5, 6); splice @a, 3; print join(",", @a), "\n"'
0,1,2
$ perl -e 'use strict; use warnings; my @a = (0, 1, 2, 3, 4, 5, 6); splice @a, 10; print join(",", @a), "\n"'
splice() offset past end of array at -e line 1.
0,1,2,3,4,5,6
$ perl -e 'print $], "\n"'
5.014002
But that's on my ISP. On our office machines, no warning.
$ perl -e 'use strict; use warnings; my @a = (0, 1, 2, 3, 4, 5, 6); splice @a, 3; print join(",", @a), "\n"'
0,1,2
$ perl -e 'use strict; use warnings; my @a = (0, 1, 2, 3, 4, 5, 6); splice @a, 10; print join(",", @a), "\n"'
0,1,2,3,4,5,6
$ perl -e 'print $], "\n"'
5.016002
$ perlfunc splice | cat
...
If OFFSET is past the end of the array,
Perl issues a warning, and splices at the end of the array.
...
So is splice likely to ever output such a warning again, so the 5.16
documentation is simply outdated? Or was that just an error in 5.16
and the warning now comes out in 5.18?
To protect against that,
splice @results, MAXSEARCHRESULTS if @results > MAXSEARCHRESULTS;
Doable (warning: that's untested code). But it's not as pretty.
Is there a cleaner way?
(As it happens, he now has to check the limit in an if anyway for
another purpose, so he knows that @results[0 .. MAXSEARCHRESULTS - 1]
won't go past the end, so the question is now moot. I'm still
curious.)
--
Tim McDaniel, tmcd@panix.com
------------------------------
Date: Thu, 25 Jul 2013 16:38:44 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: No more than N element of an array
Message-Id: <874nbi7ipn.fsf@sapphire.mobileactivedefense.com>
tmcd@panix.com (Tim McDaniel) writes:
> A cow-orker is coding something: he gets an array of results, but
> wants to take no more than the first 1000 elements. His suggestion was
>
> @results = @results[0 .. (MAXSEARCHRESULTS - 1, $#results)[MAXSEARCHRESULTS - 1 > $#results ]];
>
> He felt it was "awesome". I thought it was way too cute.
I suggest 'awful' instead:
$#results = MAXSEARCHRESULTS - 1 unless $#results < MAXSEARCHRESULTS;
------------------------------
Date: Thu, 25 Jul 2013 16:44:54 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: No more than N element of an array
Message-Id: <87zjta63ux.fsf@sapphire.mobileactivedefense.com>
Rainer Weikusat <rweikusat@mssgmbh.com> writes:
> tmcd@panix.com (Tim McDaniel) writes:
>> A cow-orker is coding something: he gets an array of results, but
>> wants to take no more than the first 1000 elements. His suggestion was
>>
>> @results = @results[0 .. (MAXSEARCHRESULTS - 1, $#results)[MAXSEARCHRESULTS - 1 > $#results ]];
>>
>> He felt it was "awesome". I thought it was way too cute.
>
> I suggest 'awful' instead:
>
> $#results = MAXSEARCHRESULTS - 1 unless $#results < MAXSEARCHRESULTS;
In case someone loves fancy calculations, this can also be written as
$#results -= (@results - MAXSEARCHRESULTS) * (@results > MAXSEARCHRESULTS);
:->
------------------------------
Date: Fri, 26 Jul 2013 05:12:52 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: No more than N element of an array
Message-Id: <4j99ca-t92.ln1@anubis.morrow.me.uk>
Quoth tmcd@panix.com:
> A cow-orker is coding something: he gets an array of results, but
> wants to take no more than the first 1000 elements. His suggestion was
>
> @results = @results[0 .. (MAXSEARCHRESULTS - 1,
> $#results)[MAXSEARCHRESULTS - 1 > $#results ]];
>
> He felt it was "awesome". I thought it was way too cute.
I'm not sure 'cute' is the word I'd use...
> Of course there's
> @results = @results[0 .. (MAXSEARCHRESULTS - 1 > $#results ? $#results :
> MAXSEARCHRESULTS - 1)];
> It has the same number of uses of variables, just in a different order.
>
> I considered plain @results[0 .. MAXSEARCHRESULTS]. It works if the
> array is longer than the limit, but pads with undef if shorter:
>
> $ perl -e 'use strict; use warnings; my @a = (0, 1, 2, 3, 4, 5, 6); @a =
> @a[0..10]; print join(",", @a), "\n"'
> Use of uninitialized value $a[7] in join or string at -e line 1.
> Use of uninitialized value $a[8] in join or string at -e line 1.
> Use of uninitialized value $a[9] in join or string at -e line 1.
> Use of uninitialized value $a[10] in join or string at -e line 1.
> 0,1,2,3,4,5,6,,,,
>
> I thought of splice.
>
> $ perl -e 'use strict; use warnings; my @a = (0, 1, 2, 3, 4, 5, 6);
> splice @a, 3; print join(",", @a), "\n"'
> 0,1,2
> $ perl -e 'use strict; use warnings; my @a = (0, 1, 2, 3, 4, 5, 6);
> splice @a, 10; print join(",", @a), "\n"'
> splice() offset past end of array at -e line 1.
You can kill this warning with
no warnings "misc";
> 0,1,2,3,4,5,6
> $ perl -e 'print $], "\n"'
> 5.014002
>
> But that's on my ISP. On our office machines, no warning.
>
> $ perl -e 'use strict; use warnings; my @a = (0, 1, 2, 3, 4, 5, 6);
> splice @a, 3; print join(",", @a), "\n"'
> 0,1,2
> $ perl -e 'use strict; use warnings; my @a = (0, 1, 2, 3, 4, 5, 6);
> splice @a, 10; print join(",", @a), "\n"'
> 0,1,2,3,4,5,6
> $ perl -e 'print $], "\n"'
> 5.016002
> $ perlfunc splice | cat
> ...
> If OFFSET is past the end of the array,
> Perl issues a warning, and splices at the end of the array.
> ...
> So is splice likely to ever output such a warning again, so the 5.16
> documentation is simply outdated? Or was that just an error in 5.16
> and the warning now comes out in 5.18?
The behaviour changed in 5.16. In 5.14 and before, both these cases
warned:
splice @a, 10, 3;
splice @a, 10;
but for 5.16 it was decided that the second was actually entirely
unambiguous, so only the first case warns.
> To protect against that,
> splice @results, MAXSEARCHRESULTS if @results > MAXSEARCHRESULTS;
> Doable (warning: that's untested code). But it's not as pretty.
>
> Is there a cleaner way?
Perhaps
@results = splice @results, 0, MAXSEARCHRESULTS;
Ben
------------------------------
Date: Thu, 25 Jul 2013 23:08:46 -0700
From: Charles DeRykus <derykus@gmail.com>
Subject: Re: No more than N element of an array
Message-Id: <kst3q6$91q$1@speranza.aioe.org>
On 7/25/2013 9:12 PM, Ben Morrow wrote:
>
> Quoth tmcd@panix.com:
>> A cow-orker is coding something: he gets an array of results, but
>> wants to take no more than the first 1000 elements. His suggestion was
>>
>> @results = @results[0 .. (MAXSEARCHRESULTS - 1,
>> $#results)[MAXSEARCHRESULTS - 1 > $#results ]];
>>
>> ...
>> $ perl -e 'use strict; use warnings; my @a = (0, 1, 2, 3, 4, 5, 6);
>> splice @a, 3; print join(",", @a), "\n"'
>> 0,1,2
>> $ perl -e 'use strict; use warnings; my @a = (0, 1, 2, 3, 4, 5, 6);
>> splice @a, 10; print join(",", @a), "\n"'
>it's not as pretty.
>> ...
>> Is there a cleaner way?
>
> Perhaps
>
> @results = splice @results, 0, MAXSEARCHRESULTS;
>
If fewer strokes were to factor into cleanliness, even:
@results = @results[0..MAXSEARCHRESULTS];
But, as you grow array size and MAXSEARCHRESULTS, it gets filthy slow...
Setting $#results = MAXSEARCHRESULTS undoubtedly comes out of the wash
purest and fastest.
--
Charles DeRykus
------------------------------
Date: Thu, 25 Jul 2013 15:00:27 +0000 (UTC)
From: "Adam H. Kerman" <ahk@chinet.com>
Subject: Re: Restart Perl Application upon KDE Restart
Message-Id: <ksreib$liq$4@news.albasani.net>
Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid> wrote:
>on 07/21/2013 at 05:13 PM, Ben Morrow <ben@morrow.me.uk> said:
>>Well, strictly speaking CTE isn't valid on Usenet,
>It may not be valid for 1036, but it is certainly valid for 5536.
>Unencoded ISO 8859-1 isn't valid for either.
The mechanism indicated in the Content-Transfer-Encoding header of 7bit
or 8bit is used with unencoded data, whereas quoted-printable or base64
is used with data encoded in the named mechanism. I have no idea why you
believe an author couldn't post an article to Usenet, the body of which
consists of unencoded Latin-1 characters, without violating syntax.
In any event, I agree with Ben and continue my boycott of MIME on
Usenet, not that anyone cares. The syntax of the CTE header, which is
used to indicate a type of unencoded data OR a mechanism of encoding,
is ungrammatical to my ear.
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 4001
***************************************