sureshsmr has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I need some advise to fix the error I am getting while running a perl code with a subprogram. Here is the perl sub program :
sub CREATE_GLOBAL_PTF_VIA_PTFMGR { my $pnum = (@_[0]); ##part number passed arg @_ into local var p +num my $coreid = (@_[1]); #use XML::Simple; #use HTTP::Response; #use LWP::UserAgent; my $ptfmgr_server= "v02k603.am.mot.com:9090/pcs/"; ############## Call to PTF web services for description informatio +n ############# my $url = "http://$ptfmgr_server/services/GenerateGlobalPtf?coreid +=$coreid&partNumber=$pnum"; my $ua= new LWP::UserAgent; #my $ua->agent("Mozilla/5.0"); my $ua->agent(""); my $request = new HTTP::Request GET => "$url"; my $response = $ua->request($request); my $ptf_filename; my $log = "" if ( $response->is_success ) { my $content= $response->content; #print "\$content = $content\n"; ############## Read XML information ############# my $xml = new XML::Simple(suppressempty => ''); ### create obj +ect suppressempty returns empty elements as strings. my $data = $xml->XMLin($content); ### read XML file my $return_value = $data->{ReturnValue}; my $ptfmgr_error = $data->{Error}; my $ptf_filename = $data->{PtfFileName}; #print "\$return_value = $return_value\n"; #if ( $return_value == "1" ) { # my $log = "\sGlobal PTF generation to \"$ptf_filename\" w +as successful.\n"; #} else { # my $log = "\sPTFMGR returned the error:\n\n$ptfmgr_erro +r\n\nGlobal PTF not created for $ptf_filename.\n."; #} #} else { # my $log = "\sCould not create PTF via PTFMGR! It may be o +ffline.\n"; # } } return $ptf_filename; }
This is the error I get while running it:
/usr/local/bin/perl PtfSapGetSyncStg.pl syntax error at PtfSapGetSyncStg.pl line 164, near ") {" Global symbol "$ptf_filename" requires explicit package name at PtfSap +GetSyncStg.pl line 184. syntax error at PtfSapGetSyncStg.pl line 185, near "}" Execution of PtfSapGetSyncStg.pl aborted due to compilation errors. v02k603:/edatools/served/pcs/ptfwes>
The syntax looks ok to me. May be the error is due to something else. I am running this on a unix server. Look forward to your advice. Thanks in advance, Yours Suresh
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Question regarding perl subroutine
by davies (Prior) on Jul 15, 2012 at 20:38 UTC | |
by sureshsmr (Initiate) on Jul 15, 2012 at 21:07 UTC | |
by afoken (Chancellor) on Jul 15, 2012 at 21:11 UTC | |
by davies (Prior) on Jul 15, 2012 at 21:28 UTC | |
by monsoon (Pilgrim) on Jul 15, 2012 at 21:18 UTC | |
Re: Question regarding perl subroutine
by AnomalousMonk (Archbishop) on Jul 15, 2012 at 21:42 UTC |
Back to
Seekers of Perl Wisdom