Drieux -
Thanks for your reply. Your suggestion for the use of foreach makes
sense and as been implemented. However, I do not understand your
comments about the return value of map. Does not map return a reference
to an anonymous arrar, not a hash?
Dick Fell
Drieux wrote:
>
> On Wednesday, April 17, 2002, at 02:09 , richard noel fell wrote:
> [..]
> > sub create_menu_bar
> > {
> > my $mb = $MW->Menu();
> > $MW->configure(-menu=>$mb);
> > opendir DIR, "./" or die " cannot open current directory: $!";
> > my $current_directory = cwd;
> > my @directories = grep { !/^\.\.?$/ && -d "$current_directory/$_" }
> > readdir DIR;
> > map {$mb->cascade(-label => '~'.$_, -menuitems=>\&sub_menu($_))}
> > @directories;
> > sub sub_menu
> > {
> > chdir "$_[0]" or die "Cannot change directory: $!"; # change to
> > Algebra1 sub-directory, then Algebra2, etc.
> > opendir SUB_DIR, "./" or die " cannot open current directory: $!";
> > my $current_sub_directory = cwd;
> > my @sub_directories = grep { !/^\.\.?$/ && -d
> > "$current_sub_directory/$_" } readdir SUB_DIR;
> > map {[ 'cascade', '~'.$_]} @sub_directories;
> > }
> > }
>
> creative use of a sub directory....
>
> from the perldoc -f map
>
> I normally think of 'map' being used in the form
>
> my %retHash = map {[ 'cascade', '~'.$_]} @sub_directories;
>
> at which point I would simply return the Hash
>
> %retHash ;
>
> my other concern is with
>
> map {$mb->cascade(-label => '~'.$_, -menuitems=>\&sub_menu($_))}
> @directories;
>
> wouldn't that be simpler to write as say
>
> $mb->cascade(-label => '~'.$_, -menuitems=>\&sub_menu($_))
> foreach (@directories);
>
> without using the 'map' processeing around it???
>
> ciao
> drieux
>
> ---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]