Skip to content

Instantly share code, notes, and snippets.

View Code-Hex's full-sized avatar

Kei Kamikawa Code-Hex

View GitHub Profile
@Code-Hex
Code-Hex / CoroRSS.pl
Created August 17, 2014 04:27
RSS内の複数のURLを並列処理でgoo.glを使用して短縮。
#! /usr/bin/perl
use strict;
use warnings;
use XML::RSS;
use Coro;
use Coro::LWP;
use LWP::UserAgent;
use HTTP::Request::Common;
use utf8;
use JSON::XS;
@Code-Hex
Code-Hex / basic.rb
Created August 18, 2014 04:30
rubyの練習。その1
print "hello\n";
sun = String.new "String.new\n";
print sun;
for num in 1..3
print num,"\n";
end
print "end\n";
@Code-Hex
Code-Hex / basic2.rb
Created August 18, 2014 05:39
rubyの練習。その2
#! /usr/bin/ruby
basket = 0
while 1
print "果物の入力\n"
fruit = STDIN.gets
result = fruit.gsub /\n/,""
# p result #改行が含まれてるか確認ができる
@Code-Hex
Code-Hex / basic.pl
Created August 20, 2014 04:45
push,popとshift,unshiftについて
#! /usr/bin/perl
use strict;
use warnings;
my @array = qw/1 2 3 4 5 6 7 8/;
print "first!!\n";
print "$_ " for (@array);
print "\n"x2;
my $a = pop @array; # 配列の一番最後の配列を抜き出す
@Code-Hex
Code-Hex / sort.pl
Created August 20, 2014 06:00
Perl の sort関数、reverse関数を使用しての例
#! /usr/bin/perl
use strict;
use warnings;
my $n = "\n";
my @array = qw/3 8 5 4 2 9 5 0 1 7 6 11 23 38 99 100/;
print "First!!\n";
print "$_ " foreach (@array);
print $n x 2;
@Code-Hex
Code-Hex / STDIN.pl
Created August 20, 2014 06:29
Perl で STDINに複数行読み込ませる方法
#! /usr/bin/perl
use strict;
use warnings;
my $n = "\n";
my @lines = <STDIN>;
chomp @lines;
print $n;
my @array = reverse @lines;
@Code-Hex
Code-Hex / input.pl
Created August 20, 2014 06:57
Perl 練習問題 回答よりも優れてたと思うw
#! /usr/bin/perl
use strict;
use warnings;
my $n = "\n";
print "Please input number 1~7" . $n;
my @lines = <STDIN>;
chomp @lines;
print $n;
my @array = qw/fred betty barney dino wilma pebbles bamm-bamm/;
@Code-Hex
Code-Hex / sub.pl
Created August 20, 2014 14:05
sub で return が省略できることを知った
#! /usr/bin/perl
use strict;
use warnings;
my $n = "\n";
my $result = max(10,20);
print $result . $n;
sub max {
my ($a, $b) = @_;
@Code-Hex
Code-Hex / state.pl
Created August 20, 2014 14:28
sub内の stateの勉強
#! /usr/bin/perl
use strict;
use warnings;
use 5.010;
my $sum;
running_sum(5,6);
running_sum(1..3);
running_sum(4);
@Code-Hex
Code-Hex / diamond.pl
Created August 21, 2014 05:01
ダイヤモンド演算子
#! /usr/bin/perl
use strict;
use warnings;
use 5.010;
my $n = "\n";
while(<>){
# chomp; で、改行を取り消すことが可能
print "$_";