Web Analytics Made Easy -
StatCounter Can't modify not in scalar assignment - perl nooB - CodingForum

Announcement

Collapse
No announcement yet.

Can't modify not in scalar assignment - perl nooB

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't modify not in scalar assignment - perl nooB

    Code:
    !# C:/Perl/bin/perl.exe
    ################################
    # 	Ein plus Ein	       #
    ################################
    
    $age=3;
    
    if ($age >= 18) {
      print "Have a beer\n";
    }
    else {
      print "Have an orange juice\n";
    }
    I have this small piece of code, i am trying to learn Perl.....

    I keep getting this error:

    CGI Error
    The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

    Can't modify not in scalar assignment at c:\inetpub\wwwroot\picco\einplusein.pl line 6, near "3;"
    Execution of c:\inetpub\wwwroot\picco\einplusein.pl aborted due to compilation errors.


    Why is that? I'm not sure what I am doing wrong?

    Any pointers?

    Picco
    Zend Certified Engineer | Ayrshire Minis - a Mini E-Community | Ayrshire-Based Web Developer

  • #2
    You have 2 problems.

    1) Your shebang line is wrong.
    2) You're not printing the html header.
    Code:
    #! C:/Perl/bin/perl.exe
    ################################
    # 	Ein plus Ein	       #
    ################################
    
    $age=3;
    
    print "Content-Type: text/html\n\n";
    
    if ($age >= 18) {
      print "Have a beer\n";
    }
    else {
      print "Have an orange juice\n";
    }

    Comment


    • #3
      Try changing this...

      Code:
      $age=>3;

      Comment


      • #4
        Originally posted by nexus024 View Post
        Try changing this...

        Code:
        $age=>3;
        that's not valid perl syntax in that context.

        Comment

        Working...
        X