| 99 | |
| 100 | = making files with random name and random content = |
| 101 | * [http://d.hatena.ne.jp/perlcodesample/20100413/1270894115 File::Temp - 一時ファイルの作成 / Perlモジュール徹底解説 - サンプルコードによるPerl入門] |
| 102 | * [http://d.hatena.ne.jp/fbis/20080114/1200307393 ランダムな文字列を生成するString::Random - Unknown::Programming] |
| 103 | |
| 104 | * makerandom.pl |
| 105 | {{{ |
| 106 | #!perl |
| 107 | #! /usr/bin/perl -w |
| 108 | |
| 109 | use strict; |
| 110 | use warnings; |
| 111 | |
| 112 | use File::Temp qw(tempfile); |
| 113 | use String::Random; |
| 114 | |
| 115 | my $filenum = $ARGV[0]; |
| 116 | |
| 117 | while ($filenum-- > 0) { |
| 118 | my ($fh, $fname) = tempfile(DIR => '.'); |
| 119 | |
| 120 | my $length = int(rand(100)); |
| 121 | print "making $fname ...\n"; |
| 122 | print $fh String::Random->new->randregex("[A-Za-z0-9]{$length}"); |
| 123 | } |
| 124 | }}} |