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