Re: [Boston.pm] $#{$Queue}

2010-09-29 Thread David Cantrell
On Tue, Sep 28, 2010 at 07:07:38PM -0400, Greg London wrote: Ive used $arr[-2] to get the second to last element of an array. But anyone using $[ to change the first index of an array to be negative should be beaten severely. No, anyone using $[ at all should be beaten severely :-)

Re: [Boston.pm] $#{$Queue}

2010-09-29 Thread David Cantrell
On Tue, Sep 28, 2010 at 10:23:27PM -0400, Gyepi SAM wrote: I think '$[' would more useful if it could be scoped to individual arrays. It shouldn't be difficult to knock up a Tie::Whatever module to simulate that. Though it does seem to be of dubious utility to begin with. It's only in the

Re: [Boston.pm] $#{$Queue}

2010-09-29 Thread Uri Guttman
DC == David Cantrell da...@cantrell.org.uk writes: DC On Mon, Sep 27, 2010 at 11:15:17PM -0400, Uri Guttman wrote: actually the = part is even more amusing. look here: perl -le '$#foo = -2 ; print $#foo' -1 you can't set the last index to -1. which makes sense. which makes the

Re: [Boston.pm] $#{$Queue}

2010-09-29 Thread rogers-pm5
From: Uri Guttman u...@stemsystems.com Date: Wed, 29 Sep 2010 15:14:37 -0400 DC == David Cantrell da...@cantrell.org.uk writes: DC On Mon, Sep 27, 2010 at 11:15:17PM -0400, Uri Guttman wrote: you can't set the last index to -1. which makes sense. which makes the

Re: [Boston.pm] $#{$Queue}

2010-09-29 Thread Uri Guttman
r == rogers-pm5 rogers-...@rgrjr.dyndns.org writes: r I have used languages (PL/1 and Pascal come to mind) that allow you to r declare both upper and lower bounds to each array dimension. But for r both languages, I have found such arrays more trouble than they are r worth. A Pascal

Re: [Boston.pm] $#{$Queue}

2010-09-28 Thread David Cantrell
On Mon, Sep 27, 2010 at 11:15:17PM -0400, Uri Guttman wrote: actually the = part is even more amusing. look here: perl -le '$#foo = -2 ; print $#foo' -1 you can't set the last index to -1. which makes sense. which makes the original code even dumber. $ perl -le '$[=-1; print $#foo' -2

Re: [Boston.pm] $#{$Queue}

2010-09-28 Thread Greg London
the awards. -Original message- From: David Cantrell da...@cantrell.org.uk To: boston-pm@mail.pm.org Sent: Tue, Sep 28, 2010 11:50:27 GMT+00:00 Subject: Re: [Boston.pm] $#{$Queue} On Mon, Sep 27, 2010 at 11:15:17PM -0400, Uri Guttman wrote: actually the = part is even more amusing. look

Re: [Boston.pm] $#{$Queue}

2010-09-28 Thread David Cantrell
Greg London wrote: From: David Cantrell da...@cantrell.org.uk On Mon, Sep 27, 2010 at 11:15:17PM -0400, Uri Guttman wrote: actually the = part is even more amusing. look here: perl -le '$#foo = -2 ; print $#foo' -1 you can't set the last index to -1. which makes sense. which makes the

Re: [Boston.pm] $#{$Queue}

2010-09-28 Thread Gyepi SAM
On Tue, Sep 28, 2010 at 07:07:38PM -0400, Greg London wrote: Ive used $arr[-2] to get the second to last element of an array. But anyone using $[ to change the first index of an array to be negative should be beaten severely. I had initially thought this too; though I imagined something worse

Re: [Boston.pm] $#{$Queue}

2010-09-28 Thread rogers-pm5
From: Gyepi SAM gy...@praxis-sw.com Date: Tue, 28 Sep 2010 22:23:27 -0400 . . . I think '$[' would more useful if it could be scoped to individual arrays. I have used languages (PL/1 and Pascal come to mind) that allow you to declare both upper and lower bounds to each array

Re: [Boston.pm] $#{$Queue}

2010-09-28 Thread Nick Patch
On Tue, Sep 28, 2010 at 11:11 PM, rogers-...@rgrjr.dyndns.org wrote: I have used languages (PL/1 and Pascal come to mind) that allow you to declare both upper and lower bounds to each array dimension.  But for both languages, I have found such arrays more trouble than they are worth.  A

Re: [Boston.pm] $#{$Queue}

2010-09-28 Thread tkohl
User-defined array indexing is included in Perl 6: my Int @array{1970..1984}; Huh??? An explicit type declaration in Perl?? Who ordered this? No more scalar = catch all type? -T ___ Boston-pm mailing list Boston-pm@mail.pm.org

Re: [Boston.pm] $#{$Queue}

2010-09-28 Thread Nick Patch
On Wed, Sep 29, 2010 at 12:37 AM, tk...@bu.edu wrote: An explicit type declaration in Perl?? Who ordered this? No more scalar = catch all type? No worries, you can just continue using untyped scalars as you always have! my $scalar; But you can also declare types and array sizes if you

[Boston.pm] $#{$Queue}

2010-09-27 Thread Greg London
what the heck? my $Queue = \...@somearray; if ($#{$Queue} = -1){ # do something } I thought $# was size, but the code is checking for it to be minus one? -- ___ Boston-pm mailing list Boston-pm@mail.pm.org

Re: [Boston.pm] $#{$Queue}

2010-09-27 Thread Ben Tilly
Check perlvar. It is the index of the last array element, which is one less than the size. @$Queue will give you the size in scalar context. On Mon, Sep 27, 2010 at 5:28 PM, Greg London em...@greglondon.com wrote: what the heck? my $Queue = \...@somearray; if ($#{$Queue} = -1){  # do

Re: [Boston.pm] $#{$Queue}

2010-09-27 Thread Greg London
...@greglondon.com Cc: boston-pm@mail.pm.org Sent: Tue, Sep 28, 2010 00:29:52 GMT+00:00 Subject: Re: [Boston.pm] $#{$Queue} Check perlvar. It is the index of the last array element, which is one less than the size. @$Queue will give you the size in scalar context. On Mon, Sep 27, 2010 at 5:28 PM

Re: [Boston.pm] $#{$Queue}

2010-09-27 Thread Uri Guttman
GL == Greg London Greg writes: GL Oh god. I'm digging through what might be on the order of.a GL hundred thousand lines of perl code on a system. The file that GL snippet came from is over ten thousand lines long. My brain is GL about to implode. better that it implode instead of

Re: [Boston.pm] $#{$Queue}

2010-09-27 Thread rogers-pm5
From: Greg Londonem...@greglondon.com Date: Mon, 27 Sep 2010 20:49:49 -0400 Oh god. I'm digging through what might be on the order of.a hundred thousand lines of perl code on a system. The file that snippet came from is over ten thousand lines long. My brain is about to implode.

Re: [Boston.pm] $#{$Queue}

2010-09-27 Thread Uri Guttman
r == rogers-pm5 rogers-...@rgrjr.dyndns.org writes: rFrom: Greg Londonem...@greglondon.com rDate: Mon, 27 Sep 2010 20:49:49 -0400 rOh god. I'm digging through what might be on the order of.a hundred rthousand lines of perl code on a system. The file that snippet came

Re: [Boston.pm] $#{$Queue}

2010-09-27 Thread rogers-pm5
From: Uri Guttman u...@stemsystems.com Date: Mon, 27 Sep 2010 23:15:17 -0400 actually the = part is even more amusing. look here: perl -le '$#foo = -2 ; print $#foo' -1 ; you can't set the last index to -1. which makes sense. which makes the original code even dumber.

Re: [Boston.pm] $#{$Queue}

2010-09-27 Thread Uri Guttman
r == rogers-pm5 rogers-...@rgrjr.dyndns.org writes: rFrom: Uri Guttman u...@stemsystems.com rDate: Mon, 27 Sep 2010 23:15:17 -0400 ractually the = part is even more amusing. look here: rperl -le '$#foo = -2 ; print $#foo' r-1 r ; ryou can't set the last