This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use common::sense; | |
use lib '/tk/mojo/lib'; | |
package TempLink; | |
use Mojo::Util qw(b64_decode b64_encode hmac_md5_sum secure_compare); | |
use Mojo::JSON; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Application; | |
use strict; | |
use warnings; | |
use base 'Mojolicious'; | |
sub startup { | |
my $self = shift; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print trunc("11111 222 4444", 9); | |
sub trunc { | |
s/\s+?\S+?$//, return $_ for my $str = substr shift, 0, (shift || 1) + 1; | |
} | |
sub trunc {#by http://what-me.livejournal.com/ | |
$_[0] =~ /^.{0,$_[1]}(?!\S)/s ? $& : ''; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
join '', map { sprintf "%2x", ord } $str =~ /./g; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use common::sense; | |
sub D($) { | |
for (scalar reverse shift) { | |
s/(\d{3})(?=\d)/$1 /g; | |
return scalar reverse; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub gen_name { | |
my $tt = [0..9,'a'..'z','A'..'Z']; | |
return join '', map {$tt->[rand @$tt]} 1..8; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub ashuffle { | |
my @a = @_; | |
[map {splice @a, int rand scalar @a, 1} 1..scalar @a]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Двойная Сортировка массива хешей | |
#mysort(array_ref, up_sort, down_sort) | |
#up_sort - индекс сортировки по возрастанию | |
#down_sort - индекс сортировки по убыванию | |
sub mysort { | |
my ($arr, $up, $down) = @_; | |
my $temp; | |
push @{$temp->{$_->{$up}}}, $_ for @$arr; | |