tom arnall wrote:
Global symbol "$fn" requires explicit package name at ./v line 3
where line 3 is:
my $b = `cat $fn`;
is it the case that using a variable as a container for a command line
argument, creates a problem for 'use strict'?
No, it's because you didn't tell the program the $fn was a global before
you used it:
Try:
#!/usr/bin/perl
use strict;
use warnings;
our $fn;
my $b = `cat $fn`;
When Perl "compiles" the program it does it in a top-down fashion. This
means it compiles the line 'my $b = `cat $fn`;' before it compiles the
BEGIN, but it executes the BEGIN before it executes 'my $b = `cat $fn`;'
But that's not the problem, since the error message you got was before
the program was executed; it was given during compilation.
What are you trying to achieve? Are you trying to understand BEGIN or
are you trying to use it in real code? I have been use Perl since Perl 4
and I have never used BEGIN in any real world application. So if you
never figure out how to use it, not worry. The changes of you needing it
are slim.
--
Just my 0.00000002 million dollars worth,
--- Shawn
"For the things we have to learn before we can do them,
we learn by doing them."
Aristotle
"The man who sets out to carry a cat by its tail learns something that
will always be useful and which will never grow dim or doubtful."
Mark Twain
"Believe in the Divine, but paddle away from the rocks."
Hindu Proverb
* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>