conflicting errors



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?

.



Relevant Pages

  • Re: What is the need for @ symbol in php script
    ... The '@' just suppresses error messages, which is never a good idea ... A fatal error will ALWAYS stop your script from working - that's why ... Hardly cumbersome, compared to managing code with list, and ... extractfunction makes the process easier. ...
    (comp.lang.php)
  • Re: Toward smarter Layouts
    ... composing SQL record descriptions. ... This is a ruddy nightmare vis a vis maintenance. ... explicitly nailing down every detail on every declaration. ... It becomes the component's job to provide error messages for the ...
    (comp.lang.java.gui)
  • Re: IE Wont Open
    ... notification about every script error." ... Open Internet Explorer. ... Two download versions are available for Windows Script 5.6. ... please post back to this thread with the details and any error messages. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: IE Crashes when loading page with javascript
    ... See these articles for possible help w/ error messages in scripting: ... Error Message When You Browse the Web: An Error Has Occurred in the Script ... Windows Script 5.7 for Windows XP ... updates/security roll-ups, etc. from Windows Update. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: IE Crashes when loading page with javascript
    ... See these articles for possible help w/ error messages in scripting: ... Error Message When You Browse the Web: An Error Has Occurred in the Script ... Windows Script 5.7 for Windows XP ... updates/security roll-ups, etc. from Windows Update. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)