perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bengt Rasmusson" <ben...@kabkonsult.se>
Subject Global 'use strict' in 2.x once again
Date Tue, 05 Aug 2003 09:01:07 GMT
Hello,

I'm trying to enforce 'use strict' in in all parts of a page. My page looks
like this:

<html><head><title>test</title></head>
<body>
[-
use strict;
use DBI;
use vars qw (@connection_string $dsn $user_name $password $dbh
$sth_rubriker);
...
$dbh = DBI->connect($dsn, $user_name, $password,{ RaiseError => 1 });
$sth_rubriker = $dbh->prepare("SELECT id, rubrik FROM tbltest1 ORDER BY
sort");
$sth_rubriker->execute();
-]
[$ while $dat_rubriker = $sth_rubriker -> fetchrow_hashref $]

...

	[-
	$sth_count_links = $dbh->selectrow_array("SELECT count(*) FROM tbltest1
WHERE rubrikid = @$dat_rubriker{id}");
	-]

...

[- $dbh->disconnect -]
</body>
</html>

The 'use strict' works in the first [- ... -] -block but *not* in the
following blocks (e.g. not in [$ while ... $] or [- $sth_count_links
... -]).

I read the thread
http://www.gossamer-threads.com/perl/mailarc/gforum.cgi?post=24546;search_st
ring=use%20strict;guest=949949&t=search_engine#24546 and so I added [$ var
$dummy $] before all epl-code. And then it seemed to work, but it works in a
strange way:

The first time I open the page after adding the [$ var $dummy $], I get an
expected error-message saying:

[114]ERR: 32: Warning in Perl code: Variable "$dat_rubriker" is not imported
at [...]/lankar_test.epl line 35.
[114]ERR: 32: Warning in Perl code: Variable "$dat_rubriker" is not imported
at [...]/lankar_test.epl line 37.
[114]ERR: 32: Warning in Perl code: Variable "$sth_count_links" is not
imported at [...]/lankar_test.epl line 44.
[114]ERR: 32: Warning in Perl code: Variable "$dat_rubriker" is not imported
at [...]/lankar_test.epl line 44.
[114]ERR: 32: Warning in Perl code: Variable "$dat_rubriker" is not imported
at [...]/lankar_test.epl line 48.

[114]ERR: 24: Error in Perl code: Global symbol "$dat_rubriker" requires
explicit package name at [...]/lankar_test.epl line 35.
    Global symbol "$dat_rubriker" requires explicit package name at
[...]/lankar_test.epl line 37.
    Global symbol "$sth_count_links" requires explicit package name at
[...]/lankar_test.epl line 44.
    Global symbol "$dat_rubriker" requires explicit package name at
[...]/lankar_test.epl line 44.
    Global symbol "$dat_rubriker" requires explicit package name at
[...]/lankar_test.epl line 48.

If I then refresh the page once or twice, the error-message looks like this
instead:

[114]ERR: 24: Error in Perl code: Global symbol "$dat_rubriker" requires
explicit package name at [...]/lankar_test.epl line 35.
    Global symbol "$dat_rubriker" requires explicit package name at
[...]/lankar_test.epl line 37.
    Global symbol "$sth_count_links" requires explicit package name at
[...]/lankar_test.epl line 44.
    Global symbol "$dat_rubriker" requires explicit package name at
[...]/lankar_test.epl line 44.
    Global symbol "$dat_rubriker" requires explicit package name at
[...]/lankar_test.epl line 48.

If I go on refreshing the page, the error-message looks like this:

[114]ERR: 32: Warning in Perl code: Variable "$sth_count_links" is not
imported at [...]/lankar_test.epl line 44.
[114]ERR: 24: Error in Perl code: Global symbol "$sth_count_links" requires
explicit package name at [...]/lankar_test.epl line 44.

And then I can go on refreshing the page, and the error-message alternates
between these three versions. That is strange, especially that the third
version doesn't warn about the variable $dat_rubriker.

Can anyone explain this behaviour? Is there a better way to enforce 'use
strict' for a whole page? I am using Apache/1.3.27 (Unix), Embperl/2.0b8,
and mod_perl/1.27.

Best,
Bengt




---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message