automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Current problems


From: Akim Demaille
Subject: Re: Current problems
Date: 26 Feb 2001 14:55:15 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Cuyahoga Valley)

Akim Demaille <address@hidden> writes:

> 2. error messages
>    for some reason I did not track down, am outputs only the suffix
>    (.am), instead of the name of the bad file (Makefile.am).

Tracked down, and I have a fix, but given that I don't understand why
it behaves this way, I'd like some insight from Perl hackers.

At the top level we have:

# Now do all the work on each file.
foreach my $am_file (@input_files)
{
    if (! -f ($am_file . '.am'))
    {
        &am_error ("\`" . $am_file . ".am' does not exist");
    }
    else
    {
        &generate_makefile ($output_files{$am_file}, $am_file);
    }
}

and there is a sub:

# Print an error message and set exit status.
sub am_error
{
    warn "$me: ${am_file}.am: @_\n";
    $exit_status = 1;
}

I can understand above $am_file is local to the loop, so it's wrong,
OK.  But what I don't understand then is that if I move the `my'
before, hence at the top level:

# Now do all the work on each file.
my $am_file;
foreach $am_file (@input_files)
{
    if (! -f ($am_file . '.am'))
    {
        &am_error ("\`" . $am_file . ".am' does not exist");
    }
    else
    {
        &generate_makefile ($output_files{$am_file}, $am_file);
    }
}

then &am_error still cannot see $am_file.  This time I don't
understand.  Sure, it works if $am_file is declared local, but I'd
like to understand why.  It was my understanding that top level `my'
where global to the whole file, so how come am_error does not see it?
How come it works with $me and the other my'd globals?  Is there
anything special about foreach loops?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]