[Israel.pm] Selective warnings use

Offer Kaye offer.kaye at gmail.com
Wed Feb 9 05:37:53 PST 2005

On Wed, 9 Feb 2005 11:52:25 +0100, Madani, Srikanth, VF-DE wrote:
> Hi all,
> I have a script which needs to run a Linux box with Perl 5.8.1, and also
> on a Solaris machine with Perl 5.0053.
> The latter doesn't let me use the warnings pragma.
> Can I check which Perl version is being used to compile/execute my
> script and then act accordingly?
> #!/usr/local/bin/perl
> #Notice that I haven't used the "-w" flag
> use strict;
> use diagnostics;
> use warnings if ($Check_if_warnings_pragma_is_available);
> Use the "-w" flag, if warnings isn't available.
> Cheers,
> Srikanth Madani

Why not use "#!/usr/local/bin/perl -w" in both cases (Linux and
Solaris)? Unless you need fine-grained control over the warnings
(either scope or type), using "-w" will be essentially the same as
"use warnings".

Offer Kaye

More information about the Perl mailing list