Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use utf8;
  5. use feature 'say';
  6. use Benchmark qw(cmpthese);
  7.  
  8. say $];
  9.  
  10. 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]?))';
  11. my $regexp = qr/$pattern/;
  12. my $ipv4 = '192.168.1.1';
  13.  
  14. cmpthese(0, +{
  15. 'precompile' => sub {
  16. $ipv4 =~ $regexp;
  17. },
  18. 'runtime' => sub {
  19. $ipv4 =~ /$pattern/;
  20. },
  21. 'runtime_static' => sub {
  22. $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]?))/;
  23. },
  24. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement