This is an embarrassing question to ask but why does this line work while the other doesn't?
Working line:
use strict;
use warning;
use Wx qw(:everything);
my $dialog = Wx::MessageDialog->new(
$self,
"About test\n" . "Version 0.01\n",
"About Test",
wxOK | wxCENTRE
);
Non-working line:
use strict;
use warning;
use Wx;
my $dialog = Wx::MessageDialog->new(
$self,
"About test\n" . "Version 0.01\n",
"About Test",
wxOK | wxCENTRE
);
Error message, from non-working line:
Bareword "wxOK" not allowed while "strict subs" in use at test.pl line 123.
Bareword "wxCENTRE" not allowed while "strict subs" in use at test.pl line 123.
BEGIN not safe after errors--compilation aborted at test.pl line 348.
It is the equivalent of this:
That code will import ':everything' from Wx into the current namespace. My guess is that Wx uses Exporter and has a group of things to import when called with ':everything'.
You can check the Wx's source and Exporter's source to try to make more sense of it.
I missed your working/non-working example. The non-working one doesn't work because the
wxOK
andwxCENTRE
constants are not imported into the current namespace. This is done using Exporter, as explained above.