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
perl -MTime::Piece -e 'my $t = localtime;my($y, $m, $d) = $t->year, $t->mon, $t->mday' |
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
perl -MString::ShellQuote -E 'my $i = say shell_quote map { ++$i % 2 ? "--$_" : $_ } (foo => 42, bar => "a b c")' |
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
sudo dscacheutil -flushcache | |
http://d.hatena.ne.jp/solitary_shell/20090102/1230887064 |
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 | |
fork+exec { $cmd } @args; | |
use strict; | |
use Capture::Tiny qw(capture); | |
my ($stdout, $stderr) = capture { | |
open my $fh, "| cat"; | |
print $fh "foo bar baz\n"; | |
}; |
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
ユーザーを削除するには、userdelコマンドを使用する。削除するユーザーのホームディレクトリをあわせて削除する場合は、-rオプションを付ける。 |
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
find `perl -e 'print "@INC";'` -name "Amon2.pm"|less | |
http://d.hatena.ne.jp/wizard_blue/20091029/1256743552 |
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
# perl | |
function ex_time() { | |
perl -le ' | |
use Time::Local; | |
use DateTime; | |
my $zone = 'UTC'; | |
my $time = $ARGV[0] || time(); | |
if ($time =~ m{^(\d{4})/(\d{2})/(\d{2})-(\d{2}):(\d{2}):(\d{2})$}) { | |
print("localtime2unixtime"); | |
print("$time"); |
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
perl -MData::Dumper -le 'my $hash = +{a => 1, b=>2, c=>3}; my @list=qw/a b/; my $hash_new =+{}; @$hash_new{@list} = delete@$hash{@list}; print Dumper($hash_new); print Dumper($hash);' |
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
if [ `uname` = "Darwin" ]; then | |
#mac用のコード | |
elif [ `uname` = "Linux" ]; then | |
#Linux用のコード | |
fi |
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
perl -le 'my %a; my $i = 1; for ($i=1; $i < 100000; $i++) { $a{ int(rand(1000000)) }++ ; }; for my $key ( keys %a ) { if ($a{$key} > 3) {print $key} } ' | |
perl -le 'my %a; my $i = 1; for ($i=1; $i < 1000000; $i++) { $a{ int(rand(1000000)+1) }++ ; }; for my $key ( keys %a ) { if ( ($key % 1000000) == 0) {print "$key" . "\t" . $a{$key} } } ' | |