Click here to get back home

BEGIN not safe after errors--compilation aborted

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
BEGIN not safe after errors--compilation aborted daz9643 02-22-2008
Posted by daz9643 on February 22, 2008, 11:26 am
Please log in for more thread options
I've got 2 perl scripts, both are code for ads. One script is admob,
the other is google. The code provided has been cut and pasted without
any mods. The admob code works, the google code doesn't and i get the
error,
syntax error at googleperlcode.cgi line 9, near "sub
google_append_color "
Can't use global @_ in "my" at googleperlcode.cgi line 10, near ", $_"
syntax error at googleperlcode.cgi line 12, near "}"
Execution of googleperlcode.cgi aborted due to compilation errors.

This is the actual google code,
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
ul class="simpleblue"
sub google_append_color {
my @color_array = split(/,/, $_[0]);
return $color_array[$_[1] % @color_array];
}

Anyone know why the errors ? Both files end in .cgi and both have the
permissions set the same, i.e 755. Both are in the same directory on
the server.

Posted by J. Gleixner on February 22, 2008, 11:55 am
Please log in for more thread options
daz9643 wrote:
> I've got 2 perl scripts, both are code for ads. One script is admob,
> the other is google. The code provided has been cut and pasted without
> any mods. The admob code works, the google code doesn't and i get the
> error,
> syntax error at googleperlcode.cgi line 9, near "sub
> google_append_color "
> Can't use global @_ in "my" at googleperlcode.cgi line 10, near ", $_"
> syntax error at googleperlcode.cgi line 12, near "}"
> Execution of googleperlcode.cgi aborted due to compilation errors.
>
> This is the actual google code,
> #!/usr/bin/perl
> use CGI::Carp qw(fatalsToBrowser);
> ul class="simpleblue"
^^^^^^^^^^^^^^^^^^^^^^
Does that look at all like it's valid syntax?

> sub google_append_color {
> my @color_array = split(/,/, $_[0]);
> return $color_array[$_[1] % @color_array];
> }
>
> Anyone know why the errors ? Both files end in .cgi and both have the
> permissions set the same, i.e 755. Both are in the same directory on
> the server.

Posted by Tad J McClellan on February 22, 2008, 10:43 pm
Please log in for more thread options


> syntax error at googleperlcode.cgi line 9, near "sub
^^^^^^
^^^^^^
> This is the actual google code,


I do not believe you.


> #!/usr/bin/perl
> use CGI::Carp qw(fatalsToBrowser);
> ul class="simpleblue"
> sub google_append_color {
> my @color_array = split(/,/, $_[0]);
> return $color_array[$_[1] % @color_array];
> }


There is no line 9 in your 7 line program...


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"

Posted by daz9643 on February 23, 2008, 1:17 pm
Please log in for more thread options
ok ,the actual google code does not include the lines
use CGI::Carp qw(fatalsToBrowser);
ul class="simpleblue"

these to lines were just added to help with debugging. Without these 2
lines i just get the error 500.
You're right about line 9, there were a few blank lines in the code
which i've deleted as they weren't necessary. If i remove the
offending line of code or rem it out the error just points to the next
line of code and so on.

Posted by Ron Bergin on February 23, 2008, 3:46 pm
Please log in for more thread options
wrote:
> ok ,the actual google code does not include the lines
> use CGI::Carp qw(fatalsToBrowser);
> ul class="simpleblue"
>
> these to lines were just added to help with debugging. Without these 2
> lines i just get the error 500.
> You're right about line 9, there were a few blank lines in the code
> which i've deleted as they weren't necessary. If i remove the
> offending line of code or rem it out the error just points to the next
> line of code and so on.

Well, it's pretty obvious that this line:

> ul class="simpleblue"

will generate an error.

Comment out that line and retest. If if fails, then post the exact
error message and the EXACT code that you tested, but only upto a
couple lines after the reported line in the error messages.

Similar ThreadsPosted
How safe is $0? August 24, 2007, 6:00 am
Is LWP thread-safe? February 10, 2005, 5:28 am
Checking for safe paths March 9, 2005, 7:59 pm
Safe Merge module March 31, 2006, 7:53 pm
safe-module and namespaces May 31, 2006, 8:05 am
BEGIN <> BEGIN May 31, 2006, 5:32 am
Safe Pipe Open question March 21, 2006, 8:00 pm
Q on BEGIN and INIT April 19, 2005, 3:05 pm
Where to begin with Perl 6 September 5, 2005, 11:03 am
BEGIN { package Foo; use Foo } December 24, 2005, 6:49 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap