Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use strict;
- use warnings;
- use utf8;
- use feature 'say';
- use Benchmark qw(cmpthese);
- say $];
- my $pattern = '((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))';
- my $regexp = qr/$pattern/;
- my $ipv4 = '192.168.1.1';
- cmpthese(0, +{
- 'precompile' => sub {
- $ipv4 =~ $regexp;
- },
- 'runtime' => sub {
- $ipv4 =~ /$pattern/;
- },
- 'runtime_static' => sub {
- $ipv4 =~ /((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))/;
- },
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement