You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Bengt Rasmusson <be...@kabkonsult.se> on 2003/08/05 11:01:07 UTC
Global 'use strict' in 2.x once again
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
Re: Global 'use strict' in 2.x once again
Posted by Gerald Richter <ri...@ecos.de>.
>
> The first time I open the page after adding the [$ var $dummy $], I get an
> expected error-message saying:
>...
>
> If I then refresh the page once or twice, the error-message looks like this
> instead:
>
This is because the page isn't recompiled and Embperl isn't able to save all
of the error message. As soon as you change the file, Embperl recompiles it
and you will get again all error messages.
>
> 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.
>
If you continue to refresh you will hit a new apache child form time to time,
which will recompile the file and show all the messages again.
Hope this helps
Gerald
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org