Re: Sort table with dynamic order of fields [Part 1]

2002-07-31 Thread Connie Chan

 Using parallel arrays to store related data is not a good idea imho.

I wanna ask for long... so what is IMHO and RTFM ??


 I would use an (anonymous) array of hashes here:
 
 my $persons = [ { ID = 'Foo', COUNTRY = 'UK', GENDER = 'F' },
 { ID = 'Bar', COUNTRY = 'US', GENDER = 'M' },
 { ID = 'Bla', COUNTRY = 'HK', GENDER = 'M' },
 { ID = 'Bob', COUNTRY = 'HK', GENDER = 'F' }
   ];

Actually, the arrays are picked up from 'files' with their names.
like : open fh,... while... read... push @this_arr, $_ ... close(fh)
So to forms arrays... I think I know how to take care of this.

But is there any quick way to transform HOA to AOH ? I suggest this :

sub HoA2AoH
{ my %hash = @_; my @ret = ();
 my @keys = keys(%hash);

 for my $round (0..$#{$hash{$keys[0]}}) 
## Thanx 2 those folks teach me $#{$...} again ##

 { my %tempHash = ();
   for my $KEY(keys(%hash)) 
  { $tempHash{$KEY} = $hash{$KEY}[$round] }
   push @ret, \%tempHash;
 }
  return @ret
}

Any comment ? Any faster ways ?


Rgds,
Connie


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Sort table with dynamic order of fields [Part 1]

2002-07-31 Thread Timothy Johnson


IMHO = In My Humble Opinion

RTFM = Read The Freaking Manual

TMAMYEHTU = Too Many Acronyms Make Your Emails Hard To Understand

-Original Message-
From: Connie Chan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 10:28 AM
To: [EMAIL PROTECTED]; Felix Geerinckx
Subject: Re: Sort table with dynamic order of fields [Part 1]


 Using parallel arrays to store related data is not a good idea imho.

I wanna ask for long... so what is IMHO and RTFM ??


 I would use an (anonymous) array of hashes here:
 
 my $persons = [ { ID = 'Foo', COUNTRY = 'UK', GENDER = 'F' },
 { ID = 'Bar', COUNTRY = 'US', GENDER = 'M' },
 { ID = 'Bla', COUNTRY = 'HK', GENDER = 'M' },
 { ID = 'Bob', COUNTRY = 'HK', GENDER = 'F' }
   ];

Actually, the arrays are picked up from 'files' with their names.
like : open fh,... while... read... push @this_arr, $_ ... close(fh)
So to forms arrays... I think I know how to take care of this.

But is there any quick way to transform HOA to AOH ? I suggest this :

sub HoA2AoH
{ my %hash = @_; my @ret = ();
 my @keys = keys(%hash);

 for my $round (0..$#{$hash{$keys[0]}}) 
## Thanx 2 those folks teach me $#{$...} again ##

 { my %tempHash = ();
   for my $KEY(keys(%hash)) 
  { $tempHash{$KEY} = $hash{$KEY}[$round] }
   push @ret, \%tempHash;
 }
  return @ret
}

Any comment ? Any faster ways ?


Rgds,
Connie


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Sort table with dynamic order of fields [Part 1]

2002-07-31 Thread Felix Geerinckx

on Wed, 31 Jul 2002 17:47:09 GMT, Timothy Johnson wrote:

 IMHO = In My Humble Opinion
 
 RTFM = Read The Freaking Manual
 
 TMAMYEHTU = Too Many Acronyms Make Your Emails Hard To Understand

Strange, I didn't find that last one at

http://www.apc.net/ia/scrmaim.htm

-- 
felix

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]