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
use strict; | |
use warnings; | |
my %hash = ( | |
hoge => 33, | |
var => 44, | |
foo => 55, | |
); | |
my $ref = { |
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 strict; | |
use warnings; | |
while (my $form = <STDIN>) { | |
calc_string($form) | |
} | |
sub calc_string { | |
my $str = 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
package PerlBeginners { | |
sub perllevel { | |
my $level = shift; | |
if ($level == 1) { | |
print "レベル1: Perl 関係の書籍や資料を何も読んでいない。Perl がプログラミング言語だということは知っているが、それ以外のことは何も知らない。他人の書いたPerl プログラムを実行できるので、プログラムの一部を編集することでプログラムの動作の一部(出力される文字列の内容など)を変更できることを知っている。プログラムのほかの部分に変更を加えてもなぜうまくいかないのか理解していない。この言語に合うメンタルモデルを持っていないので、Perl の構文をCOBOL とC++ のような他の言語のものとは区別できていない。\n"; | |
} elsif ($level == 2) { |
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 strict; | |
use warnings; | |
open (FILE, 'buffer.txt'); | |
my @lines = <FILE>; | |
for my $line (@lines) { | |
if ($line =~ /\[(.+)\]\[(.+)\]/) { |
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 strict; | |
use warnings; | |
use DDP; | |
my @files = qw/papix.pl moznion.pm macopy.py boolfool.vim/; | |
sub map_bak { | |
my $array_ref = shift; | |
return [ map {$_ . '.bak'} @{$array_ref} ]; |
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 Mojolicious::Lite; | |
my @bar = (); | |
get '/' => sub { | |
my $self = shift; | |
$self->stash(hoge => \@bar); | |
$self->render('index'); | |
}; |
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 Mojolicious::Lite; | |
my @entries = {}; | |
get '/' => sub { | |
my $self = shift; | |
$self->stash(entries => \@entries); | |
$self->render('index'); | |
}; |
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 Mojolicious::Lite; | |
get '/' => sub { | |
my $self = shift; | |
$self->stash(title => 'fizzbuzz_practice'); | |
$self->render('index'); | |
}; | |
app->start; |
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 strict; | |
use warnings; | |
print "Input a number or a word.\n"; | |
my %english = ( | |
#ここに大量の単語を入れる | |
abandon => 'を捨てる', | |
abide => 'に従う|我慢する|住む', |
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 strict; | |
use warnings; | |
print "Input a date with 'YYYYMMDD' or 'YYYY/MM/DD' or 'YYYY-MM-DD'.\n"; | |
my $day = [qw( | |
Sunday | |
Monday | |
Tuesday |