How to fix the syntax error issue ?

Discussion in 'Perl' started by citiwang, May 24, 2011.

  1. citiwang

    citiwang New Member

    Joined:
    May 18, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    ##### choosing which file type #################
    print "Please Choose Solution ? \n" ;
    print " 1) Please Input An filename ? \n" ;
    print " 2) Summation Daily Total Counts  \n" ;
    chomp ($line = <ftype>);
    if ("$ftype" == "1") {
            print "Please input filename and file path \n" ;
            chomp ($line1 = <filepath>);
    }
            if ( ! -e "$filepath" ) {
                    print "************************************" ;
                    print "*****Shit!! File does not exist*****" ;
                    print "************************************" ;
                    exit 1;
    }
    @datatype = ('split','licenceCounter','cdrsReceivedTotSum','cdrsCombinedSum','cdrsAggregatedSum');
        foreach (@datatype) {
             print $i;
                    `gzcat $filepath | grep $i  >> $tmp_folder/$i."log"`;
    }
    elsif ("$ftype" == "2") {
            print " Please input date for processing \n";
            chomp ($line2 = <filedate>);  # ch_server
            print " Please input path \n";
            chomp ($line3 = <datepath>);
            $datefile =`ls -al $datepath/PM.$hostip.$filedate.*.xml.gz | wc -l`;
            if ( "$datefile" == "0" ) {
                    print "Sorry !! There are no PM files under $datepath" ;
                    exit 1 ;
    }
    @datatype = ('split','licenceCounter','cdrsReceivedTotSum','cdrsCombinedSum','cdrsAggregatedSum');
        foreach (@datatype) {
             print $i;
                   `gzcat $datepath/PM.$hostip."$filedate.\*"."xml.gz" |grep $i  >> $tmp_folder/$i."log"`;
    }
    else {
            print "Sorry!! You don't give me the right command" ;
    }
    syntax error at test.pl line 25, near "elsif"
    syntax error at test.pl line 30, near "else"
    Missing right curly or square bracket at test.pl line 32, at end of line
     
    Last edited by a moderator: May 24, 2011
  2. sreek

    sreek New Member

    Joined:
    Nov 15, 2010
    Messages:
    11
    Likes Received:
    2
    Trophy Points:
    0
    I think your brackets are mis
    Code:
    
    
    aligned and indentation problem also.
    Is this what you implied in code?

    Code:
    ##### choosing which file type #################
    print "Please Choose Solution ? \n" ;
    print " 1) Please Input An filename ? \n" ;
    print " 2) Summation Daily Total Counts  \n" ;
    chomp ($line = <ftype>);
    if ("$ftype" == "1") {
            print "Please input filename and file path \n" ;
            chomp ($line1 = <filepath>);
            if ( ! -e "$filepath" ) {
                    print "************************************" ;
                    print "*****Shit!! File does not exist*****" ;
                    print "************************************" ;
                    exit 1;
    	}
    	@datatype = ('split','licenceCounter','cdrsReceivedTotSum','cdrsCombinedSum','cdrsAggregatedSum');
    	foreach (@datatype) {
    		 print $i;
                    `gzcat $filepath | grep $i  >> $tmp_folder/$i."log"`;
    	}
    }
    elsif ("$ftype" == "2") {
            print " Please input date for processing \n";
            chomp ($line2 = <filedate>);  # ch_server
            print " Please input path \n";
            chomp ($line3 = <datepath>);
            $datefile =`ls -al $datepath/PM.$hostip.$filedate.*.xml.gz | wc -l`;
            if ( "$datefile" == "0" ) {
                    print "Sorry !! There are no PM files under $datepath" ;
                    exit 1 ;
    	}
    	@datatype = ('split','licenceCounter','cdrsReceivedTotSum','cdrsCombinedSum','cdrsAggregatedSum');
    	foreach (@datatype) {
    		print $i;
                   `gzcat $datepath/PM.$hostip."$filedate.\*"."xml.gz" |grep $i  >> $tmp_folder/$i."log"`;
    	}
    }
    else {
            print "Sorry!! You don't give me the right command" ;
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice