[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Speed question



On Thu, Jun 01, 2000 at 06:19:05PM +0200, Giorgio Valoti wrote:
> "Andrew M. Langmead" wrote:
> 
> > You might be better of grabbing on key at a time by using the iterator
> > built into the scalar context version of keys().
> >
> > while(defined(my $key = keys %database) ) {
> >   print DUMP "$key\n". ("=" x (length($key)+1))."\n";
> >   print DUMP "$database{$key}\n\n";
> > }
> 
> uhm... I get this error:
> # Use of uninitialized value.
> File 'Macintosh HD:Desktop Folder:testDB_file.pl'; Line 33 which is the
> #
>   print DUMP "$database{$key}\n\n";
> #
> line
> I'm a newbie am I missing something obvious?
> bye

Andrew had mixed up keys() and each(), as Ken mentioned.  This is what he
meant:

while(defined(my $key = each %database) ) {
  print DUMP "$key\n". ("=" x (length($key)+1))."\n";
  print DUMP "$database{$key}\n\n";
}

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org