[Israel.pm] Selective warnings use

Shlomo Yona shlomo at cs.haifa.ac.il
Wed Feb 9 03:02:38 PST 2005


Yes.

Here's a quote from `perldoc perlvar`:

$]      The version + patchlevel / 1000 of the Perl interpreter.
 	This variable can be used to determine whether the
 	Perl interpreter executing a script is in the right
 	range of versions.  (Mnemonic: Is this version of
 	perl in the right bracket?) Example:

 	warn "No checksumming!\n" if $] < 3.019;

 	See also the documentation of "use VERSION" and
 	"require VERSION" for a convenient way to fail if the
 	running Perl interpreter is too old.

 	The floating point representation can sometimes lead
 	to inaccurate numeric comparisons.  See $^V for a more
 	modern representation of the Perl version that allows
 	accurate string comparisons.




-- 
Shlomo Yona
shlomo at cs.haifa.ac.il
http://cs.haifa.ac.il/~shlomo/

On Wed, 9 Feb 2005, 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
>
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl
>



More information about the Perl mailing list