All pastes #928778 Raw Edit

Beau

public text v1 · immutable
·published 2008-03-05 08:51 UTC
rendered paste body
#!/usr/bin/perl

use strict;

die unless opendir(DIR, ".");

while (my $item = readdir(DIR)) {
	next unless $item =~ /\.txt$/i;
	my $data;
	die unless open(FILE, "$item");
	while (<FILE>) {
		$data .= $_;
	}
	close(FILE);
	$data =~ s/aaa/bbb/g;
	die unless open(FILE, "> $item");
	print FILE $data;
	close(FILE);
}

closedir(DIR);