Skip to content

Instantly share code, notes, and snippets.

View note103's full-sized avatar
🏠
Working from home

Hiroaki Kadomatsu note103

🏠
Working from home
View GitHub Profile
@note103
note103 / hash_ref_test.pl
Created December 21, 2013 03:11
hash_ref_test.pl
use strict;
use warnings;
my %hash = (
hoge => 33,
var => 44,
foo => 55,
);
my $ref = {
@note103
note103 / calc_string.pl
Created December 21, 2013 06:02
calc_string.pl
#!/usr/bin/env perl
use strict;
use warnings;
while (my $form = <STDIN>) {
calc_string($form)
}
sub calc_string {
my $str = shift;
@note103
note103 / PerlBeginners.pm
Created December 25, 2013 15:30
PerlBeginners.pm 2013/12/26
#!/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) {
@note103
note103 / tag_out.pl
Created December 28, 2013 10:20
タグ整理のためにスクエアブラケット外すためのもの
#!/usr/bin/env perl
use strict;
use warnings;
open (FILE, 'buffer.txt');
my @lines = <FILE>;
for my $line (@lines) {
if ($line =~ /\[(.+)\]\[(.+)\]/) {
@note103
note103 / map_grep.pl
Last active August 29, 2015 13:56
Perl入学式2013年度第5回補講in東京よりmap, grep練習問題の校長の回答
#!/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} ];
#!/usr/bin/env perl
use Mojolicious::Lite;
my @bar = ();
get '/' => sub {
my $self = shift;
$self->stash(hoge => \@bar);
$self->render('index');
};
#!/usr/bin/env perl
use Mojolicious::Lite;
my @entries = {};
get '/' => sub {
my $self = shift;
$self->stash(entries => \@entries);
$self->render('index');
};
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $self = shift;
$self->stash(title => 'fizzbuzz_practice');
$self->render('index');
};
app->start;
@note103
note103 / english_words_lesson.pl
Last active August 29, 2015 14:01
英単語学習用のPerlスクリプト
#!/usr/bin/env perl
use strict;
use warnings;
print "Input a number or a word.\n";
my %english = (
#ここに大量の単語を入れる
abandon => 'を捨てる',
abide => 'に従う|我慢する|住む',
@note103
note103 / daydate.pl
Last active August 29, 2015 14:01
日付を入れて曜日を出すPerlスクリプト
#!/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