Hi,
The error message you're getting is one of the many changes to the
nature of perl under strict. It usually means that the variable in
question needs to be either explicitely named (via
$::Package::Variable) or lexically scoped (via my, our, or use vars).
you've made a couple errors here, which are only raised using strict.
> my $tag_list ;
> my $vbs_list ;
> @tag_list = @fields[1] ;
> @vbs_list = @fields[2] ;
Here, you've pre-declared a SCALAR variable $tag_list and two line later
you're using an ARRAY (list) variable to hold the results.
Additionally, when you refer to @fields[1] you are probably trying to
refer to $fields[1] (because when you refer to a slice of an array, you
need to in a scalar fashion. (think - an array is two dimensional, but
the slice to which you refer is only one value)
so change that to my $tag_list = $fields[1]; you can declare with my at
the same time as assigning the initial value, in this case the second
slice of @fields. (the first slice is $fields[0])
Next, in the line:
foreach $lock (@tag_list) {
It is not being declared or scoped, try:
foreach my $lock (@tag_list) {
(there's a few more just like that that you need to change)
You'll need to scope each of your variables when running under strict,
which is a better programming habit, and one of the many reasons it's
reccommended to use strict.
Hope that helps,
--A
[EMAIL PROTECTED] wrote:
>
> All,
> When I use strict function, I get an error in the following code.
> #!/usr/local/bin/perl
> use strict ;
> my @vob_list = `cleartool lsvob | grep "*"`;
> my $entry ;
> foreach $entry (@vob_list) {
> chomp $entry;
> my @fields = split /\s+/, $entry;
> my $tag_list ;
> my $vbs_list ;
> @tag_list = @fields[1] ;
> @vbs_list = @fields[2] ;
> foreach $lock (@tag_list) {
> print "$lock \n" ;
> foreach $tardir (@vbs_list) {
> print "$tardir \n" ;
> }
> }
> }
>
> Global symbol "tag_list" requires explicit package name at ./back.pl line 10.
> Global symbol "vbs_list" requires explicit package name at ./back.pl line 11.
> Global symbol "lock" requires explicit package name at ./back.pl line 12.
> Variable "@tag_list" is not imported at ./back.pl line 12.
> Global symbol "tag_list" requires explicit package name at ./back.pl line 12.
> Variable "$lock" is not imported at ./back.pl line 13.
> Global symbol "lock" requires explicit package name at ./back.pl line 13.
> Global symbol "tardir" requires explicit package name at ./back.pl line 14.
> Variable "@vbs_list" is not imported at ./back.pl line 14.
> Global symbol "vbs_list" requires explicit package name at ./back.pl line 14.
> Variable "$tardir" is not imported at ./back.pl line 15.
> Global symbol "tardir" requires explicit package name at ./back.pl line 15.
> Execution of ./back.pl aborted due to compilation errors.
>
> I get this error only when I use the strict function, so I figured that this is
> not an efficient code. Can somebody help me on this ?
>
> Thx in advance
> Kailash