Re: Manipulating reference to array of array references

2011-11-21 Thread Rob Dixon
On 20/11/2011 04:14, Chris Charley wrote: Well, if Dr Ruud is right, and you shouldn't replace the undefs in the original arrays, then the following program wouldn't be correct. It changes the original array (data). On 20/11/2011 00:23, Dr.Ruud wrote: Unless you really want to change your

Re: Manipulating reference to array of array references

2011-11-21 Thread Mohan L
Unless you really want to change your data, use map(). Ruud didn't say that you shouldn't change the data, only that you should use map unless that was what you wanted. Who knows what the OP wants. Rob Sorry for the delay. What Shlomi Fish mentioned was I wanted. Thanks for all your

Re: Manipulating reference to array of array references

2011-11-20 Thread Rob Dixon
' ] ]; To print 'fred' , I can use like : print $ref_to_AoA-[0]-[0]; But What I want is, I want to replace all 'undef' to a string 'foo'. What is the efficient way I will replace it (the array is larger then what I am showing above). Any help and explanation will be appreciated. If you want just to print

Re: Manipulating reference to array of array references

2011-11-20 Thread Chris Charley
' ] ]; To print 'fred' , I can use like : print $ref_to_AoA-[0]-[0]; But What I want is, I want to replace all 'undef' to a string 'foo'. What is the efficient way I will replace it (the array is larger then what I am showing above). Any help and explanation will be appreciated. Thanks Rg Mohan L

Manipulating reference to array of array references

2011-11-19 Thread Mohan L
I want is, I want to replace all 'undef' to a string 'foo'. What is the efficient way I will replace it (the array is larger then what I am showing above). Any help and explanation will be appreciated. Thanks Rg Mohan L

Re: Manipulating reference to array of array references

2011-11-19 Thread Shlomi Fish
', undef, 'judy' ] ]; To print 'fred' , I can use like : print $ref_to_AoA-[0]-[0]; But What I want is, I want to replace all 'undef' to a string 'foo'. What is the efficient way I will replace it (the array is larger then what I am showing above). Any help

Re: Manipulating reference to array of array references

2011-11-19 Thread Dr.Ruud
On 2011-11-19 19:21, Mohan L wrote: But What I want is, I want to replace all 'undef' to a string 'foo'. Unless you really want to change your data, use map(). -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org

sorting array of array of array elements

2008-04-22 Thread Süleyman Gülsüner
} 32 elsif ($tab eq 3) { 33 $sub3[$h][$i] = $title; 34 $i++; 35 } 36 } this strategy works for only if there are main and sub titles. it doesn't work for 2. and 3. level sub titles, because of the change of 1. level sub title array. putting them into different files

Re: array within array

2007-10-30 Thread Ron Bergin
is incomplete and I'm doing an array within an array which is incorrect. Please help. You are not using arrays you are using hashes. Here's what I want to do; I have to flat files (pipe delimited, export from a database) that I want to parse through and assign variables for each column. Basically

array within array

2007-10-29 Thread Mike Tran
Hey all, I'm new with Perl and need help with this simple script. I'm still playing around with the script below to get a feel for Perl. My script below is incomplete and I'm doing an array within an array which is incorrect. Please help. Here's what I want to do; I have to flat files

Re: array within array

2007-10-29 Thread Beginner
On 29 Oct 2007 at 8:42, Mike Tran wrote: Hey all, I'm new with Perl and need help with this simple script. I'm still playing around with the script below to get a feel for Perl. My script below is incomplete and I'm doing an array within an array which is incorrect. Please help

RE: array within array

2007-10-29 Thread Andrew Curry
PROTECTED] Sent: 29 October 2007 15:30 To: beginners @ perl. org Subject: Re: array within array On 29 Oct 2007 at 8:42, Mike Tran wrote: Hey all, I'm new with Perl and need help with this simple script. I'm still playing around with the script below to get a feel for Perl. My script

Re: array within array

2007-10-29 Thread John W . Krahn
On Monday 29 October 2007 07:29, Beginner wrote: while (EXCLUDE) { chomp; my @fields = split(/|/,$_); ^^^ $exclude_bases{$F[0]} = 0; # $f[0] contains base_no } close(EXCLUDE); open(BASE,base.txt)|| die(Could not open file!); while (BASE) {

Re: array within array

2007-10-29 Thread Dr.Ruud
Andrew Curry schreef: be very careful with exists, it auto creates the structure use Data::Dumper; my %hash; if (exists $hash{a}{b}) {} print Dumper(\%hash) then the next time you use exists it is there. defined is much safer as it doesnt do this. No, the difference here

Re: array within array

2007-10-29 Thread John W . Krahn
On Monday 29 October 2007 06:42, Mike Tran wrote: Hey all, Hello, I'm new with Perl and need help with this simple script. I'm still playing around with the script below to get a feel for Perl. My script below is incomplete and I'm doing an array within an array which is incorrect. Please

Re: array within array

2007-10-29 Thread Ron Bergin
On Oct 29, 6:42 am, [EMAIL PROTECTED] (Mike Tran) wrote: Hey all, I'm new with Perl and need help with this simple script. I'm still playing around with the script below to get a feel for Perl. My script below is incomplete and I'm doing an array within an array which is incorrect. Please

RE: array within array

2007-10-29 Thread Mike Tran
beginners Subject: Re: array within array On Monday 29 October 2007 06:42, Mike Tran wrote: Hey all, Hello, I'm new with Perl and need help with this simple script. I'm still playing around with the script below to get a feel for Perl. My script below is incomplete and I'm doing an array within

Re: Printing size of array unitializes array?

2007-10-19 Thread Dr.Ruud
Matthew Whipple schreef: If you're looking for the last element then you could use $files[$#files] Or $files[-1]. -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Printing size of array unitializes array?

2007-10-19 Thread yitzle
I use the scalar keyword on occasion: #!/usr/bin/perl my @arr = qw/adfs adsf 4fd feqw3 f432d/; print The size of the array is . scalar (@arr) . \n; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Printing size of array unitializes array?

2007-10-19 Thread Matthew Whipple
line, it initializes the files array and I can't use it after? Why is that? I actually guessed the code to be trying to go one way but am now changing my guess. Don't say initialize when you don't mean it, that implies that the variable previously contained no value. I now

Re: Printing size of array unitializes array?

2007-10-19 Thread Matthew Whipple
Joseph L. Casale wrote: Sorry, it is an array I used above this block of code. jlc That could have easily been guessed (that's one of the few options). The question is what's in it and what are you trying to do with it. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL

Re: Printing size of array unitializes array?

2007-10-19 Thread Matthew Whipple
[EMAIL PROTECTED] wrote: I had the following code: open (FILEOUT, $OutDir/info) or die $!; print FILEOUT text = abc\n; my $Tmp = ++$#files; print FILEOUT moretext = $Tmp\n; When I add the 3rd line, it initializes the files array and I can't

Re: Printing size of array unitializes array?

2007-10-19 Thread Tom Phoenix
On 10/19/07, Joseph L. Casale [EMAIL PROTECTED] wrote: open (FILEOUT, $OutDir/info) or die $!; print FILEOUT text = abc\n; my $Tmp = ++$#files; Huh? print FILEOUT moretext = $Tmp\n; When I add the 3rd line, it initializes the files array

RE: Printing size of array unitializes array?

2007-10-19 Thread Joseph L. Casale
Sorry, it is an array I used above this block of code. jlc -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of yitzle Sent: October-19-07 11:16 AM To: Joseph L. Casale Cc: beginners@perl.org Subject: Re: Printing size of array unitializes array? What are you

Re: Printing size of array unitializes array?

2007-10-19 Thread yitzle
; my $Tmp = ++$#files; print FILEOUT moretext = $Tmp\n; When I add the 3rd line, it initializes the files array and I can't use it after? Why is that? I now have: open (FILEOUT, $OutDir/info) or die $!; print FILEOUT text = abc\n; print

Printing size of array unitializes array?

2007-10-19 Thread Joseph L. Casale
I had the following code: open (FILEOUT, $OutDir/info) or die $!; print FILEOUT text = abc\n; my $Tmp = ++$#files; print FILEOUT moretext = $Tmp\n; When I add the 3rd line, it initializes the files array and I can't use it after? Why is that? I

RE: Array of Array refs

2007-05-30 Thread Andrew Curry
: Array of Array refs On May 29, 6:06 am, [EMAIL PROTECTED] (Paul Lalli) wrote: On May 29, 4:58 am, [EMAIL PROTECTED] (Brian) wrote: On May 28, 6:14 pm, [EMAIL PROTECTED] (Paul Lalli) wrote: oh yes, more important than all that minutiae... the push did not work for me in the working code

Re: Array of Array refs

2007-05-29 Thread Brian
step toward becoming a better programmer. hmmm, misunderstanding there. The push worked fine in the sample I posted, but not in the more complex working program I had simplified as an example. The array was being rewritten. Then you didn't delcare your variables in the correct scope

Re: Array of Array refs

2007-05-29 Thread Brian
On May 28, 6:04 pm, [EMAIL PROTECTED] (Paul Lalli) wrote: On May 28, 3:22 pm, [EMAIL PROTECTED] (Brian) wrote: my variable names end with A for array and H for hash, Pointless. Variable names in Perl identify what kind of variable they are. @ for arrays, % for hashes. [ ] for accessing

Re: Array of Array refs

2007-05-29 Thread Paul Lalli
On May 29, 5:30 am, [EMAIL PROTECTED] (Brian) wrote: On May 28, 6:04 pm, [EMAIL PROTECTED] (Paul Lalli) wrote: On May 28, 3:22 pm, [EMAIL PROTECTED] (Brian) wrote: my variable names end with A for array and H for hash, Pointless. Variable names in Perl identify what kind of variable

Re: Array of Array refs

2007-05-29 Thread Paul Lalli
() works perfectly well. It adds elements to an array. If your program produced incorrect results, it is because you did something wrong, not because push didn't work. Of course, as you haven't shown any code that produces these undesired results, we can only guess as to what your actual problem

Re: Array of Array refs

2007-05-29 Thread Rob Dixon
Brian wrote: Paul Lalli wrote: Brian wrote: my variable names end with A for array and H for hash, Pointless. Variable names in Perl identify what kind of variable they are. @ for arrays, % for hashes. [ ] for accessing an element of a hash, { } for accessing element of a hash. no, I

Re: Array of Array refs

2007-05-29 Thread Paul Lalli
On May 29, 10:16 am, [EMAIL PROTECTED] (Rob Dixon) wrote: Brian wrote: I agree with you Brian. I have been posting on this list for around four years, and rarely have I seen 'help' that is expressed with such vitriol as Paul's has been. I'm truly sorry you feel that way, Brian. My responses

Re: Array of Array refs

2007-05-29 Thread Paul Lalli
On May 29, 11:10 am, [EMAIL PROTECTED] (Paul Lalli) wrote: On May 29, 10:16 am, [EMAIL PROTECTED] (Rob Dixon) wrote: Brian wrote: I agree with you Brian. I have been posting on this list for around four years, and rarely have I seen 'help' that is expressed with such vitriol as Paul's

Re: Array of Array refs

2007-05-29 Thread Dr.Ruud
Brian schreef: Changing @ to $ is confusing... Huh? @ means array, $ means scalar; there is nothing to change. -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Array of Array refs

2007-05-29 Thread Paul Lalli
On May 29, 3:21 pm, [EMAIL PROTECTED] (Dr.Ruud) wrote: Brian schreef: Changing @ to $ is confusing... Huh? @ means array, $ means scalar; there is nothing to change. Presumably, he meant that @array identifies the entire array, while $array[0] identifies the first element of the array, thus

Re: Re: Array of Array refs @ 1180470274

2007-05-29 Thread Johan Meskens CS3 jmcs3
Intrah onat Diria .. , ** wrote Revera y: Changing @ to $ is confusing... this is different in perl6 , http://dev.perl.org/perl6/doc/design/syn/S09.html the following could be unreadable @ 1180470350 ::: hbeingspiel , 0::- , 1::',| , 0::| , 1::vert{ ,

Re: Array of Array refs

2007-05-29 Thread Chas Owens
On 29 May 2007 13:04:42 -0700, Paul Lalli [EMAIL PROTECTED] wrote: On May 29, 3:21 pm, [EMAIL PROTECTED] (Dr.Ruud) wrote: Brian schreef: Changing @ to $ is confusing... Huh? @ means array, $ means scalar; there is nothing to change. Presumably, he meant that @array identifies the entire

Re: Array of Array refs

2007-05-29 Thread Brian
simplified as an example. nope, sorry, you're wrong. push() works perfectly well. It adds elements to an array. If your program produced incorrect results, it is because you did something wrong, not because push didn't work. ugh. pedantic semantics... Of course, as you haven't shown any

Array of Array refs

2007-05-28 Thread Brian
Hi All- I am trudging through some DBI, XML, etc.. I had a problem and was baffled by how to get at array elements out of a series of pushed array refs. But, by simplifying the problem, I found that the syntax I used was in error. here is the small sample, already debugged. Hope this helps

Re: Array of Array refs

2007-05-28 Thread Rob Dixon
Brian wrote: Hi All- I am trudging through some DBI, XML, etc.. I had a problem and was baffled by how to get at array elements out of a series of pushed array refs. But, by simplifying the problem, I found that the syntax I used was in error. here is the small sample, already debugged. Hope

Re: Array of Array refs

2007-05-28 Thread Paul Lalli
On May 28, 12:00 am, [EMAIL PROTECTED] (Brian) wrote: I am trudging through some DBI, XML, etc.. I had a problem and was baffled by how to get at array elements out of a series of pushed array refs. What's to be baffled by? Have you read: perldoc perlreftut perldoc perllol perldoc perldsc

Re: Array of Array refs

2007-05-28 Thread Brian
On May 27, 9:00 pm, [EMAIL PROTECTED] (Brian) wrote: Hi All- I am trudging through some DBI, XML, etc.. I had a problem and was baffled by how to get at array elements out of a series of pushed array refs. But, by simplifying the problem, I found that the syntax I used was in error. here

Re: Array of Array refs

2007-05-28 Thread Brian
On May 27, 9:00 pm, [EMAIL PROTECTED] (Brian) wrote: Hi All- I am trudging through some DBI, XML, etc.. I had a problem and was baffled by how to get at array elements out of a series of pushed array refs. But, by simplifying the problem, I found that the syntax I used was in error. here

Re: Array of Array refs

2007-05-28 Thread Paul Lalli
On May 28, 3:22 pm, [EMAIL PROTECTED] (Brian) wrote: my variable names end with A for array and H for hash, Pointless. Variable names in Perl identify what kind of variable they are. @ for arrays, % for hashes. [ ] for accessing an element of a hash, { } for accessing element of a hash. yes

Re: Array of Array refs

2007-05-28 Thread Paul Lalli
On May 28, 3:26 pm, [EMAIL PROTECTED] (Brian) wrote: On May 27, 9:00 pm, [EMAIL PROTECTED] (Brian) wrote: Hi All- I am trudging through some DBI, XML, etc.. I had a problem and was baffled by how to get at array elements out of a series of pushed array refs. But, by simplifying

Re: calculate the value in an array of array

2006-08-19 Thread chen li
--- John W. Krahn [EMAIL PROTECTED] wrote: I have an array of array look like this: @array_of_array=( [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5] ) How do I get the total values for each colume

RE: calculate the value in an array of array

2006-08-19 Thread Charles K. Clarkson
chen li wrote: : $total[ $column ] += $row-[ $column ]; : : Can you or anyone else explain it a bit more? It is short for this. $total[ $column ] = $total[ $column ] + $row-[ $column ]; HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254

calculate the value in an array of array

2006-08-18 Thread chen li
Dear all, I have an array of array look like this: @array_of_array=( [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5] ) How do I get the total values for each colume, such as $column1=1+1+1+1; $column2=2+2+2+2; $column3=3+3+3+3; ... Thanks

RE: calculate the value in an array of array

2006-08-18 Thread Nagasamudram, Prasanna Kumar
-Original Message- From: chen li [mailto:[EMAIL PROTECTED] Sent: Friday, August 18, 2006 7:00 PM To: beginners@perl.org Subject: calculate the value in an array of array Dear all, I have an array of array look like this: @array_of_array=( [1,2,3,4,5

Re: calculate the value in an array of array

2006-08-18 Thread Dr.Ruud
chen li schreef: I have an array of array look like this: @array_of_array=( [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5] ) How do I get the total values for each colume #!/usr/bin/perl use warnings ; use strict ; my @AoA

Re: calculate the value in an array of array

2006-08-18 Thread John W. Krahn
chen li wrote: Dear all, Hello, I have an array of array look like this: @array_of_array=( [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5] ) How do I get the total values for each colume, such as $column1=1+1+1+1; $column2=2+2

Re: calculate the value in an array of array

2006-08-18 Thread Rob Dixon
chen li wrote: I have an array of array look like this: @array_of_array=( [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5] ) How do I get the total values for each colume, such as $column1=1+1+1+1; $column2=2+2+2+2; $column3=3+3+3

Re: calculate the value in an array of array

2006-08-18 Thread Dalibor Straka
On Fri, Aug 18, 2006 at 06:29:36AM -0700, chen li wrote: Dear all, I have an array of array look like this: @array_of_array=( [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5] ) How do I get the total values for each colume

Re: calculate the value in an array of array

2006-08-18 Thread Dr.Ruud
row. Like an old turbo pascal implementation of strings did ;-) That's twisted. g (The array isn't guaranteed to be square either.) -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org

Re: @array =to= $array

2005-06-10 Thread Dave Gray
my $localtime; @$localtime{qw / second minute hour mday month year weekday yearday isdst /} = localtime(time); [1] A style nit: Speaking of nitpicks: my %localtime; If you DO need to iterate across all the indices for an array ( rarely necessary if you have designed your data correctly

Re: @array =to= $array

2005-06-10 Thread Lawrence Statton
my $localtime; @$localtime{qw / second minute hour mday month year weekday yearday isdst / } = localtime(time); [1] A style nit: Speaking of nitpicks: my %localtime; Assuming you are suggesting making that change, I'd reccomend against it, unless you wish to elicit the following

Re: @array =to= $array

2005-06-10 Thread Dave Gray
On 6/10/05, Lawrence Statton [EMAIL PROTECTED] wrote: my $localtime; @$localtime{qw / second minute hour mday month year weekday yearday isdst / } = localtime(time); [1] A style nit: Speaking of nitpicks: my %localtime; Assuming you are suggesting making that change,

Re: @array =to= $array

2005-06-10 Thread Lawrence Statton
Huh. So it does... that doesn't look like it's making a reference, though. I think I would write that as @{$localtime}{ ... } for clarity. I only got out my snippy voice because it will be a snowy day here when I post example code to the list that hasn't actually been tested. It does not

Re: @array =to= $array

2005-06-10 Thread Dave Gray
On 6/10/05, Lawrence Statton [EMAIL PROTECTED] wrote: Huh. So it does... that doesn't look like it's making a reference, though. I think I would write that as @{$localtime}{ ... } for clarity. As to the clarity question. To my eyes, I find spurious {} tend to diminish rather than

@array =to= $array

2005-06-09 Thread shoker
Hi All Prob: I want to convert all the elememts of an array to ascalor variable that I can use latter on in my code e.g. my @array=qw/balli johney bobby/; now here i need 3 different variable with the above values i.e. my $name1=balli ; my $name2=johney ; my $name3=bobby ; Soln so far

Re: @array =to= $array

2005-06-09 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi All Hello, Prob: I want to convert all the elememts of an array to ascalor variable that I can use latter on in my code Each element of an array *is* a scalar so why do you think you need to do this? e.g. my @array=qw/balli johney bobby/; now here i need 3

Re: @array =to= $array

2005-06-09 Thread Lawrence Statton
Hi All Prob: I want to convert all the elememts of an array to ascalor variable that I can use latter on in my code e.g. my @array=qw/balli johney bobby/; now here i need 3 different variable with the above values i.e. my $name1=balli ; my $name2=johney ; my $name3=bobby

Re: @array =to= $array

2005-06-09 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Each element of an array *is* a scalar so why do you think you need to do this? my ( $name1, $name2, $name3 ) = @array; True, But how would I know how many ($name) to use in the line above In my case for a perticular user I have some bad volumes which

Re: @array =to= $array

2005-06-09 Thread Pablo Wolter
[EMAIL PROTECTED] wrote: Hi All Prob: I want to convert all the elememts of an array to ascalor variable that I can use latter on in my code e.g. my @array=qw/balli johney bobby/; now here i need 3 different variable with the above values i.e. my $name1=balli ; my $name2=johney ; my $name3

Re: @array =to= $array

2005-06-09 Thread Lawrence Statton
[EMAIL PROTECTED] wrote: Hi All Prob: I want to convert all the elememts of an array to ascalor variable tha t I can use latter on in my code e.g. my @array=qw/balli johney bobby/; now here i need 3 different variable with the above values i.e. my $name1=balli ; my $name2=johney

Re: array against array regexp

2005-06-06 Thread Ing. Branislav Gerzo
Randal L. Schwartz [RLS], on , , 2005 at 05:47 (-0700) wrote about: RLS $wanted ||= $input =~ /$_/ for @filter; RLS $wanted; RLS } @input; RLS Note the use of ||= for short-circuiting the tests once a good filter RLS is found. You can't use return 1, because a grep/map block is

Re: Confusion on @array vs $array[] vs $array

2002-12-20 Thread Todd W
kc:very consistent, IMHO: You just need to keep in mind the types of kc:the values/data types ultimately being expressed, and it should kc:become clearer. $ always prefixes scalars or references, @ kc:always prefixes lists, and % always prefixes associative arrays kc:(a.k.a hashes). kc: kc:@array is a

Re: Perl 6 (was: Re: Confusion on @array vs $array[] vs $array)

2002-12-20 Thread Todd W
Fliptop [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... [reply cc'd to list] On Thu, 19 Dec 2002 at 06:23, Rob Richardson opined: RR:What is the advantage of these changes? RR:When is Perl 6 due out? RR:Do those links you provided describe all the

Re: Perl 6 (was: Re: Confusion on @array vs $array[] vs $array)

2002-12-20 Thread Todd W
Fliptop [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... [reply cc'd to list] On Thu, 19 Dec 2002 at 06:23, Rob Richardson opined: RR:What is the advantage of these changes? RR:When is Perl 6 due out? RR:Do those links you provided describe all the

Re: Confusion on @array vs $array[] vs $array

2002-12-19 Thread Anthony Early
And, for increased flexibility (strict/warn OK) my @array = ( 10,20,30,40); my %array = @array; my %hash = (1,2,3,4); my @hash = %hash; print Array Element \$array[1] = $array[1]\n; print Hash Element \$hash{'1'} = $hash{'1'}\n; print Array Hash Element \$array{'10'} = $array{'10'}\n; print

Re: Confusion on @array vs $array[] vs $array

2002-12-19 Thread kevin christopher
scalars or references, @ always prefixes lists, and % always prefixes associative arrays (a.k.a hashes). @array is a list $array[n] is a scalar/reference %hash is a hash $hash{'key'} is a scalar/reference @$ref dereferences a reference to an array, accessing the array In this case, print $ref; would

Re: Confusion on @array vs $array[] vs $array

2002-12-19 Thread fliptop
being expressed, and it should kc:become clearer. $ always prefixes scalars or references, @ kc:always prefixes lists, and % always prefixes associative arrays kc:(a.k.a hashes). kc: kc:@array is a list kc:$array[n] is a scalar/reference kc:%hash is a hash kc:$hash{'key'} is a scalar/reference kc

Re: Perl 6 (was: Re: Confusion on @array vs $array[] vs $array)

2002-12-19 Thread fliptop
[reply cc'd to list] On Thu, 19 Dec 2002 at 06:23, Rob Richardson opined: RR:What is the advantage of these changes? RR:When is Perl 6 due out? RR:Do those links you provided describe all the differences we will see in RR:Perl 6? i'm no authority on perl 6, so i can't answer any of your

Re: Confusion on @array vs $array[] vs $array

2002-12-18 Thread Octavian Rasnita
@var is an array $var is a scalar $var[0] is also a scalar even though is an array element. @var[0] is an array which contains more array elements, but in this case it contains just a single element. To create an array slice with more elements, you'll need something like @var[0 .. n] You need

Re: Confusion on @array vs $array[] vs $array

2002-12-18 Thread Mark Bergeron
I can see where you're coming from on this. However the most obvious reason is that perl has no relationship in scalar context between @somename and %somename. Your question regarding the special $ is not germane to this concept. Each element of the array is a separate scalar variable, accessed

RE: Confusion on @array vs $array[] vs $array

2002-12-18 Thread Scot Robnett
I don't know that I'd agree with the assessment @ = ordered list % = unordered list That's a bit confusing. It's true that a hash (or associative array) uses its own sort order unless you use the 'sort' option. But an array is a simple list of elements, whereas a hash