http://www.perlmonks.org?node_id=1024983

manishrathi has asked for the wisdom of the Perl Monks concerning the following question:

I get following error when I run the code below it. I don't seem to find error. Please let me know whats wrong in here

D:\Interwoven\TeamSite\iw-perl\bin>iwperl D:\Interwoven\TeamSite\custom\tsadm\testFile3.pl
Global symbol "$cmd" requires explicit package name at D:\Interwoven\TeamSite\custom\tsadm\testFile3.pl line 32.
Global symbol "@output" requires explicit package name at D:\Interwoven\TeamSite\custom\tsadm\testFile3.pl line 33.
Global symbol "$cmd" requires explicit package name at D:\Interwoven\TeamSite\custom\tsadm\testFile3.pl line 33.
Global symbol "$rc" requires explicit package name at D:\Interwoven\TeamSite\custom\tsadm\testFile3.pl line 35.
Global symbol "@output" requires explicit package name at D:\Interwoven\TeamSite\custom\tsadm\testFile3.pl line 37.
Global symbol "$rc" requires explicit package name at D:\Interwoven\TeamSite\custom\tsadm\testFile3.pl line 43.
Execution of D:\Interwoven\TeamSite\custom\tsadm\testFile3.pl aborted due to compilation errors.

use warnings; #use strict; use strict; use TeamSite::Config; use TeamSite::WFtask; use TeamSite::WFworkflow; #--------------------------------------------------------------------- # Workflow variables # (my $iwhome = TeamSite::Config::iwgethome()) =~ tr|\\|/|; (my $iwmount = TeamSite::Config::iwgetmount()) =~ tr|\\|/|; my @tmp_home = split("/TeamSite",$iwhome); $iwhome = $tmp_home[0]; my ($jobid, $taskid, $area ) = (shift, shift, shift); #my $task = TeamSite::WFtask->new($taskid); my $task = new TeamSite::WFtask($taskid); my $taskname=$task->GetName(); $area =~ tr |\\|/|; my $branch = $area; $branch =~ /default\\main\\(.*)\\WORKAREA/; $branch = $1; my @workArea =split("/",$area); my $source; my $target_production; my $path; my $od_conf; my $execute_cmd = 1; # $filelist = "C:\\Users\\Administrator\\Desktop\\Test\\printFile.txt" +; $cmd = "D:\\Interwoven\\OpenDeployNG\\bin\\iwodcmd start D:\\Interwove +n\\OpenDeployNG\\conf\\tsadm\\test_jignesh"; @output = `$cmd`; $rc = $?; my $success_flag = 0; foreach (@output) { $success_flag = 1 if (/ERROR/i); $success_flag = 1 if (/Status: Failed/i); } # Check for the success/failure of the deployment process. if ($rc eq "0" && $success_flag != 1) { print "<b>Your Files have been deployed Successfully.</b> <br> +<br>"; #print "Below is output... <br><br>"; #print "@output <br>"; # Deployment successful... transition to closure $task->CallBack(0, "Completed Deploy Process"); } else { print "<b>Deployment Failed</b>. <br><br>"; print "Please Contact TeamSite Admin with the following error. +.. <br><br>\@output"; print "<br><br><br>"; # Deployment failed... Do not close this job. print "<b>Your Job is still active. To initiate deployment aga +in, you can switch to 'Workflow' tab and use the existing job</b><br> +<br>"; $task->CallBack(1, "Deployment Failed"); } # $filelist = "C:\\Documents and Settings\\Administrator\\Desktop\\tes +t\\printFile.txt"; # # print "FileList : ". $filelist; # # my @files = (file1, file2, file3); # open(WRITEFILE, ">$filelist") || die("ERROR: unable to open file: $ +! \n"); # select WRITEFILE; # foreach my $file (@files){ # print WRITEFILE "$file\n"; # } # close WRITEFILE;
I found it, I put "my" before these variables. Those eror are gone. Now I m getting following errors

D:\Interwoven\TeamSite\iw-perl\bin>iwperl D:\Interwoven\TeamSite\custom\tsadm\te stFile3.pl
Use of uninitialized value in transliteration (tr///) at D:\Interwoven\TeamSite\ custom\tsadm\testFile3.pl line 19.
Use of uninitialized value in pattern match (m//) at D:\Interwoven\TeamSite\cust om\tsadm\testFile3.pl line 21.
Use of uninitialized value in split at D:\Interwoven\TeamSite\custom\tsadm\testF ile3.pl line 23.

Locating OpenDeploy service.
Got OpenDeploy service
>>>>>-- Start deployment D:\Interwoven\OpenDeployNG\conf\tsadm\test_mr.
iwodstart running in default synchronous mode.
Need to wait for deployment to complete.
***ERROR - Starting deployment.
Reason from server: DEPLOY_CONFIG_FILE
Details : Deployment config file not found (D:\Interwoven\OpenDeploy NG\conf\D:\Interwoven\OpenDeployNG\conf\tsadm\test_jignesh.xml)
Deployment Failed.

Please Contact TeamSite Admin with the followi ng error...

@output


Your Job is still active. To initiate deployment again, you can switch to 'Workflow' tab and use the existing job

Task 1 does not exist. ERROR:00920: Object being looked up was not found

Replies are listed 'Best First'.
Re: Code is giving "explicit package name required" error
by SuicideJunkie (Vicar) on Mar 22, 2013 at 21:48 UTC
    Global symbol "$cmd" requires explicit package name at D:\Interwoven\TeamSite\custom\tsadm\testFile3.pl line 32.

    That means you have a variable "$cmd" on line 32, which you failed to declare with my $cmd or a similar statement.

    You've already got a bunch of variables declared at the beginning, so you just forgot to declare this one.

    EDIT:

    Please don't remove your existing text. Append to it with an edit mark, or if the problem is sufficiently different, it may be appropriate to start a new SoPW.

    ***ERROR - Starting deployment. Reason from server: DEPLOY_CONFIG_FILE Details : Deployment config file not found (D:\Interwoven\OpenDeploy NG\conf\D:\Interwoven\OpenDeployNG\conf\tsadm\test_jignesh.xml)

    This has nothing to do with perl. It looks like your config file name got mangled as it has two drive letters in it.

      > > Global symbol "$cmd" requires explicit package name at ...

      > That means you have a variable "$cmd" on line 32, which you failed to declare with my $cmd or a similar statement.

      I wonder if nowadays the error message shouldn't be updated to something "requires explicit package name or lexical "my" declaration ..."

      Lexicals replaced package vars as a standard long ago, maybe the feedback should reflect the most probable cause.

      I'm aware that changing the message might confuse some parsers, but it's such a common question here that it's worth a rethink.

      Cheers Rolf

      ( addicted to the Perl Programming Language)