This:
while($read=sysread(STDIN,$buf,32760)) {
$buf=~s/\r/posttag\rpretag\t/go;
$buf=~s/\n/posttag\npretag\t/go;
syswrite(STDOUT,$buf);
}
delivers ~200 MB/s on my system.
This:
my $pretag = "pretag";
my $posttag = "posttag";
while($read=sysread(STDIN,$buf,32760)) {
$buf=~s/\r/$posttag\r$pretag\t/go;
$buf=~s/\n/$posttag\n$pretag\t/go;
syswrite(STDOUT,$buf);
}
delivers ~100 MB/s on my system.
Why?
I thought that when I had used /o it should not matter if the content is a variable or a fixed string. Is there an easy way I can get the speed of the first?