[29774] in Perl-Users-Digest
Perl-Users Digest, Issue: 1017 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 9 03:09:40 2007
Date: Fri, 9 Nov 2007 00:09:06 -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 Fri, 9 Nov 2007 Volume: 11 Number: 1017
Today's topics:
Re: cookie dbi based authentication <mark.clementsREMOVETHIS@wanadoo.fr>
new CPAN modules on Fri Nov 9 2007 (Randal Schwartz)
Re: Newbie doesn't quite understand pointers with hashe <keeresarge@nowhere.com>
Re: Newbie doesn't quite understand pointers with hashe <tadmc@seesig.invalid>
Re: Set TCP_MAXSEG (OS buffering) on Win32? How? <ed@notarealemailaccount.com>
Re: Set TCP_MAXSEG (OS buffering) on Win32? How? <ed@notarealemailaccount.com>
Re: Sun and moon data program Nov. 8, 2007 <tadmc@seesig.invalid>
Re: Sun and moon data program Nov. 8, 2007 <Klazmon@llurdiaxorb.govt>
Why can't you slice an array @a[3..-1]? <clint.olsen@gmail.com>
Re: Why can't you slice an array @a[3..-1]? <bik.mido@tiscalinet.it>
Re: Why can't you slice an array @a[3..-1]? <clint.olsen@gmail.com>
Re: Why can't you slice an array @a[3..-1]? <nospam-abuse@ilyaz.org>
Re: Why can't you slice an array @a[3..-1]? <clint.olsen@gmail.com>
Re: Why can't you slice an array @a[3..-1]? <mritty@gmail.com>
Re: Why can't you slice an array @a[3..-1]? <tadmc@seesig.invalid>
Re: Why can't you slice an array @a[3..-1]? <mgjv@tradingpost.com.au>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 09 Nov 2007 07:31:10 +0100
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: cookie dbi based authentication
Message-Id: <4733feb6$0$27387$ba4acef3@news.orange.fr>
A. Sinan Unur wrote:
> joe <jcharth@gmail.com> wrote in news:1194558983.064362.108310
> @z24g2000prh.googlegroups.com:
>
>> Hello I am currently using dbi authentication on my apache server to
>> query a table in my sql server for user/password information. Is there
>> a way to convert this authentication to cookie based authentication or
>> change the look and feel of the username/password window? thanks.
>
> I am sure we would all love to know how this is a topical question for this
> group.
>
He has mentioned DBI, so presumably Perl is used somewhere along the
line. It takes a considerable amount of experience to judge where all
the demarcation lines between different components of a system are. It
isn't particulary helpful being snide when someone asking for help
misdetermines which group to which to post a question.
To the OP: this is more of an Apache configuration question than
anything else and thus should be asked in an appriopriate group, but
take a look at
http://www.modperl.com/book/chapters/ch6.html
Mark
------------------------------
Date: Fri, 9 Nov 2007 05:42:20 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Fri Nov 9 2007
Message-Id: <Jr856K.1MzM@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.
Acme-6502-0.71
http://search.cpan.org/~andya/Acme-6502-0.71/
Pure Perl 65C02 simulator.
----
Acme-ProgressBar-1.124
http://search.cpan.org/~rjbs/Acme-ProgressBar-1.124/
a simple progress bar for the patient
----
Amce-CNA-0.064
http://search.cpan.org/~rjbs/Amce-CNA-0.064/
a moer tolernat verison of mehtod location
----
App-vget-0.01
http://search.cpan.org/~marcel/App-vget-0.01/
Marker package for vget
----
Business-OnlinePayment-viaKLIX-0.02
http://search.cpan.org/~jef/Business-OnlinePayment-viaKLIX-0.02/
viaKLIX backend for Business::OnlinePayment
----
CPAN-Mini-0.565
http://search.cpan.org/~rjbs/CPAN-Mini-0.565/
create a minimal mirror of CPAN
----
CPANPLUS-Dist-Mdv-0.3.0
http://search.cpan.org/~jquelin/CPANPLUS-Dist-Mdv-0.3.0/
a cpanplus backend to build mandriva rpms
----
Catalyst-Plugin-Acme-LOLCAT-0.01
http://search.cpan.org/~ashley/Catalyst-Plugin-Acme-LOLCAT-0.01/
IM IN UR CATALYST APPLECASHUN REWRITINS YUR OUTPUTS.
----
Config-XPath-0.12
http://search.cpan.org/~pevans/Config-XPath-0.12/
a module for retrieving configuration data from XML files by using XPath queries
----
Data-KeyDiff-0.010_1
http://search.cpan.org/~rkrimen/Data-KeyDiff-0.010_1/
Diff one set/list against another with a key basis
----
Data-KeyDiff-0.010_2
http://search.cpan.org/~rkrimen/Data-KeyDiff-0.010_2/
Diff one set/list against another with a key basis
----
Data-Throttler-Memcached-0.00003
http://search.cpan.org/~dmaki/Data-Throttler-Memcached-0.00003/
Memcached-Based Data::Throttler
----
DateTime-TimeZone-0.6903
http://search.cpan.org/~drolsky/DateTime-TimeZone-0.6903/
Time zone object base class and factory
----
Devel-TraceLoad-1.0.1
http://search.cpan.org/~andya/Devel-TraceLoad-1.0.1/
Discover which modules a Perl program loads.
----
EV-0.6
http://search.cpan.org/~mlehmann/EV-0.6/
perl interface to libev, a high performance full-featured event loop
----
Encode-HanExtra-0.22
http://search.cpan.org/~audreyt/Encode-HanExtra-0.22/
Extra sets of Chinese encodings
----
Formatter-HTML-MPS-0.3
http://search.cpan.org/~vetler/Formatter-HTML-MPS-0.3/
----
Getopt-Attribute-1.44
http://search.cpan.org/~marcel/Getopt-Attribute-1.44/
Attribute wrapper for Getopt::Long
----
Gungho-0.09002
http://search.cpan.org/~dmaki/Gungho-0.09002/
Yet Another High Performance Web Crawler Framework
----
Gungho-0.09003_01
http://search.cpan.org/~dmaki/Gungho-0.09003_01/
Yet Another High Performance Web Crawler Framework
----
Gungho-0.09003_02
http://search.cpan.org/~dmaki/Gungho-0.09003_02/
Yet Another High Performance Web Crawler Framework
----
Image-IPTCInfo-1.95
http://search.cpan.org/~jcarter/Image-IPTCInfo-1.95/
Perl extension for extracting IPTC image meta-data
----
LEOCHARRE-Class-1.12
http://search.cpan.org/~leocharre/LEOCHARRE-Class-1.12/
----
Lemonldap-Config-Parameters-3.2.2
http://search.cpan.org/~egerman/Lemonldap-Config-Parameters-3.2.2/
Backend of configuration for lemonldap SSO system
----
Lemonldap-Handlers-Generic-3.5.3
http://search.cpan.org/~egerman/Lemonldap-Handlers-Generic-3.5.3/
Perl extension for Lemonldap sso system
----
Log-Dispatch-File-Alerts-1.01
http://search.cpan.org/~jacob/Log-Dispatch-File-Alerts-1.01/
Object for logging to alert files
----
Log-Dispatch-File-Rolling-1.05
http://search.cpan.org/~jacob/Log-Dispatch-File-Rolling-1.05/
Object for logging to date/time/pid stamped files
----
Mail-DKIM-0.29
http://search.cpan.org/~jaslong/Mail-DKIM-0.29/
Signs/verifies Internet mail with DKIM/DomainKey signatures
----
Mail-DKIM-0.29_2
http://search.cpan.org/~jaslong/Mail-DKIM-0.29_2/
Signs/verifies Internet mail with DKIM/DomainKey signatures
----
Module-Changes-0.01
http://search.cpan.org/~marcel/Module-Changes-0.01/
Machine-readable Changes file
----
Module-Changes-0.02
http://search.cpan.org/~marcel/Module-Changes-0.02/
Machine-readable Changes file
----
Net-BGP-0.09
http://search.cpan.org/~kbrint/Net-BGP-0.09/
Border Gateway Protocol version 4 speaker/listener library
----
Net-Kotonoha-0.01a
http://search.cpan.org/~mattn/Net-Kotonoha-0.01a/
A perl interface to kotonoha.cc
----
Object-InsideOut-3.31
http://search.cpan.org/~jdhedden/Object-InsideOut-3.31/
Comprehensive inside-out object support module
----
Object-InsideOut-3.32
http://search.cpan.org/~jdhedden/Object-InsideOut-3.32/
Comprehensive inside-out object support module
----
Parse-Eyapp-1.084
http://search.cpan.org/~casiano/Parse-Eyapp-1.084/
Extensions for Parse::Yapp
----
Parse-Marpa-0.001_037
http://search.cpan.org/~jkegl/Parse-Marpa-0.001_037/
Jay Earley's general parsing algorithm with LR(0) precomputation
----
Parse-RecDescent-FAQ-6.0.a
http://search.cpan.org/~tbone/Parse-RecDescent-FAQ-6.0.a/
the official, authorized FAQ for Parse::RecDescent.
----
Perl-Version-1.003
http://search.cpan.org/~andya/Perl-Version-1.003/
Parse and manipulate Perl version strings
----
Perl-Version-1.004
http://search.cpan.org/~andya/Perl-Version-1.004/
Parse and manipulate Perl version strings
----
Pod-Help-1.00
http://search.cpan.org/~jacob/Pod-Help-1.00/
Perl module to automate POD display
----
SOAP-Lite-0.70_02
http://search.cpan.org/~mkutter/SOAP-Lite-0.70_02/
Perl's Web Services Toolkit
----
Sepia-0.94_01
http://search.cpan.org/~seano/Sepia-0.94_01/
Simple Emacs-Perl Interface
----
ShipIt-Step-CheckYAMLChangeLog-0.01
http://search.cpan.org/~marcel/ShipIt-Step-CheckYAMLChangeLog-0.01/
ShipIt step for YAML Changes files
----
Subtitles-1.00
http://search.cpan.org/~karasik/Subtitles-1.00/
fix timing for subtitles in various text formats
----
Sysadm-Install-0.24
http://search.cpan.org/~mschilli/Sysadm-Install-0.24/
Typical installation tasks for system administrators
----
SystemC-Vregs-1.441
http://search.cpan.org/~wsnyder/SystemC-Vregs-1.441/
Utility routines used by vregs
----
Tk-Tree-4.73
http://search.cpan.org/~srezic/Tk-Tree-4.73/
Create and manipulate Tree widgets
----
WWW-UsePerl-Journal-0.21
http://search.cpan.org/~barbie/WWW-UsePerl-Journal-0.21/
A use.perl.org journal tool
----
WWW-UsePerl-Journal-Thread-0.10
http://search.cpan.org/~barbie/WWW-UsePerl-Journal-Thread-0.10/
Handles the retrieval of UsePerl journal comment threads.
----
Win32-WebBrowser-1.02
http://search.cpan.org/~darnold/Win32-WebBrowser-1.02/
open the default web browser on Win32
----
X11-GUITest-record-0.11
http://search.cpan.org/~mkoderer/X11-GUITest-record-0.11/
Perl implementation of the X11 record extension.
----
X11-GUITest-record-0.12
http://search.cpan.org/~mkoderer/X11-GUITest-record-0.12/
Perl implementation of the X11 record extension.
----
XML-Compile-0.59
http://search.cpan.org/~markov/XML-Compile-0.59/
Compilation based XML processing
----
ack-1.72
http://search.cpan.org/~petdance/ack-1.72/
grep-like text finder
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: Thu, 08 Nov 2007 23:34:20 -0000
From: keersarge <keeresarge@nowhere.com>
Subject: Re: Newbie doesn't quite understand pointers with hashes.
Message-Id: <13j777sdrcp95d0@corp.supernews.com>
On Thu, 08 Nov 2007 17:06:47 -0600, J. Gleixner wrote:
> keersarge wrote:
> [...]
>> As I said, my usually useful books either discourage forms in templates or
>
> I find that hard to believe.
>
From the FAQ from the guy who wrote HTML::Template
...It is certainly possible to produce a <select> element entirely inside
the template. What you end up with is a rat's nest of loops and
conditionals...
From the CGI Programming book
...The Form method can be used within a template, but this leads to some
coding that is less than elegant, to say the least... ...Rather than
trying to shoehorn form methods inside of templates, you should probably
try to use JavaScript for...
> A form element is nothing special and outside of some mark-up
> elements/syntax a template is nothing special either, it doesn't
> have to relate to HTML at all.
At my level of knowledge of Templating, all I could go by is the published
info. I am glad to hear a different opinion from you as well as another. I
will now go back and try the templates again.
>
> Why should a book about learning a language discuss templates?
They don't. I wasn't talking about Learning Perl and Perl Cookbooks
and so forth. My fault, I didn't specify.
>
> Does it discuss using Class::DBI, Catalyst, and XML::Simple?
>
Yep, but I am trying to learn Perl fast and well, with short side trips to
CGI, so add-on stuff, however neat and interesting, will have to wait a
while. Unless some rich uncle leaves me enough to spend full time on this.
Thanks
keersarge
------------------------------
Date: Fri, 09 Nov 2007 00:12:03 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Newbie doesn't quite understand pointers with hashes.
Message-Id: <slrnfj792k.stg.tadmc@tadmc30.sbcglobal.net>
Keersarge <keersarge@nowhere.com> wrote:
> I have a long string in some file somewhere that has what looks like a
> reference to a hash element in it. Like so...
>
> asfp poip wwdudjh skkienb $submithash(somekey) llsigj kosoone
That does not have what looks like a reference to a hash element in it...
This has what looks like a hash access in it:
asfp poip wwdudjh skkienb $submithash{somekey} llsigj kosoone
> By coincidence I also have a program that has a hash by that same name
> i.e. %submithash and it has that same key somewhere in it, say,
> $submithash(somekey)= 5986
Please do not attempt pseudocode when Real Code is so easy to show instead.
---------------------------------
#!/usr/bin/perl
use warnings;
use strict;
my %submithash = ( somekey => 5986 );
$_ = 'asfp poip wwdudjh skkienb $submithash{somekey} llsigj kosoone';
s/\$submithash{somekey}/$submithash{somekey}/g;
print "$_\n";
---------------------------------
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Thu, 08 Nov 2007 23:41:44 +0000
From: Ed W <ed@notarealemailaccount.com>
Subject: Re: Set TCP_MAXSEG (OS buffering) on Win32? How?
Message-Id: <zdWdnSSIM49eA67aRVnyuAA@pipex.net>
> TCP segment size has _nothing at all_ to do with stream buffer sizes,
> those are two limits that apply to different layers of a tcp
> communication.
Actually on Win32 it appears that MSS controls the advertised receive
window. Forget the reference now, but some googling will turn it up I
think?
> TCP_MAXSEG controls how big a tcp packet can be before it gets split
> into consecutive segments.
Err? Really? I don't think it is actually? I think it's the MSS window?
Trying to toy with that from within an
> application is dangerous and may lead to problems that are very
> hard to track down. The task of determining efficient segment
> sizes is best left to the communication stack itself.
This is all over localhost!! The problem is that the operating system
is trying to open up the window to be efficient and I need to close it
down because I'm buffering to talk over a pipe which speaks 20KB per
minute!! The standard window is about a 4 *minute* buffer and this
causes problems with the apps we are trying to proxy for.
It's a specialist case for sure...
> The send/receive buffering happens at a higher level. In the case of
> a send buffer, it simply contains the raw data that is to be broken
> into tcp segments and sent over the wire. In the case of a receive
> buffer, it contains the raw data _assembled_ from one or more
> consecutive tcp segments.
I'm pretty sure that you are confusing SO_SNDBUF and SO_RCVBUF, plus the
packet size, with the receive window which is tracking the amount of
data in flight. I want to clamp down the send/receive window only - the
size of each packet is not a priority
> I can't rule out for sure that there is a (recommendable) mechanism to
> change SO_SNDBUF individually for a foreign application's socket on
> Win32,
Apparently it's to change TCP_MAXSEG, which in turn changes the
advertised receive window which affects the send window on the transmit end.
So full circle - why am I getting an error trying to set TCP_MAXSEG?
> I'm wondering what problem you are trying to solve that appears as
> "Currently the OS is buffering too much data".
I am writing a network app on a network which transmits at slightly less
then 20KB per min. This requires quite a bit of control over the data
being sent, packet size and buffer sizes. Most of this is inhand, the
problem I am having is controlling the advertised receive window on new
connections - if there is a better way to set this via perl then I am
looking for a solution - right now I believe that on win32 at least that
the TCP_MAXSEG is the setting which controls this? Problem I am having
is that current ActiveState is reporting that it's "not implemented" -
is there a workaround or some other solution?
Your question,
> however, has nothing to do with Perl
?? My app is written in perl and it's unable to set standard TCP socket
settings?! How is this NOT a perl question?
I guess I could fix this if I drop into some XS and run some direct
calls over the socket, but I am keen to get this sorted with minimum
extra modules.
Grateful for any thoughts?
Ed W
P.S. Update see http://support.microsoft.com/kb/224829/EN-US/ for a
confirmation that advertised MSS controls the transmit window under
win32 - just need to find out how to change it per connection without
screwing down the whole machine for this single application...
------------------------------
Date: Thu, 08 Nov 2007 23:53:08 +0000
From: Ed W <ed@notarealemailaccount.com>
Subject: Re: Set TCP_MAXSEG (OS buffering) on Win32? How?
Message-Id: <DaWdnciONMDtPK7anZ2dnUVZ8tWvnZ2d@pipex.net>
Bah, bother
I can't find a bunch of articles now which suggest that TCP_MAXSEG is a
roundabout route to accidently controlling the advertised receive
window. However, I am sure I have seen something about this
The goal anyway is to control the advertised receive window in the hope
that this will indirectly affect the actual transmit window at the
remote end (this is all on localhost so it's quite controllable).
Some tests here suggest that SO_RCVBUF actually controls the transmit
buffer to some extent on Vista, but on XP it's not happening...
Any other suggestions? I don't control the sending app and I need to
throttle it back to around <20KB per min and right now the OS buffers
are allowing it to send WAAAAY more data than is reasonable...
Cheers
Ed W
------------------------------
Date: Fri, 09 Nov 2007 00:12:03 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Sun and moon data program Nov. 8, 2007
Message-Id: <slrnfj78n3.stg.tadmc@tadmc30.sbcglobal.net>
["Followup-To:" header set to comp.lang.perl.misc.]
E.D.G. <edgrsprj@ix.netcom.com> wrote:
> A freeware sun and moon location data generation computer program is needed
> for use with an earthquake related computer program. Perl would be the
> preferred language.
>
> Information regarding where such a program can be obtained would be
> appreciated.
You can accomplish your goal via a two-step process:
step 1) learn Perl
step 2) write a sun and moon location data generation Perl program
> Perl is a programming language somewhat similar to Basic.
It appears that you have not yet started on step 1...
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: 9 Nov 2007 16:08:12 +1300
From: Llanzlan Klazmon the 15th <Klazmon@llurdiaxorb.govt>
Subject: Re: Sun and moon data program Nov. 8, 2007
Message-Id: <Xns99E3A4267BF4Klazmonllurdiaxorbgo@203.97.37.6>
"E.D.G." <edgrsprj@ix.netcom.com> wrote in
news:13j6kh9prckmn13@corp.supernews.com:
> Topic 1 Sun And Moon Data Program Needed
> Topic 2 Perl - Gnuplot Interface
>
I suggest you consult the book "Astronomical Algorithms" by Jean Meeus.
http://www.willbell.com/math/mc1.htm
Klazmon.
------------------------------
Date: Thu, 08 Nov 2007 17:25:48 -0600
From: Clint Olsen <clint.olsen@gmail.com>
Subject: Why can't you slice an array @a[3..-1]?
Message-Id: <slrnfj76ns.1499.clint.olsen@belle.0lsen.net>
I've never figured out why this intuitive syntax does not work. It should,
because doing $# inside the subscripts is really awkward, and I don't see
any ambguity here. Either that you have to use @a[3 .. scalar(@a) - 1 ].
Is there an easier way to do this?
Thanks,
-Clint
------------------------------
Date: Fri, 09 Nov 2007 00:36:05 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Why can't you slice an array @a[3..-1]?
Message-Id: <p677j3t8ls59mnr20cr8m2t6m4snsedcg9@4ax.com>
On Thu, 08 Nov 2007 17:25:48 -0600, Clint Olsen
<clint.olsen@gmail.com> wrote:
>I've never figured out why this intuitive syntax does not work. It should,
>because doing $# inside the subscripts is really awkward, and I don't see
>any ambguity here. Either that you have to use @a[3 .. scalar(@a) - 1 ].
>
>Is there an easier way to do this?
Basically, no. But you don't need the explicit scalar():
@a[3 .. (@a - 1)]
would do. But since we're talking about an index, $#a would be even
better:
@a[3 .. $#a]
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Thu, 08 Nov 2007 19:15:43 -0600
From: Clint Olsen <clint.olsen@gmail.com>
Subject: Re: Why can't you slice an array @a[3..-1]?
Message-Id: <slrnfj7d5v.1499.clint.olsen@belle.0lsen.net>
On 2007-11-08, Michele Dondi <bik.mido@tiscalinet.it> wrote:
> Basically, no. But you don't need the explicit scalar():
>
> @a[3 .. (@a - 1)]
>
> would do. But since we're talking about an index, $#a would be even
> better:
>
> @a[3 .. $#a]
This doesn't work for array references. How can I perform the same ($#) on
an array reference?
I got this when trying to:
DB<10> x $#{@$_}
Bizarre copy of ARRAY in leave at (eval
76)[/nfs/pdx/disks/pdx_otools/lib/perl5/5.8.5/perl5db.pl:620] line 2.
And $_ is an array reference.
-Clint
------------------------------
Date: Fri, 9 Nov 2007 01:23:09 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Why can't you slice an array @a[3..-1]?
Message-Id: <fh0cpt$1u7t$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Clint Olsen
<clint.olsen@gmail.com>], who wrote in article <slrnfj76ns.1499.clint.olsen@belle.0lsen.net>:
> I've never figured out why this intuitive syntax does not work. It should,
> because doing $# inside the subscripts is really awkward, and I don't see
> any ambguity here.
Me too. 3..-1 INAMBIGUOUSLY returns an empty list.
Hope this helps,
Ilya
------------------------------
Date: Thu, 08 Nov 2007 19:34:05 -0600
From: Clint Olsen <clint.olsen@gmail.com>
Subject: Re: Why can't you slice an array @a[3..-1]?
Message-Id: <slrnfj7e8d.1499.clint.olsen@belle.0lsen.net>
On 2007-11-08, Clint Olsen <clint.olsen@gmail.com> wrote:
> I've never figured out why this intuitive syntax does not work. It should,
> because doing $# inside the subscripts is really awkward, and I don't see
> any ambguity here. Either that you have to use @a[3 .. scalar(@a) - 1 ].
I think I figured out why this doesn't work the way I expected. Since the
'..' operator creates a list (series) from the left value to the right, it
doesn't make sense to do this from a valid index to -1.
And I also through experimentation figured out why the array reference
doesn't work. The syntax appears to be:
$#$_
Where $_ is an array reference. I can't explain why this works however
based on my knowledge of perl and references...
-Clint
------------------------------
Date: Thu, 08 Nov 2007 17:46:28 -0800
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Why can't you slice an array @a[3..-1]?
Message-Id: <1194572788.622317.102190@s15g2000prm.googlegroups.com>
On Nov 8, 8:34 pm, Clint Olsen <clint.ol...@gmail.com> wrote:
> And I also through experimentation figured out why the array
> reference doesn't work. The syntax appears to be:
>
> $#$_
>
> Where $_ is an array reference. I can't explain why this works
> however based on my knowledge of perl and references...
The rule is that you take the reference, and treat the reference as
the "name" of the array. Then every other operation is exactly the
same as it is for a normal array.
Normal array:
@foo - "name" of array is foo.
Normal array element:
$foo[0]
Normal array slice:
@foo[0..5];
Normal array last index:
$#foo
Array reference:
$ref - "name" of array is $ref.
Array reference element:
$$ref[0]
Array reference slice:
@$ref[0..5]
Array reference last index:
$#$ref
Paul Lalli
------------------------------
Date: Thu, 8 Nov 2007 21:42:56 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Why can't you slice an array @a[3..-1]?
Message-Id: <slrnfj7lq0.utf.tadmc@tadmc30.sbcglobal.net>
Clint Olsen <clint.olsen@gmail.com> wrote:
> The syntax appears to be:
>
> $#$_
>
> Where $_ is an array reference. I can't explain why this works however
> based on my knowledge of perl and references...
Simply apply "Use Rule 1" from perlreftut.pod.
I like to do it in 3 steps:
1) $#a # pretend it is a normal array
2) $#{ } # replace the name with a block
3) $#{ $_ } # fillin the block with something that returns
# the appropriate type of reference (array in this case)
If what is in the block is a simple, standalone scalar, then you
are allowed to leave out the curly braces:
$#$_
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Fri, 9 Nov 2007 18:11:55 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Why can't you slice an array @a[3..-1]?
Message-Id: <slrnfj821r.1nl.mgjv@martien.heliotrope.home>
On Thu, 08 Nov 2007 19:15:43 -0600,
Clint Olsen <clint.olsen@gmail.com> wrote:
> On 2007-11-08, Michele Dondi <bik.mido@tiscalinet.it> wrote:
>> Basically, no. But you don't need the explicit scalar():
>>
>> @a[3 .. (@a - 1)]
>>
>> would do. But since we're talking about an index, $#a would be even
>> better:
>>
>> @a[3 .. $#a]
>
> This doesn't work for array references. How can I perform the same ($#) on
> an array reference?
my $ra = \@a;
my $last_index = $#$ra;
Martien
--
|
Martien Verbruggen | I think there is a world market for maybe
| five computers. -- Thomas Watson, chairman of
| IBM, 1943
------------------------------
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 1017
***************************************