App-Cheats
view release on metacpan or search on metacpan
# Merge: 1.7s
%users = ( %users, %users_one);
#
# Slice: 700ms
@users{keys %users_one} = values %users_one;
# Benchmark glob() vs -e() functions
perl -Me -e '
n {
e_found => sub{ -e "recursive.pl" },
e_not_found => sub{ -e "recursive2.pl" },
glob_found => sub{ glob "recursive.pl" },
glob_not_found => sub{ glob "recursive2.pl" },
glob_wild_flag_found => sub{ glob "rec*.pl" },
glob_wild_flag_not_found => sub{ glob "rec2*.pl" },
}, 1_000_000
'
Rate glob_wild_flag_not_found glob_wild_flag_found glob_found glob_not_found e_found e_not_found
glob_wild_flag_not_found 79491/s -- -45% -94% -95% -96% -98%
glob_wild_flag_found 143885/s 81% -- -90% -91% -93% -96%
glob_found 1408451/s 1672% 879% -- -15% -35% -56%
glob_not_found 1666667/s 1997% 1058% 18% -- -23% -48%
e_found 2173913/s 2635% 1411% 54% 30% -- -33%
e_not_found 3225806/s 3958% 2142% 129% 94% 48% --
#############################################################
## Perl Binary
#############################################################
# Convert to binary using recursion (POC,perl).
sub binary{
my($n) = @_;
$n //= $_;
# Unignore case when searching (Vim)
:set noic
#############################################################
## Vim Find/Search and Replace for strings
#############################################################
# Make every after very magical (Vim,regex)
\v magical \V not_magical
# Replace pattern with string according to flags (Vim)
:s/pattern/string/flags
# Replace pattern with string ask for confirmation of each change (Vim)
:s/pattern/string/gc
# Replace pattern with string in entire file (Vim)
:%s/pattern/string/gc
:1,$s/pattern/string/gc
xt/boilerplate.t view on Meta::CPAN
#!perl
use 5.006;
use strict;
use warnings;
use Test::More;
plan tests => 3;
sub not_in_file_ok {
my ( $filename, %regex ) = @_;
open( my $fh, '<', $filename )
or die "couldn't open $filename for reading: $!";
my %violated;
while ( my $line = <$fh> ) {
while ( my ( $desc, $regex ) = each %regex ) {
if ( $line =~ $regex ) {
push @{ $violated{$desc} ||= [] }, $.;
xt/boilerplate.t view on Meta::CPAN
fail( "$filename contains boilerplate text" );
diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
}
else {
pass( "$filename contains no boilerplate text" );
}
}
sub module_boilerplate_ok {
my ( $module ) = @_;
not_in_file_ok(
$module => 'the great new $MODULENAME' => qr/ - The great new /,
'boilerplate description' => qr/Quick summary of what the module/,
'stub function definition' => qr/function[12]/,
);
}
TODO: {
local $TODO = "Need to replace the boilerplate text";
not_in_file_ok(
README => "The README is used..." => qr/The README is used/,
"'version information here'" => qr/to provide version information/,
);
not_in_file_ok( Changes => "placeholder date/time" => qr(Date/time) );
module_boilerplate_ok( 'lib/App/Cheats.pm' );
}
( run in 0.380 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )