how are using this subroutine in your code? Can you give us the line where you use this sub, Tk is bit picky at times when you try funky things.
> -----Original Message----- > From: richard noel fell [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, April 23, 2002 10:45 AM > To: [EMAIL PROTECTED] > Subject: variable not set as expected > > > Below is a subroutine that is part of a perl/Tk script. The variable > $test_path is initialized earlier to the empty string and the variable > $tests_directory is likewise initialized to the correct directory. The > array @test_files contains entries such as (test1, test2, ..) and is > correctly set by the subroutine. The problem comes with -command=>sub > {$test_path="$tests_directory/$_"; print "$test_path\n";} > $test_path is > not set to $test_directory/test1, $test_directory/test2, but only to > $test_directory, as if @test_files were empty, which is not > the case. > Thanks for any advice, > Dick Fell > > > sub tests_menu > { > opendir TESTS_DIR, $tests_directory or die " cannot open Tests > directory: $!"; > my @test_files = grep {-f "$tests_directory/$_"} readdir > TESTS_DIR; > [map {[ 'command', $_,-command=>sub > {$test_path="$tests_directory/$_"; > print "$test_path\n";}]} @test_files]; > } > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > ---------------------------------------------------------------------------- -------------------- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]