H
H. Wade Minter
I'm taking time and cleaning up my Perl/Tk application to run under
"use strict", which has been fun and productive, and also revealed some
bad code that I've rewritten. So, cool.
I have a question on one thing, though, and didn't see an answer by
Googling. My code is designed on Linux but also runs on Windows via
checks of $^O. So, to import Windows-specific modules, I do this:
if ( "$^O" eq "MSWin32" )
{
$rcfile = "C:\\mrvoice.cfg";
BEGIN
{
if ( $^O eq "MSWin32" )
{
require LWP::UserAgent;
LWP::UserAgent->import();
require HTTP::Request;
HTTP::Request->import();
require Win32:rocess;
Win32:rocess->import();
require Tk::Radiobutton;
Tk::Radiobutton->import();
require Win32::FileOp;
Win32::FileOp->import();
require Audio::WMA;
Audio::WMA->import();
}
}
}
Then, later in the code, I use an imported constant like:
if ( "$^O" eq "MSWin32" )
{
# Start the MP3 player on a Windows system
my $object;
Win32:rocess::Create( $object, $config{'mp3player'}, '', 1,
NORMAL_PRIORITY_CLASS, "." );
$mp3_pid = $object->GetProcessID();
sleep(1);
}
However, when strict subs are enabled, I get an error about barewords:
[minter@localhost mrvoice]$ ./mrvoice.pl
Bareword "NORMAL_PRIORITY_CLASS" not allowed while "strict subs" in use
at ./mrvoice.pl line 3513.
Execution of ./mrvoice.pl aborted due to compilation errors.
My question is - what's the proper way to use this constant when strictures
are enabled?
Thanks,
Wade
"use strict", which has been fun and productive, and also revealed some
bad code that I've rewritten. So, cool.
I have a question on one thing, though, and didn't see an answer by
Googling. My code is designed on Linux but also runs on Windows via
checks of $^O. So, to import Windows-specific modules, I do this:
if ( "$^O" eq "MSWin32" )
{
$rcfile = "C:\\mrvoice.cfg";
BEGIN
{
if ( $^O eq "MSWin32" )
{
require LWP::UserAgent;
LWP::UserAgent->import();
require HTTP::Request;
HTTP::Request->import();
require Win32:rocess;
Win32:rocess->import();
require Tk::Radiobutton;
Tk::Radiobutton->import();
require Win32::FileOp;
Win32::FileOp->import();
require Audio::WMA;
Audio::WMA->import();
}
}
}
Then, later in the code, I use an imported constant like:
if ( "$^O" eq "MSWin32" )
{
# Start the MP3 player on a Windows system
my $object;
Win32:rocess::Create( $object, $config{'mp3player'}, '', 1,
NORMAL_PRIORITY_CLASS, "." );
$mp3_pid = $object->GetProcessID();
sleep(1);
}
However, when strict subs are enabled, I get an error about barewords:
[minter@localhost mrvoice]$ ./mrvoice.pl
Bareword "NORMAL_PRIORITY_CLASS" not allowed while "strict subs" in use
at ./mrvoice.pl line 3513.
Execution of ./mrvoice.pl aborted due to compilation errors.
My question is - what's the proper way to use this constant when strictures
are enabled?
Thanks,
Wade