I pretty printed for my own sanity:
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 my $lock (@tag_list) {
print "$lock \n" ;
foreach my $tardir (@vbs_list) {
print "$tardir \n" ;
}
}
}
You need to declare the variables referenced in the foreach statements. I
put my in front of both.
The other two errors related to the lines:
my $tag_list ;
my $vbs_list ;
@tag_list = @fields[1] ;
@vbs_list = @fields[2] ;
This is a common mistake for new folks... you're declaring two scalars, but
you're actually assigning into two different arrays.
In perl, $tag_list is a completely different variable than @tag_list. One
is a scalar (single value) and the other is an array. To access an item
within the array, you reference it in a scalar context:
$tag_list = $fields[1];
Hope this helps
Bruce W. Lowther
Micron Technology, Inc.
Boise, Idaho
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 24, 2001 3:41 PM
To: [EMAIL PROTECTED]
Subject: Global symbol requires explicit pack name
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