Skip to content

Instantly share code, notes, and snippets.

View jef-sure's full-sized avatar

Anton Petrusevich jef-sure

  • Germany
View GitHub Profile
use strict;
use warnings;
my $processes = $ARGV[0] || 1;
my $block_size = 64 * 1024 * 1024;
my $file = 'very_big_file';
my $fsize = -s $file or die 'no file';
my @offsets;
my @sizes;
use strict;
use warnings;
use Benchmark qw( timethese cmpthese);
use v5.10;
my $s =
"1336 4669 6120 5110 3216 4578 1692 5012 7523 4781 5278 2504 3947 2907 7780 9837 2914 7227 4378 56 4020 2819 8271 9706 4144 6489 2809 6748 6585 8995";
cmpthese(
-2, {
use strict;
use warnings;
use v5.10;
use Benchmark;
use constant NUMBER => 500_000_000;
use constant STEP => 1;
our $first = 1;
our $step;
# Henry Ford task
use List::Permutor;
use strict;
use warnings;
use constant {
O => 0,
N => 1,
A => 2,
L => 3,
G => 4,
$ perl -E '$_="Perl Weekly Challenge"; $= = s/e/E/g; say; say $='
PErl WEEkly ChallEngE
5
$ perl -E 'for $= (1..20) { $_ = $=; $_ = "fizz" if $= % 3 == 0; $_ = ($_ ne $=? "$_ ": "") . "buzz" if $= % 5 == 0; say } '
1
2
fizz
4
buzz
fizz
#!/usr/bin/perl
use v5.12;
use warnings;
use JSON::XS;
use List::Util qw(first);
use Time::HiRes 'time';
use File::Map 'map_file';
#!/usr/bin/perl
# https://perlweeklychallenge.org/blog/perl-weekly-challenge-007/
# Challenge #2
# Word Ladder
# Author: Anton Petrusevich
use strict;
use warnings;
use v5.20;
use Socket;
my @hosts = map {"192.168.2.$_"} (89 .. 110, 1 .. 12, 111 .. 190, 35 .. 45, 192 .. 198, 201 .. 210, 46 .. 87);
my @ranges; # contains pairs [$low_num, $high_num]
sub ip_to_num {
return unpack("N", inet_aton($_[0]));
}
# Perl vs PHP
# Perl (with signatures)
sub encode_burl($param) {
my $burl = encode_base64($param, "");
$burl =~ tr|+/|-_|;
my $padd = $burl =~ tr|=||d;
return $burl . $padd;
}
use JSON;
use JSV::Compiler;
use v5.10;
use strict;
use warnings;
use Data::Dumper;
my $s = JSV::Compiler->new;