Click to See Complete Forum and Search --> : array population only works w/o Strict


Ultimater
10-07-2005, 11:53 AM
Full source of my file test123.pl:

#!/usr/bin/perl -w
# use strict;
use CGI qw(:standard);
use warnings FATAL => 'all';
use CGI::Carp qw(fatalsToBrowser);
print header;

our @markings;my $marking;
$body='
<body>
...
<!-- Start marking -->
&lt;data1&gt;
<!-- End marking -->
...
<!-- Start marking -->
&lt;data2&gt;
<!-- End marking -->
...
</body>
';

$marking=$body;
$marking =~ s/<\!--\s*Start\s+marking\s*-->(.*?)<\!--\s*End\s+marking\s*-->/buildMarkingsArray($1)/iegs;
print $markings[0];


sub buildMarkingsArray{
push(@markings, $_[0]);return "";
}

When not using the Strict module, the above prints:

<data1>

like it should and as intended.

When using the Strict module, I get an error:

Software error:

Global symbol "$body" requires explicit package name at /cgi-bin/test123.pl line 9.
Global symbol "$body" requires explicit package name at /cgi-bin/test123.pl line 23.
Execution of cgi-bin/test123.pl aborted due to compilation errors.


My question is how do I revise the above code to work with the Strict module?

Ultimater
10-07-2005, 11:56 AM
Oh wait nevermind, I found the error myself, silly me :D

my $body;