Charles K. Clarkson [CKC], on Tuesday, May 24, 2005 at 08:16 (-0500) thinks about:
CKC> It would be helpful to know what $hr looks like. Do this, and then CKC> show us what it looks like. Show a partial dump if this is too long. CKC> use Data::Dumper 'Dumper'; CKC> print Dumper $hr; in select I have around 30 columns, I think every structure from $get->fetchall_hashref('id') looks like this: '10' => { 'foo' => 'bar', 'bar' => 'foo' } so this will not help. CKC> : while (my ($id, $value) = each(%$hr)) { CKC> : get_something(); CKC> If you want to operate on a particular piece of data in a subroutine, CKC> then pass that data (or a reference to that data) to the subroutine. CKC> get_something( $hr ); I know, this is more proper, but not in this case, $hr is global and it is small example, but you have right, I should use _always_ this type. CKC> Catch the passed data structure. Avoid using variables in a subroutine CKC> which are not defined or passed into that subroutine. CKC> my $hr = shift; you have right of course, but this don't change the behavior. CKC> : foreach my $k ( reverse sort { $hr->{$a}{counter} <=> CKC> : $hr->{$b}{counter} } (keys( %$hr )) ) { CKC> : print $k; CKC> : } CKC> Avoid one letter variable names and neatly wrap long lines. $k was $key :) it was just only for test. I don't wrap a lot, I have 19" monitor, but when sending to list I should wrap, that's true. CKC> Give us a working example. Something we can copy to an editor and CKC> run to see your error. Help us help you find the problem. it was easy mistake, everything we should know about this is avoid using keys() on %$hr in while loop, because it resets iterator. That's all. The solution ? I have to redesign my script. -- How do you protect mail on web? I use http://www.2pu.net [It's kind of fun doing the impossible.] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>