Re: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[$#{@$a}]'

2005-03-14 Thread marcos rebelo
] wrote: -Original Message- From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] Sent: Thursday, March 10, 2005 8:55 AM To: Marcos Rebelo Cc: Perl Beginners Subject: Re: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[EMAIL PROTECTED]' Marcos Rebelo wrote: This is correctly

Re: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[$#{@$a}]'

2005-03-12 Thread Jonathan Paton
You should not fiddle with $[ though. Unless you are creating an entry into the obfuscated code contest or a YAPH. Thanks for the idea :) @words = (another , hacker\n, Just , Perl ); eval '$[=' . $_ . ';print $words[3]' for 1, 3, 0, 2; The eval is required because you can only set $_ to a

Re: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[$#{@$a}]'

2005-03-12 Thread Hendrik Maryns
Jonathan Paton schreef: You should not fiddle with $[ though. Unless you are creating an entry into the obfuscated code contest or a YAPH. Thanks for the idea :) @words = (another , hacker\n, Just , Perl ); eval '$[=' . $_ . ';print $words[3]' for 1, 3, 0, 2; The eval is required because you can

Re: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[$#{@$a}]'

2005-03-11 Thread Gerhard Meier
On Thu, Mar 10, 2005 at 11:10:06AM -0500, Wiggins d'Anconia wrote: Btw ... What perldoc can I read to read about '$#'? Not sure, a quick glance at perldata discusses the -1 index usage, but didn't turn up $# that I could see. Its in the books :-). wiggim$ perldoc perldata | fgrep -c '$#'

Re: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[$#{@$a}]'

2005-03-10 Thread Wiggins d'Anconia
Marcos Rebelo wrote: This is correctly printing '7' but '$a-[EMAIL PROTECTED]' seems to be encripted code. Can I write this in a cleaner way? $a-[-1]; ??? http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[$#{@$a}]'

2005-03-10 Thread Harald Ashburner
On Thu, 10 Mar 2005 14:52:36 -, Marcos Rebelo [EMAIL PROTECTED] wrote: This is correctly printing '7' but '$a-[EMAIL PROTECTED]' seems to be encripted code. Can I write this in a cleaner way? perl -e '$a = [1,2,3,4,7]; print $a-[-1];' -- Kind regards, Hal Ashburner -- To

RE: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[$#{@$a}]'

2005-03-10 Thread Manav Mathur
;) $a is an anonymous reference to the array defined @$a resolves that reference [EMAIL PROTECTED] prints out the index of the last element of array $a-[elemmentnumber] is used to access an element thru an array reference. so $a-[EMAIL PROTECTED] simply gives you the last element of the array

RE: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[$#{@$a}]'

2005-03-10 Thread Marcos Rebelo
This really works, I didn't now that. Thanks Marcos Rebelo -Original Message- From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] Sent: quinta-feira, 10 de Março de 2005 14:55 To: Marcos Rebelo Cc: Perl Beginners Subject: Re: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[EMAIL PROTECTED

RE: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[$#{@$a}]'

2005-03-10 Thread Larsen, Errin M HMMA/IT
-Original Message- From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] Sent: Thursday, March 10, 2005 8:55 AM To: Marcos Rebelo Cc: Perl Beginners Subject: Re: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[EMAIL PROTECTED]' Marcos Rebelo wrote: This is correctly printing '7

Re: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[$#{@$a}]'

2005-03-10 Thread Wiggins d'Anconia
Larsen, Errin M HMMA/IT wrote: -Original Message- From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED] Sent: Thursday, March 10, 2005 8:55 AM To: Marcos Rebelo Cc: Perl Beginners Subject: Re: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[EMAIL PROTECTED]' Marcos Rebelo wrote

RE: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[$#{@$a}]'

2005-03-10 Thread Larsen, Errin M HMMA/IT
SNIP # or, since [EMAIL PROTECTED] will always be the index of the last element of the array: print $a-[-1] Did I get it right? That looks like homework to me ... Why would you ever do that in a practical script? --Errin I think you got it. Ever want the

Re: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[$#{@$a}]'

2005-03-10 Thread Wiggins d'Anconia
Larsen, Errin M HMMA/IT wrote: SNIP # or, since [EMAIL PROTECTED] will always be the index of the last element of the array: print $a-[-1] Did I get it right? That looks like homework to me ... Why would you ever do that in a practical script? --Errin I think you got it. Ever want the

RE: Simplify perl -e '$a = [1,2,3,4,7]; print $a-[$#{@$a}]'

2005-03-10 Thread Jenda Krynicky
From: Larsen, Errin M HMMA/IT [EMAIL PROTECTED] # [EMAIL PROTECTED] will be the number of elements in the array referenced by $a, minus one (or, '4', in this example) Well, yes most likely it will be, but it doesn't have to ;-) $#array is defined as the highest index in the array. The