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

Hi i am new to Perl programming. I am writing the HTML and jquery in the code. I am not able to figure out why the HTML part is not working. Here is the code:
#!/usr/bin/perl use warnings; use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); my $cgi = CGI->new; #print $cgi->redirect(-location=>'test1.cgi'); print $cgi->header( -type=> "text/html" ); print <<EOF; <!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquer +y.min.js"></script> <script> var embeddedVideo = { requestVID : function() { $.ajax({ url:"serve.cgi", success: function () { alert("done"); }, }).fail(function( jqXHR, textStatus, errorThrown ) { console.l +og(textStatus,errorThrown)}); }, }; $(document).ready(function(){ embeddedVideo.requestVID(); }); </script> </head> </html> EOF
In the log it is writing like
Use of uninitialized value $. in concatenation (.) or string at /usr/ +lib/cgi-bin/test.cgi line 13.
Please tell me where it is going wrong.I don't get any useful information relating to this.And i am not sure how to make it working. Any help will be appreciated.Thanks in advance

Replies are listed 'Best First'.
Re: what is this error means Use of uninitialized value $. in concatenation (.) or string
by Corion (Patriarch) on Feb 07, 2016 at 09:44 UTC

    $. is a variable in Perl. See perlvar.

    You are interpolating this variable in the string $.ajax(.... I recommend putting Javascript in a separate file and reading it from Perl, or alternatively using a non-interpolating here-document:

    print <<'EOF'; This costs many $$$ EOF
Re: what is this error means Use of uninitialized value $. in concatenation (.) or string
by martin (Friar) on Feb 07, 2016 at 10:48 UTC

    The HTML code following after the line print <<EOF; is not properly quoted. You should write that line as:

    print <<'EOF';
    to prevent perl from interpolating $. and $( as variables.