PLEASE HELP ME!!! P E R L!!!

I have a CGI (PERL) file namely 'test.cgi' and it has the correct permission (755) on the FTP server and it is within the CGI path.

I have the following code in it:

===================================
1: #!/usr/bin/perl
2:
3: $cr = '???';
4: $decrypted ="Something";
5: $decrypted =~ s/$cr/\r/g;
6:
7: print $decrypted;
===================================

The code works pretty well when I comment out Line#5 but whenever I want to use Line#5, it throws me the following error!

=========================================
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@wildwildsearch.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
=========================================

Please help me, this is an URGENT. PLEASE PLEASE PLEASE.

You need to print an http header when running scripts in a CGI environment:

1: #!/usr/bin/perl
2:
3: $cr = '???';
4: $decrypted ="Something";
5: $decrypted =~ s/$cr/\r/g;
6: print "Content-type: text/html\n\n";
7: print $decrypted;

use a better subject line in the future. "Please Help Me!!! P E R L!!!" is not appropriate.

You need to print an http header when running scripts in a CGI environment:

1: #!/usr/bin/perl
2:
3: $cr = '???';
4: $decrypted ="Something";
5: $decrypted =~ s/$cr/\r/g;
6: print "Content-type: text/html\n\n";
7: print $decrypted;

use a better subject line in the future. "Please Help Me!!! P E R L!!!" is not appropriate.

It still won't work :(

It's not working because the question mark '?' is a quantifier in a perl regular expression, it means one or zero. You have to escape the ? to treat it as a literal ? instead of a quantifier. You can use the quotemeta option with the regexp:

$cr = '???';
$decrypted ="Something";
$decrypted =~ s/\Q$cr\E/\r/g;
print "Content-type: text/html\n\n";
print $decrypted;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.