Re: how to return an array reference from a subroutine

2002-04-18 Thread drieux
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 { !/^\.\

Re: how to return an array reference from a subroutine

2002-04-18 Thread drieux
On Thursday, April 18, 2002, at 11:21 , Felix Geerinckx wrote: [..] > Personally, however, I prefer an explicit 'return' statement, as in > > return map { ($_ => 1) }, @array; > > (The () are optional). [..] Ok, I can go there... so my test code shows me [jeeves:~/tmp/perl/misc] drieux% p

Re: how to return an array reference from a subroutine

2002-04-18 Thread Felix Geerinckx
on Thu, 18 Apr 2002 18:07:38 GMT, Drieux wrote: > hence > > map {[ 'cascade', '~'.$_]} @sub_directories; > > as the last line of the sub should have returned a 'list' > back to the caller just as the > > sub foo { qw/ 1 2 3 4 5 6 7 8 9 / } ; > > would return a 'list' ??? Yes > >

Re: how to return an array reference from a subroutine

2002-04-18 Thread drieux
On Thursday, April 18, 2002, at 06:05 , Felix Geerinckx wrote: > on Thu, 18 Apr 2002 12:56:43 GMT, [EMAIL PROTECTED] (Richard Noel Fell) > wrote: > >> 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

RE: how to return an array reference from a subroutine

2002-04-18 Thread David Gray
> But, the script below does not work. I get an error message : > Not an ARRAY reference at > /usr/local/ActivePerl-5.6/lib/site_perl/5.6.1/i686-linux-threa > d-multi/Tk/Menu.pm > line 69. The cause of this is the subroutine sub_menu. As I > understand things, the argument to -menuitems must b

Re: how to return an array reference from a subroutine

2002-04-18 Thread richard noel fell
Felix - Thanks for the very clear explanation. Dick Felix Geerinckx wrote: > > on Thu, 18 Apr 2002 12:56:43 GMT, [EMAIL PROTECTED] (Richard Noel Fell) > wrote: > > > However, I do not understand your > > comments about the return value of map. Does not map return a > > reference to

Re: how to return an array reference from a subroutine

2002-04-18 Thread Felix Geerinckx
on Thu, 18 Apr 2002 12:56:43 GMT, [EMAIL PROTECTED] (Richard Noel Fell) wrote: > 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? 'map' returns a *list*. This list can be coerced into an array or int

Re: how to return an array reference from a subroutine

2002-04-18 Thread richard noel fell
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 Wednesda

Re: how to return an array reference from a subroutine

2002-04-17 Thread drieux
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 { !/

how to return an array reference from a subroutine

2002-04-17 Thread richard noel fell
What I am attempting to do is write a perl script that reads the sub-directories of the current directory, creates a menu bar with the sub-directories as the titles of cascade widgets and then goes into the sub-directories, read the files there and creates command widgets with the file names as t