dimmesdale has asked for the wisdom of the Perl Monks concerning the following question:
I created a callback on the option menu that holds the directory, but apart from other problems during testing yesterday, doday I'm getting an error message: Can't use string "string here" as a HASH ref. Here's the code, some things, of course, taken out.
sub generate_options { ... opendir(DIR,$_[0]->{base}); my @subdirs = grep /[Tt][Ss]\d+/, readdir(DIR); closedir(DIR); ... my $nb = $mw->NoteBook->grid; ... for(1..$_[0]->{conds}) { $page->[$_-1] = $nb->add("Page$_", -label => "Condition $_") } for(1..$_[0]->{conds}) { ... my $dom = $page->[$_-1]->Optionmenu( -variable => \$info->{subdir}->[$_-1], -options => [@subdirs], ); my $fom = $page->[$_-1]->Optionmenu( -variable => \$info->{file}->[$_-1], -options => get_files ($_[0]->{base},\@subdirs, 0), ); # This here is where I get into trouble: $info->{subdir}... # is spitting out hash ref error described above $dom->configure(-command => sub { $fom->configure(-options => get_files($_[0]->{base},$info->{subdir}->[$_-1])) }); my $b = $page->[$_-1]->Button( -text => "Set", -command => [\&record, { info => $info, indx => $_-1 } +], ); ... $dom->grid( $fom ); ... } ... } sub get_files { opendir(DIR,$_[0] . '\\' . $_[1]->[$_[2]]); my @files = grep /.txt$/, readdir(DIR); closedir(DIR); return [@files]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't use string as HASH ref
by Abigail-II (Bishop) on Jul 23, 2002 at 15:51 UTC | |
by dimmesdale (Friar) on Jul 23, 2002 at 15:59 UTC | |
by Abigail-II (Bishop) on Jul 23, 2002 at 16:04 UTC | |
by dimmesdale (Friar) on Jul 23, 2002 at 16:50 UTC | |
by Abigail-II (Bishop) on Jul 23, 2002 at 16:57 UTC | |
| |
|
Re: Can't use string as HASH ref
by hossman (Prior) on Jul 23, 2002 at 22:44 UTC |