Skip to content

Instantly share code, notes, and snippets.

@sng2c
sng2c / gist:2760165
Created May 21, 2012 01:13
Perl Again in 2012

Perl Again in 2012

작성자 정보

Abstraction

오래전 우리나라에서는 잊혀지고만 perl을 재조명해봅니다.

@sng2c
sng2c / gist:2832869
Created May 30, 2012 02:16
moose monkey patch
package Dog;
#use Any::Moose;
use Moose;
sub bark{
my $self = shift;
print $self->word() x 2;
print "\n";
@sng2c
sng2c / gist:2832954
Created May 30, 2012 02:23
moose monkey patch2
package Dog;
#use Any::Moose;
use Moose;
has 'name'=>(is=>'rw');
sub bark{
my $self = shift;
print $self->word() x 2;
@sng2c
sng2c / depend.pl
Created June 14, 2012 07:20
module dependency checker for cpanm
#!/usr/bin/perl
use strict;
use File::Find;
use Module::Which;
use Module::ExtractUse;
my %depend;
finddepth({wanted=>\&wanted,follow_fast=>1} ,@ARGV);
print join "\n",keys %depend;
@sng2c
sng2c / depend.sh
Created June 14, 2012 08:09
perl dependency checker for cpanm by ack
ack --perl --no-group --no-filename '^(use |requires [\x{27}"])' */Makefile.PL */lib/ */bin/ */examples/ */t/ | sort | uniq
@sng2c
sng2c / evtest.pl
Created June 21, 2012 07:53
AnyEvent recursive blocking wait error
use AnyEvent;
my $cv = AE::cv;
my $t = AE::timer 2,0, sub{
my $cv2 = AE::cv;
my $cnt = 10;
my $tot = 0;
foreach(1..10){
@sng2c
sng2c / ev2.pl
Created June 21, 2012 08:27
solve local blocking
use AnyEvent;
my $cv = AE::cv;
my $t = AE::timer 2,0, sub{
my $cv2 = AE::cv;
my $cnt = 10;
@sng2c
sng2c / ev3.pl
Created June 21, 2012 09:04
coupled timer fail
use AnyEvent;
use EV;
my $cv = AE::cv;
my $t = AE::timer 2,0, sub{
my $cv2 = AE::cv;
my $cnt = 10;
my $tot = 0;
@sng2c
sng2c / buscheck.pl
Created September 25, 2012 07:29
고속버스 빈자리 체크
#!/usr/bin/perl
use utf8;
use LWP::UserAgent;
use Encode;
use AnyEvent;
binmode(STDOUT,":utf8");
my $cv = AE::cv;
my $only_biz = 1;
@sng2c
sng2c / index_arr.pl
Last active December 15, 2015 05:48
perl에서 index() 와 같이 작동하지만 인자는 배열인 거. https://gist.github.com/am0c/dc65b37eca606e74e760 에 offset 추가
sub index_array {
my ($array, $key, $offset) = @_;
my $i = 0;
for my $i ($offset .. $#$array) {
my $is_eql = 1;
for my $j (0 .. $#$key) {
last if $i + $j > $#$array;
if ($key->[$j] ne $array->[$i + $j]) {