File: post_filter.pl

package info (click to toggle)
suck 4.3.5-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,196 kB
  • sloc: ansic: 12,086; perl: 528; sh: 363; makefile: 345; java: 144
file content (35 lines) | stat: -rwxr-xr-x 824 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl

# sample program for editting/changing the downloaded articles.
# this program is passed the directory where the articles are
# stored

# it modifies the Path: header, so you can add your own unique
# host to it, so you can tell INN not to upload these articles

opendir (DIRP, $ARGV[0]) or die "Can't open $ARGV[0]";

# get list of files, skipping hidden files
@files = grep ( !/^\./, readdir(DIRP));

foreach $file ( @files) {

	# read the file in
	$path  = "${ARGV[0]}/${file}";
	open FIP, "<${path}" or die "Can't read ${path}\n";
	@file = <FIP>;
	close FIP;

	# find the line and change it
	foreach $line ( @file) {
		if ( $line =~ /^Path: /) {
			$line =~ s/^Path: /Path: myhost\!/
		}
	}
	
	# save it back out
	open FIP, ">${path}" or die "Can't write to ${path}\n";
	print FIP @file;
	close FIP;
}