in reply to Re: Use of uninitialized value in concatenation (.) or string
in thread Use of uninitialized value in concatenation (.) or string

After adding use strict and correcting all the typos (steps), I got this error:
Global symbol "@steps" requires explicit package name.
What does "use strict" do and in this case should I make @steps local?
  • Comment on Re^2: Use of uninitialized value in concatenation (.) or string

Replies are listed 'Best First'.
Re^3: Use of uninitialized value in concatenation (.) or string
by jwkrahn (Abbot) on Aug 23, 2009 at 23:07 UTC

    Use my in the proper scope to create the @steps variable.

Re^3: Use of uninitialized value in concatenation (.) or string
by Marshall (Canon) on Aug 24, 2009 at 09:18 UTC
    use strict; is a pragma that enforces lexical scoping of variables. With some very unusual exceptions, this is just a "compile time" deal. There are "our" vars (package scope) and "local" vars. Use strict and my $vars until you are very sure about why you should use one of these other forms.

    Something like this is almost always wrong in Perl (almost always doesn't mean always, it just means almost:

    for ($i=0;$i<=$#steps;$i++){}
    my @steps = (..list of some stuff.....); foreach my $step (@steps) { ..use $step...here... no $i index needed.. }