Dave's Brain

Browse - programming tips - perl is this perl5

Date: 2008oct20

Q.  How I can dynamically tell if I am running Perl 5?

A.  This subroutine does the trick:

sub isPerl5()
{
	return $] =~ m/^5\./
}

sub exampleUse()
{
	if (isPerl5())
	{
		print "This IS Perl 5\n";
	}
	else
	{
		print "This is NOT Perl 5\n";
	}
}
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: