This file contains hidden or 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 v5.14; | |
| my $input_string; | |
| say "Hello! Input string as \"x + y\" or \"sin x\" \n"; | |
| say 'You can use "+", "-", "*", "\", "**", "sin", "cos", "tan"'; | |
| $input_string = <STDIN>; | |
| my ($first_arg, $second_arg, $third_arg) = split ' ', $input_string; |
This file contains hidden or 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 vk_api_init { | |
| my $self = shift; | |
| my $token = $self->db->selectrow_hashref( | |
| "SELECT access_token,uid FROM clients_social WHERE client_id = ? and network = ?", | |
| {Slice => {}}, | |
| $self->current_user->{id}, 'vkontakte' | |
| ); | |
| $self->{vk_token} = $token; | |
| my $api_point = "https://api.vk.com/method/"; | |
| return sub { |
This file contains hidden or 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
| use Curses; | |
| use strict; | |
| use warnings; | |
| initscr; | |
| start_color; | |
| init_pair(1, COLOR_BLACK, COLOR_RED); |
This file contains hidden or 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 | |
| package World::Schema; | |
| use base qw/DBIx::Class::Schema::Loader/; | |
| $ENV{SCHEMA_LOADER_BACKCOMPAT} = 1; | |
| my $schema = World::Schema->connect("DBI:mysql:database=world", "world", "world1", | |
| {PrintError => 1, RaiseError => 1, mysql_enable_utf8 => 1}); | |
| package main; | |
| use DBIx::Connector; | |
| use DBIx::Struct; |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| package A; | |
| sub new {bless [[], undef], $_[0]} | |
| sub id { | |
| if (@_ > 1) { |
This file contains hidden or 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
| use FindBin qw($Bin); | |
| use lib "$Bin/../lib"; | |
| use lib "$Bin/../t"; | |
| use Test::More; | |
| use DBI; | |
| use Time::HiRes 'time'; | |
| use Test::mysqld; | |
| use feature 'say'; | |
| use DBIx::MysqlAsync; |
This file contains hidden or 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 B; | |
| use Scalar::Util::LooksLikeNumber 'looks_like_number'; | |
| sub positive_int { | |
| my $lln = looks_like_number($_[0]); | |
| ($lln == 1 || $lln & B::SVf_IOK) && $_[0] > 0; | |
| } | |
| for (0, "0", 123, "123", 123.45, "123.45", "yolki-palki", "nancy") { | |
| print "$_ -> " . (positive_int($_) ? "true" : "false"); |
This file contains hidden or 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 warnings; | |
| use strict; | |
| use feature 'say'; | |
| my @array = (5, 3, 7, 9, 2, 1, 6, 5, 3, 7, 9, 3, 4); | |
| say "@array - initial"; |
This file contains hidden or 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
| use PDF::Haru; | |
| use strict; | |
| use warnings; | |
| # create new document | |
| my $pdf = PDF::Haru::New(); | |
| #$pdf->LoadTTFontFromFile("/usr/share/fonts/truetype/msttcorefonts/arial.ttf", HPDF_TRUE); | |
| # add page | |
| my $page = $pdf->AddPage(); | |
| # set page size and orientation |
This file contains hidden or 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 Undef; | |
| sub new { bless \my $a, $_[0] } | |
| sub AUTOLOAD { Undef->new } | |
| use overload | |
| '""' => sub {""}, | |
| lt => sub { $_[2] ? $_[1] lt "" : "" lt $_[1] }, | |
| le => sub { $_[2] ? $_[1] le "" : "" le $_[1] }, | |
| gt => sub { $_[2] ? $_[1] gt "" : "" gt $_[1] }, | |
| ge => sub { $_[2] ? $_[1] ge "" : "" ge $_[1] }, |