����ä�perl�ǡ�
Rails Hub�����: dd���ޥ�ɤΥ�åѡ���ddr�פ�Ruby�ǽ񤤤Ƥߤ��ǡ����ԡ������Х��ȿ����23MB Combo!�פ�ɽ�����褦�Ȥ��Ƶ��դ����ΤǤ�������Υ�����ץȤϰտޤ������ȤȰ㤦ư���򤷤Ƥ��ޤ���IO#popen��ɸ����Ϥ������ȥ���ץ���Ǥ��Ƥʤ��ơ�ñ�˲��̤˽ФƤ��Ƥ�������Ǥ���open3�Ȥ�STY�Ȥ�������餷���饤�֥�꤬���ä��ꤷ�Ƥ������˻���ꡢIO�Хåե��� flush�����ꡩ �ʤɡ���������Ĵ�٤Ƥߤ��ΤǤ���������ʤ��Ȥ��Ƥ��礸��ʤ��ȵ��դ��ơ����������Ż������ޤ��ġġ�
��äĤ��⤤���Ȥ����Ǥ�������� Mac OS X �Ǥ� Ubuntu �Ǥ� FreeBSD �Ǥ�ư���ǧ���Ƥ���ޤ���CPAN��¸�Ϥ���ޤ��󡣥С�����դ����ݤʤΤ�%ɽ���Ǥ���������Ƥ��ޤ���
#!/usr/bin/env perl use strict; use warnings; use IPC::Open3; use Symbol 'gensym'; use Time::HiRes 'sleep'; my $sig = ( $^O eq 'linux' ) ? 10 : 29; # SIGUSR1 for linux, else SIGINFO my $size = getsize(@ARGV); my $intv = 0.1; unshift @ARGV, 'dd'; my ( $cin, $cout, $cerr ) = ( undef, undef, gensym ); die $! unless my $pid = open3( $cin, $cout, $cerr, @ARGV ); close $cin; close $cout; local $| = 1; loop: while (1) { sleep $intv; kill $sig, $pid; while (<$cerr>) { my ($curr) = /^(\d+) bytes/; next unless $curr; print_progress( $1, $size ); last loop if $curr >= $size; last; } } waitpid $pid, 0; print "\n"; sub getsize { my $cmd = join " ", @_; my ($if) = ( $cmd =~ /if=(\S+)/ ); return -s $if if -f $if; my ($bs) = ( $cmd =~ /bs=(\d+)/ ); $bs ||= 512; my ($count) = ( $cmd =~ /count=(\d+)/ ); $count ||= 1; return $bs * $count; } sub print_progress { my ( $curr, $size ) = @_; printf "$curr/$size (%d%%)\r", $curr / $size * 100; }
���Ƥ��̤ꡢ���Υץ���������Ȥ����ΤϤʤ��ʤ��ޤ�ɤ������ɤ��������ơ��ɤ����Ƥ�Ȥ������� Perl Cookbook �򸫤Ƥʤ�Ȥ����Ƥ����ޤ��Ȥ��������ʤΤǤ�����
��dd�����椹��פȹͤ���ΤǤϤʤ������ç¤ï¿½Ê¶ï¿½ï¿½Õ¥ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½Ä½ï¿½ï¿½Ç§ï¿½ï¿½ï¿½Ê¤ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½×¤Î¤Ç¤ï¿½ï¿½ï¿½Ð¡ï¿½ï¿½Ê²ï¿½ï¿½Î¤è¤¦ï¿½Ë¤ï¿½ï¿½Ã¤È¥ï¿½ï¿½ï¿½×¥ï¿½Ë¤Ê¤ï¿½Þ¤ï¿½ï¿½ï¿½
#!/usr/bin/env perl use strict; use warnings; my ( $bs, $count, $filename ) = @ARGV; die "$0 bs count file" unless $filename; open my $wfh, '>', $filename or die "$filename:$!"; local $| = 1; # AUTOFLUSH; for my $i ( 1 .. $count ) { print $wfh "\0" x $bs; printf "%d/%d (%d%%)\r", $bs * $i, $bs * $count, $i / $count * 100; } close $wfh; print "\n"
�ߥ˥ޥ�Perl
Tim Maher / ��ƣ�İ�& ��������Ϻ��
[����:Minimal Perl]
���μ�Υ����ƥ������Υ�����ץȤλ��ͽ�Ȥ��Ƥϡ��֥ߥ˥ޥ�Perl�פ������Ƥޤ���
Enjoy!
Dan the System Administrator that Scripts
���Υ֥����˥����Ȥ���ˤ�����������ɬ�פǤ���
��������������
���ε����ˤϵ��ĥ桼�����������Ȥ��Ǥ��ޤ���