I'm writing a script that maps out a file system. Here is what I have so far:
#!/usr/bin/perl -w use strict; #use Data::Dumper; sub data_for_path { my $path = shift; if (-f $path or -l $path) { return undef; } if (-d $path) { my %directory; opendir PATH, $path or die "Cannot opendir $path: $!"; my @names = readdir PATH; closedir PATH; for my $name (@names) { next if $name eq '.' or $name eq '..'; $directory{$name} = data_for_path("$path/$name"); } return \%directory; } warn "$path is neither a file nor a directory\n"; return undef; } #print Dumper(data_for_path("..")); my $filesystem_ref = data_for_path("..") foreach (keys %$filesystem_ref) { if ( $filesystem_ref->[$_] = undef) { print $_."\n"; } } If I run the script, I get the following error messages: Global symbol "$filesystem_ref" requires explicit package name at filesystem.pl line 30. syntax error at filesystem.pl line 30, near ") {" Global symbol "$filesystem_ref" requires explicit package name at filesystem.pl line 31. Execution of filesystem.pl aborted due to compilation errors. However if I put a 'my' in front of $filesystem_ref at the line numbers indicated in the error message, I get the following error message: "my" variable $filesystem_ref masks earlier declaration in same statement at filesystem.pl line 30. "my" variable $filesystem_ref masks earlier declaration in same statement at filesystem.pl line 31. Can't declare hash dereference in my at filesystem.pl line 30, near "$filesystem_ref) " syntax error at filesystem.pl line 30, near ") {" Can't use global $_ in "my" at filesystem.pl line 31, near "[$_" Execution of filesystem.pl aborted due to compilation errors. Now I'm just confused. What's up with these conflicting error messages? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/