insensate has asked for the wisdom of the Perl Monks concerning the following question:
Greetings. Once again I humbly request your wisdom. I have a script that is called by a cron that has executed flawlessly for several weeks. Today it did not and exited with the ubiqitous "Global symbol requires explicit package name" error. Below is the code in question and the error. I had to remove some specifics from the code for confidentiality reasons.
Here is today's error:#!/usr/local/bin/perl $|=1; use strict; use File::Basename; use File::Copy; use File::Find; use File::stat; use Getopt::Long; use POSIX qw(strftime); my $pid1; my $pid2; my $pid3; ######################## my @cmd; my $HOME = "/usr/local/SCRIPTS"; if (!defined ($pid1 = fork)) { die "Unable to fork: $!\n"; } elsif (! $pid1) { # this is the branch for the child process my $cmd1 = "$HOME/myscript.sh"; my $out1 = `$cmd1`; exit; } else{ if (!defined ($pid2 = fork)) { die "Unable to fork: $!\n"; } elsif (! $pid2) { # this is the branch for the child process my $cmd2 = "$HOME/myscript.sh"; my $out2 = `$cmd2`; exit; } waitpid($pid1,0); } waitpid($pid2,0); open(LOGFILE,"../LOGS/temp_file_formyscript.txt"); my $flag = 0; my $file1Flag = 0; my $file2Flag = 0; my $logfile1 = ""; my $logfile2 = ""; while(<LOGFILE>) { chomp; if($flag == 0) { $logfile1 = $_; $flag = 1; } if($flag == 1) { $logfile2 = $_; } } open(LOGFILE1,"../LOGS/oldlogs/$logfile1") ; open(LOGFILE2,"../LOGS/oldlogs/$logfile2") ; while(<LOGFILE1>) { chomp; if ($_ =~ /Successfully Completed/i) { $file1Flag = 1; } } while(<LOGFILE2>) { chomp; if ($_ =~ /Successfully Completed/i) { $file2Flag = 1; } } close LOGFILE; close LOGFILE1; close LOGFILE2; if ( ($file1Flag == 1) and ($file2Flag == 1)) { my $cmd3 = "$HOME/myscript.sh"; my $out3 = `$cmd3`; my $cmd4 = "rm ../LOGS/temp_file_formyscript.txt"; my $out4 = `$cmd4`; # print "inside!!\n"; } else { my $msg = "OPEN_FEED_FAILED\n"; my $cmd5 = "mailx \-s \"OPENFEED\" mypager\@skytel.com \< err_m +sg.txt "; my $out5 = `$cmd5`; } exit;
Looking at the code this shouldn't happen, I don't know if perhaps a piece of the script was edited this morning then changed back...but a perl -c seems to check out fine...any insight would be greatly appreciated. JasonGlobal symbol "$cmd3" requires explicit package name at myscript line +88. Execution of myscript aborted due to compilation errors.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Variable Scope Issue?
by Biker (Priest) on Apr 19, 2002 at 19:30 UTC | |
by insensate (Hermit) on Apr 19, 2002 at 19:41 UTC | |
Re: Variable Scope Issue?
by JayBonci (Curate) on Apr 19, 2002 at 20:49 UTC | |
Re: Variable Scope Issue?
by RMGir (Prior) on Apr 19, 2002 at 20:46 UTC |
Back to
Seekers of Perl Wisdom