On 09/21/2006 10:25 AM, Tony Frasketi wrote:
Hello list.
I'm getting the following error message when compiling the program listed below ...

  Bad name after c' at /test/test1.cgi line 22.

line 22 is  '   s/%(..)/pack('c', hex($1))/eg;'

Need help in eliminating this error!
thnx
tony

=========
#!/usr/local/bin/perl -w

use strict;

# Enable HTTP output
print("Content-type: text/html\n\n");

my $url = "nice.cgi?a=b+c+d&x=a+m";
my $x = &decodeURL($url);
print 'x[$x]<br>";


Use a programmer's editor that has syntax highlighting. The /second/ I pasted your code into VIM, I saw the problem. That print statement's string is not terminated correctly. You start the string with a single-quote, but you end it with a double-quote--so the string never really ends until you get to the single-quote in the pack statement below.

exit;


#-------------------------------------------------------------
# Decode the URL
# &decoded_url = &decodeURL($url);
#-------------------------------------------------------------
sub decodeURL {
  $_ = shift;
  tr/+/ /;
  s/%(..)/pack('c', hex($1))/eg;
  return($_);
}


HTH


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to