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


In reply to Question regarding perl subroutine by sureshsmr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.