次のコードを makefile.pl などというファイル名で保存して、chmod +x ./makefile.pl し、そして ./makefile.pl を実行すれば makefile.pl と同じディレクトリ上に sample.txt に1GiB (ギビバイト=2^30)ぴったりのデータ(「a」の文字で埋め尽くされた テキストファイル)が作成されていると思う。プログラム的には、例えば 1KiB のダミーデータを変数($data)に入れてそれを 1024 x 1024 回書き込んだ方が 1文字ずつ 2^30 回書き込むよりも速いと思うが、試してみたらバァッファオーバーフローしてるのか?うまくいかなかった。
ちなみに、2^30 = 1ギガバイト = 1,073,741,824 バイト = 1024 バイト x 1024 キロバイト x 1024 メガバイト
#!/usr/bin/perl
open(OUT, '>sample.txt');
for(my $i = 0; $i < 2^30; $i++) { print OUT 'a'; }
close(OUT);
1;次のコードを makefile.pl などというファイル名で保存して、chmod +x ./makefile.pl し、そして ./makefile.pl を実行すれば makefile.pl と同じディレクトリ上に sample.txt に1GiB (ギビバイト=2^30)ぴったりのデータ(「a」の文字で埋め尽くされた テキストファイル)が作成されていると思う。プログラム的には、例えば 1KiB のダミーデータを変数($data)に入れてそれを 1024 x 1024 回書き込んだ方が 1文字ずつ 2^30 回書き込むよりも速いと思うが、試してみたらバァッファオーバーフローしてるのか?うまくいかなかった。
ちなみに、2^30 = 1ギガバイト = 1,073,741,824 バイト = 1024 バイト x 1024 キロバイト x 1024 メガバイト
#!/usr/bin/perl
open(OUT, '>sample.txt');
for(my $i = 0; $i < 2^30; $i++) { print OUT 'a'; }
close(OUT);
1;<?php
$dir_path = 'your_directory';
$filename = array();
$dir = dir($dir_path);
while($file = $dir->read()) {
if(!ereg('(^\.$)|(^\.\.$)', $file)) {
$filename[] = $file;
}
}
$dir->close();
?><?php
$dir_path = 'your_directory';
$filename = array();
$dir = dir($dir_path);
while($file = $dir->read()) {
if(!ereg('(^\.$)|(^\.\.$)', $file)) {
$filename[] = $file;
}
}
$dir->close();
?>
使用するモジュール
use MIME::Base64;
perl -MMIME::Base64 -ne 'print decode_base64($_)'
< くっつけたBase64ファイル名.txt > 出力ファイル名.pdf
(上は、すべて1行に書く)
使用するモジュール
use MIME::Base64;
perl -MMIME::Base64 -ne 'print decode_base64($_)'
< くっつけたBase64ファイル名.txt > 出力ファイル名.pdf
(上は、すべて1行に書く)#/usr/bin/perl -w
my @array = ('a', 'b', 'c', 'a');
my %count;
@array = grep {!$count{$_}++} @array;
print @array; # 出力は abc となる。
1;#/usr/bin/perl -w
my @array = ('a', 'b', 'c', 'a');
my %count;
@array = grep {!$count{$_}++} @array;
print @array; # 出力は abc となる。
1;#/usr/bin/perl -w
use strict;
our $HOME_DIR = '/home/youraccount';
our $DIR = "$HOME_DIR/targetdirectory";
our %WORDS = (
'ブラウザー' # 置換前の文字列
=> 'ブラウザ', # 置換後の文字列
'FTP' # 置換前の文字列
=> 'FTP', # 置換後の文字列
# ... 以下、
'置換前の文字列1'
=> '置換後の文字列1',
'置換前の文字列2'
=> '置換後の文字列2'
# ... という形で追加していけばよい。
);
1;#!/usr/bin/perl
require './jcode.pl';
require './replace.conf';
opendir(DIR, $DIR) or die "Couldn't open $DIR directory.";
my @files = readdir(DIR);
closedir(DIR);
foreach my $file (@files) {
if(!(-d $file) && $file ne '.' && $file ne '..' && $file ne __FILE__) {
print "$file\n";
replace($file);
}
}
sub replace {
my ($file) = @_;
open(IN, "$DIR/$file") or die die "Couldn't open $file.";
my @lines = <IN>;
close(IN);
open(OUT, ">$DIR/$file.tmp") or die die "Couldn't open $file.";
foreach my $line (@lines) {
&jcode'h2z_sjis(\$line);
while(my($before, $after) = each %WORDS) {
if($line =~ /$before/) {
$line =~ s/$before/$after/g;
}
}
print OUT $line;
}
close(OUT);
rename("$DIR/$file.tmp", "$DIR/$file");
unlink("$DIR/$file.tmp");
}
1;#/usr/bin/perl -w
use strict;
our $HOME_DIR = '/home/youraccount';
our $DIR = "$HOME_DIR/targetdirectory";
our %WORDS = (
'ブラウザー' # 置換前の文字列
=> 'ブラウザ', # 置換後の文字列
'FTP' # 置換前の文字列
=> 'FTP', # 置換後の文字列
# ... 以下、
'置換前の文字列1'
=> '置換後の文字列1',
'置換前の文字列2'
=> '置換後の文字列2'
# ... という形で追加していけばよい。
);
1;#!/usr/bin/perl
require './jcode.pl';
require './replace.conf';
opendir(DIR, $DIR) or die "Couldn't open $DIR directory.";
my @files = readdir(DIR);
closedir(DIR);
foreach my $file (@files) {
if(!(-d $file) && $file ne '.' && $file ne '..' && $file ne __FILE__) {
print "$file\n";
replace($file);
}
}
sub replace {
my ($file) = @_;
open(IN, "$DIR/$file") or die die "Couldn't open $file.";
my @lines = <IN>;
close(IN);
open(OUT, ">$DIR/$file.tmp") or die die "Couldn't open $file.";
foreach my $line (@lines) {
&jcode'h2z_sjis(\$line);
while(my($before, $after) = each %WORDS) {
if($line =~ /$before/) {
$line =~ s/$before/$after/g;
}
}
print OUT $line;
}
close(OUT);
rename("$DIR/$file.tmp", "$DIR/$file");
unlink("$DIR/$file.tmp");
}
1;