Re: dereferencing hash arrays

2010-08-19 Thread Sharan Basappa
wow! My impending question about usage of -> also got answered ... On Thu, Aug 19, 2010 at 5:59 PM, Chas. Owens wrote: > On Thu, Aug 19, 2010 at 07:51, Sharan Basappa > wrote: >> Hello, >> >> Assuming I have reference to an hash array $rHash, what would be the >> way to dereference it. >> Woul

Re: dereferencing hash arrays

2010-08-19 Thread Chas. Owens
On Thu, Aug 19, 2010 at 07:51, Sharan Basappa wrote: > Hello, > > Assuming I have reference to an hash array $rHash, what would be the > way to dereference it. > Would it be: %hashEntry = %{$rHash}; ? snip The ways to dereference a hash are # treat $ref as a hash variable %$ref # treat $ref as

Re: dereferencing hash arrays

2010-08-19 Thread Robert Wohlfarth
On Thu, Aug 19, 2010 at 6:51 AM, Sharan Basappa wrote: > Assuming I have reference to an hash array $rHash, what would be the > way to dereference it. > Would it be: %hashEntry = %{$rHash}; ? > Yes, that dereferences the hash. It's useful notation in loops... foreach (keys %{$rHash}) while (my ($

dereferencing hash arrays

2010-08-19 Thread Sharan Basappa
Hello, Assuming I have reference to an hash array $rHash, what would be the way to dereference it. Would it be: %hashEntry = %{$rHash}; ? Regards, Sharan -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: hash arrays

2010-08-14 Thread Dr.Ruud
Chas. Owens wrote: Thomas Bätzler: #!/usr/bin/perl -w use strict; Don't use -w. Use the [warnings pragma][0] instead. When you say -w you turn on warnings for everything, even modules that are not expecting them. Read more in [perldoc perllexwarn][1]. And that is why I prefer -w. (Mayb

Re: hash arrays

2010-07-26 Thread Chas. Owens
On Mon, Jul 26, 2010 at 09:21, Thomas Bätzler wrote: snip > Assuming that $abc is a hash reference, it works like this: > > #!/usr/bin/perl -w > > use strict; snip Don't use -w. Use the [warnings pragma][0] instead. When you say -w you turn on warnings for everything, even modules that are not

Re: hash arrays

2010-07-26 Thread Sharan Basappa
Thank you, Bob & others. I think I now understand better. I have the source code. So now I should be able to figure this out. Regards, Sharan On Mon, Jul 26, 2010 at 6:00 PM, Rob Coops wrote: > > > On Mon, Jul 26, 2010 at 2:09 PM, Sharan Basappa > wrote: >> >> Folks, >> >> I am reusing a code f

AW: hash arrays

2010-07-26 Thread Thomas Bätzler
Hi, Sharan Basappa asked: > I am reusing a code for some enhancements. According to my > understanding, it is a record with > some unique string as key and then hash array as the value. > > I iterate through the array and print as follows: > > foreach my $key (keys %{$abc}) > { > print "$key

Re: hash arrays

2010-07-26 Thread Chas. Owens
On Mon, Jul 26, 2010 at 08:09, Sharan Basappa wrote: > Folks, > > I am reusing a code for some enhancements. According to my > understanding, it is a record with > some unique string as key and then hash array as the value. > > I iterate through the array and print as follows: > > foreach my $key

Re: hash arrays

2010-07-26 Thread Rob Coops
On Mon, Jul 26, 2010 at 2:09 PM, Sharan Basappa wrote: > Folks, > > I am reusing a code for some enhancements. According to my > understanding, it is a record with > some unique string as key and then hash array as the value. > > I iterate through the array and print as follows: > > foreach my $ke

hash arrays

2010-07-26 Thread Sharan Basappa
Folks, I am reusing a code for some enhancements. According to my understanding, it is a record with some unique string as key and then hash array as the value. I iterate through the array and print as follows: foreach my $key (keys %{$abc}) { print "$key ${$abc}{$key} \n"; } I get values suc

Re: avoid repitive code while sorting hash arrays

2003-09-19 Thread Rob Dixon
Ramprasad wrote: > > Rob Dixon wrote: > > > > > > Will this do? > > > > sort { > > my ($va, $vb) = map $$hash{$_}{$sortkey}, $direction eq 'a' ? ($a, $b) : ($b, > > $a); > > $sortkey eq 'uname' ? $va cmp $vb : $va <=> $vb; > > } keys %$hash; > > > > Cheers, > > > > Rob > > > > > > Gr8 Now the

Re: avoid repitive code while sorting hash arrays

2003-09-19 Thread Ramprasad A Padmanabhan
Rob Dixon wrote: Ramprasad wrote: suppose I have a hash like %users =( 'cvs' => { 'uname' => 'cvs', 'uid' => 582, 'gid' => 500 }, 'radvd' => { 'uname' => '

Re: avoid repitive code while sorting hash arrays

2003-09-19 Thread Chuck Fox
Rob and all the other perl wonder workers who contribute to this list, Awesome, While I have been reading and writing perl for a few years now, I am always amazed at the code reduction that can occur when you properly apply the power of perl. This is the most instructive forum that I have ever

Re: avoid repitive code while sorting hash arrays

2003-09-19 Thread Rob Dixon
Ramprasad wrote: > suppose I have a hash like > > %users =( >'cvs' => { > 'uname' => 'cvs', > 'uid' => 582, > 'gid' => 500 > }, > 'radvd' => { > 'un

avoid repitive code while sorting hash arrays

2003-09-19 Thread Ramprasad A Padmanabhan
suppose I have a hash like %users =( 'cvs' => { 'uname' => 'cvs', 'uid' => 582, 'gid' => 500 }, 'radvd' => { 'uname' => 'radvd', 'u

Re: hash & arrays

2003-01-09 Thread Victor Tsang
you second @EXPORT_OK= statement reset the EXPORT_OK array, I believe the correct syntex should be. our @EXPORT_OK = qw(@T_AREA %T_IDS); Tor. Jerry Preston wrote: > > Hi!, > > I do not understand what I am doing wrong. I can pass an hash this way and > not an array using the following: > >

Re: hash & arrays

2003-01-09 Thread Jenda Krynicky
From: "Jerry Preston" <[EMAIL PROTECTED]> > I do not understand what I am doing wrong. I can pass an hash this > way and not an array using the following: > >require Exporter; > >our @ISA = qw(Exporter); >our @EXPORT = qw(); >our @EXPORT_OK = qw( @T_AREA ); >our @EXPORT_OK =

RE: hash & arrays

2003-01-09 Thread wiggins
You are resetting (clearing) @EXPORT_OK. Either you need to set it all at once or push to it (though I don't know if this latter works, should). See inline. On Thu, 9 Jan 2003 06:26:01 -0600, "Jerry Preston" <[EMAIL PROTECTED]> wrote: > Hi!, > >

hash & arrays

2003-01-09 Thread Jerry Preston
Hi!, I do not understand what I am doing wrong. I can pass an hash this way and not an array using the following: require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(); our @EXPORT_OK = qw( @T_AREA ); our @EXPORT_OK = qw( %T_IDS ); where @T_AREA = ( "", "NORTH", "SOUT

Help with Hash Arrays

2002-10-14 Thread Vincent Lee
Can someone help me with this? I have a query in a database that queries the columns from the SYSCAT.COLUMNS table of either Oracle or DB2. I want to be able to print the columns in a string as follows: Col1, col2, col3...etc. depending on the table. How would I do this? = Regards, Vinc