Timothy -
Yes, I have done a "print @test_files" and it is as expected.
Dick
Timothy Johnson wrote:
>
>
> Have you tried doing a "print @test_files;"? It looks to me like there
> wouldn't be any files in the array because readdir(TESTS_DIR) would return
> only the file names, not the full paths, so "grep {-f "$tests_directory/$_"}
> readdir TESTS_DIR;" might not be returning anything. But then again I'm not
> a huge grep user, so I could be wrong.
>
> -----Original Message-----
> From: richard noel fell
> To: [EMAIL PROTECTED]
> Sent: 4/23/02 7:44 AM
> 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]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]