Closed p5pRT closed 20 years ago
The Camel states on p. 671 that "ordinary string comparisons can be used to determinewhether the Perl interpreter executing your script is in the right range of versions" (this may be a "bug in the book").
The example is
warn "No 'our' declarations!\n" if $^V lt v5.6;
which does\, in fact work under Perl 5.6.0
However\, I expect string comparisons to work when quoted; I'm not a fan of barewords. Consequently\, I was surprised that
warn "No 'our' declarations!\n" if $^V lt "v5.6";
and
warn "No 'our' declarations!\n" if $^V lt 'v5.6';
do not act as expected (that is\, the if test fails).
Steps to reproduce
print "Running Perl version $]\n";
print "Running Perl version ";
printf ("%vd\n"\, $^V); # uninitialized var in 5.004 and 5.00503
warn "1 No 'our' declarations!\n" if $^V lt v5.6;
warn "2 No 'our' declarations!\n" if ($^V lt v5.6);
warn "3 No 'our' declarations!\n" if $^V lt "v5.6";
warn "4 No 'our' declarations!\n" if ($^V lt "v5.6");
warn "3 No 'our' declarations!\n" if $^V lt 'v5.6';
warn "4 No 'our' declarations!\n" if ($^V lt 'v5.6');
prints
Running Perl version 5.006 Running Perl version 5.6.0 3 No 'our' declarations! 4 No 'our' declarations! 3 No 'our' declarations! 4 No 'our' declarations!
On Fri\, Feb 16\, 2001 at 01:13:37PM -0800\, vicki.brown@barclaysglobal.com wrote:
However\, I expect string comparisons to work when quoted; I'm not a fan of barewords. Consequently\, I was surprised that
warn "No 'our' declarations!\n" if $^V lt "v5.6";
and
warn "No 'our' declarations!\n" if $^V lt 'v5.6';
do not act as expected (that is\, the if test fails).
They act as I expected...
perldoc perldata:
A literal of the form v1.20.300.4000 is parsed as a string composed of characters with the specified ordinals. This provides an alternative\, more readable way to construct strings\, rather than use the somewhat less readable interpolation form "\x{1}\x{14}\x{12c}\x{fa0}".
Ronald
Migrated from rt.perl.org#5837 (status was 'resolved')
Searchable as RT5837$