This seems connected to one of my pet peeves: why do people put use 5.010 (or higher) in code that is destined for CPAN when the only feature being used is something like say or //=? Why break backwards compatibility for what are, in my opinion, trivial reasons? Is it unreasonable for me to think that gunzip would do that?
That is not to say that when one is writing code for a closed environment, i.e. $work, where everything is fully controlled then by all means write for the latest and greatest that you have confidence in and take full advantage of new features! But keep in mind that there is a great difference between a private environment such as $work, and a public one such as CPAN. Please don't assume that others who want to use an otherwise great CPAN module have the environment that will allow them to use anything higher than 5.8 unless there are compelling reasons to disregard those users.
To be fair, performance could differ between using older code and a newer feature, as the following demonstrates (OS X 10.9, perl v5.16.2). But I honestly think that it would be rare indeed for something like this to even begin to affect the run-time of a real application.
#!/usr/bin/perl use v5.16; use warnings; use Benchmark qw/cmpthese/; my $foo = { bar => 'baz', baz => undef, }; my $foo1 = {}; sub _ifdefined { for ( keys(%{$foo}) ) { $foo1->{$_} = 'default' unless defined($foo->{$_}); } } sub _definedor { for ( keys(%{$foo}) ) { $foo1->{$_} //= 'default'; } } cmpthese( -5, { _ifdefined => sub { _ifdefined() }, _definedor => sub { _definedor() }, } ); exit; __END__ Output: Rate _ifdefined _definedor _ifdefined 1081314/s -- -12% _definedor 1228949/s 14% --
NOTE: if $foo1 is initialized inside the sub-routines then the output changes to this:
Rate _ifdefined _definedor _ifdefined 511025/s -- -1% _definedor 514053/s 1% --
In reply to Re: Make $^V and "my" implicit
by boftx
in thread Make $^V and "my" implicit
by gunzip
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |