Re: self referential arrays/hashes ?

2011-08-18 Thread Dr.Ruud
On 2011-08-18 21:58, Dr.Ruud wrote: On 2011-08-18 16:51, Zak wrote: can you reference elements of an array/hash from within that array/ hash for example would @array=(A, B, C, D, $array[0], E, F) fly? See Data::Alias and Array::RefElem. perl -Mstrict -MData::Dumper -MData::Alias -wle '

self referential arrays/hashes ? [sort]

2011-08-18 Thread shawn wilson
". $i . ":" . $sorted->[ $i ]->[ $j ]->[ 1 ] . " had " . $sorted->[ $i ]->[ $j ]->[ 0 ] . " duplicates\n" if( $sorted->[ $i ]->[ $j ] ); } } -- Forwarded message -- From: Rob Dixon Date: Thu, Aug 18, 2011 at 17:37 Subje

Re: self referential arrays/hashes ?

2011-08-18 Thread Shawn H Corey
On 11-08-18 10:51 AM, Zak wrote: @array=(A, B, C, D, $array[0], E, F) This is the same as: { my @temporary = @array; @array = ( A, B, C, D, $temporary[0], E, F ); } -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding. Programming is as much

Re: self referential arrays/hashes ?

2011-08-18 Thread Jim Gibson
On 8/18/11 Thu Aug 18, 2011 7:51 AM, "Zak" scribbled: > can you reference elements of an array/hash from within that array/ > hash for example would > > @array=(A, B, C, D, $array[0], E, F) > > fly? Try it out. See what you get. The above will not set the fifth element of @array to 'A', how

Re: self referential arrays/hashes ?

2011-08-18 Thread Rob Dixon
On 18/08/2011 15:51, Zak wrote: can you reference elements of an array/hash from within that array/ hash for example would @array=(A, B, C, D, $array[0], E, F) fly? You can write my @array; @array=('A', 'B', 'C', 'D', \$array[0], 'E', 'F'); What are you trying to do? Rob -- To unsub

Re: self referential arrays/hashes ?

2011-08-18 Thread Dr.Ruud
On 2011-08-18 16:51, Zak wrote: can you reference elements of an array/hash from within that array/ hash for example would @array=(A, B, C, D, $array[0], E, F) fly? See Data::Alias and Array::RefElem. perl -Mstrict -MData::Dumper -MData::Alias -wle ' my @data = qw(A B C D A E F A B B A);

self referential arrays/hashes ?

2011-08-18 Thread Zak
can you reference elements of an array/hash from within that array/ hash for example would @array=(A, B, C, D, $array[0], E, F) fly? Zak -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: arrays/hashes

2004-02-19 Thread James Edward Gray II
On Feb 19, 2004, at 1:25 PM, [EMAIL PROTECTED] wrote: Thought i'd address the build portion below, to see if i'm not utilizing PERL's strengths correctly. First PERL i've written in 3+ years. Perl. The language you are relearning is called Perl, not PERL. ;) James -- To unsubscribe, e-mail:

Re: arrays/hashes

2004-02-19 Thread jeffrey_n_Dyke
Hi Jeffrey. >> There are several questions here, so I've answered in-line. Rob, thanks a ton. that worked perfectly, as has the rest of the processing of the larger hash. Thought i'd address the build portion below, to see if i'm not utilizing PERL's strengths correctly. First PERL i've wr

Re: arrays/hashes

2004-02-19 Thread Rob Dixon
Hi Jeffrey. There are several questions here, so I've answered in-line. Jeffrey N Dyke wrote: > > I had a simple array in mind, but as i got reacquainted with PERL, with the > help of the list, i realized i was thinking to small. (that's always > dangerous) On the contrary, I think thinking BIG

arrays/hashes

2004-02-19 Thread jeffrey_n_Dyke
Hello, I had a simple array in mind, but as i got reacquainted with PERL, with the help of the list, i realized i was thinking to small. (that's always dangerous) Anyway. I have an array/hash(still learning the technical differences) similar to (pardon syntax irregularities, just trying

Re: Wanted: Help with perl 5.6 syntax Arrays, Hashes and references

2003-06-04 Thread R. Joseph Newton
Richard Heintze wrote: > Why does "@$y[$i]" work here, and "foreach $i (keys > %$x)" works to fetch the keys from a reference to a > hash, but I use $$x{$i} to fetch hash reference > element values instead of %$x{$i}? > > This seems very inconsistent to me. > Maybe, but it is really not. What y

Re: Wanted: Help with perl 5.6 syntax Arrays, Hashes and references

2003-06-01 Thread James Edward Gray II
On Saturday, May 31, 2003, at 03:51 PM, Richard Heintze wrote: James, I hope this is my last question. I appreciate your (and everyone else's that has contributed) generousity. Not a problem. Hope I'm helping more than I'm confusing. Why does "@$y[$i]" work here, and "foreach $i (keys %$x)" wo

Re: Wanted: Help with perl 5.6 syntax Arrays, Hashes and references

2003-06-01 Thread Richard Heintze
James, I hope this is my last question. I appreciate your (and everyone else's that has contributed) generousity. I have a web site I inherited where a single page has 3000 lines of perl code. It does not use strict or warnings. The original authors only used global variables and never used any f

Re: Wanted: Help with perl 5.6 syntax Arrays, Hashes and references

2003-06-01 Thread James Edward Gray II
On Saturday, May 31, 2003, at 02:45 PM, Richard Heintze wrote: Can you explain this syntax then, that is used with foreach loops? foreach my $i (keys %{$x}) { ... } Why don't we use foreach my $i (keys $$x){... }? What is the name for this syntax: "(keys %{$x})"? Oops, sorry, I meant to get to

Re: Wanted: Help with perl 5.6 syntax Arrays, Hashes and references

2003-06-01 Thread Richard Heintze
Sorry James, you got a second copy. I meant to reply to the group. James, thank you, thank you! Can you explain this syntax then, that is used with foreach loops? foreach my $i (keys %{$x}) { ... } Why don't we use foreach my $i (keys $$x){... }? > > What is the name for this syntax: "(keys

Re: Wanted: Help with perl 5.6 syntax Arrays, Hashes and references

2003-06-01 Thread James Edward Gray II
On Saturday, May 31, 2003, at 01:47 PM, Richard Heintze wrote: I tried "use strict;" and that worked. Are you encouraging me to use "use warn;" too? That does not work. use warnings; It will alert you to potential problems in your code, while strict makes sure you obey the good programmer rules

Re: Wanted: Help with perl 5.6 syntax Arrays, Hashes and references

2003-06-01 Thread John W. Krahn
Richard Heintze wrote: > > I have some more questions! > > I tried "use strict;" and that worked. Are you > encouraging me to use "use warn;" too? That does not > work. use warnings; And/or: use diagnostics; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTE

Re: Wanted: Help with perl 5.6 syntax Arrays, Hashes and references

2003-06-01 Thread John W. Krahn
Richard Heintze wrote: > > Some help understanding this program would be greatly > appreciated! I'm really struggling with this perl > language! perldoc perldata perldoc perlreftut perldoc perlref perldoc perldsc perldoc perllol > my $x= {'d' => 'y', 'f' => 'g'}, > $y = ['a', 'b', 'c', 'd']

Re: Wanted: Help with perl 5.6 syntax Arrays, Hashes and references

2003-06-01 Thread Richard Heintze
Thank you very much James and David! Wow! What prompt responses! I have some more questions! I tried "use strict;" and that worked. Are you encouraging me to use "use warn;" too? That does not work. > > # $i receives the proper values > > foreach my $i (keys %{$x}) { > > # (4) Why does not thi

Re: Wanted: Help with perl 5.6 syntax Arrays, Hashes and references

2003-06-01 Thread James Edward Gray II
On Saturday, May 31, 2003, at 12:51 PM, Richard Heintze wrote: my $x= {'d' => 'y', 'f' => 'g'}, $y = ['a', 'b', 'c', 'd']; I am surprised this works. I would write this as: my($x, $y) = ( { d => 'y', f => 'g' }, [ qw(a b c d) ] ); The => operator automatically quotes barewords in front of

RE: Wanted: Help with perl 5.6 syntax Arrays, Hashes and references

2003-06-01 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Richard Heintze wrote: > Some help understanding this program would be greatly > appreciated! I'm really struggling with this perl > language! > Thanks, > siegfried > You should always use warnings and strict. In the first portion, you had a comma after the end of $x lin

Wanted: Help with perl 5.6 syntax Arrays, Hashes and references

2003-06-01 Thread Richard Heintze
Some help understanding this program would be greatly appreciated! I'm really struggling with this perl language! Thanks, siegfried my $x= {'d' => 'y', 'f' => 'g'}, $y = ['a', 'b', 'c', 'd']; # This works! Good! foreach my $i (@{$y}){ print "array i = $i\n" } # (1) Why does