#!/usr/bin/perl

$file = $ARGV[0];

@valid = (" ","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",".","!","?","\"","%","&","/","(",")","=","?","`","ä","ü","ö",",",".","-","+","*",",",";","+","-",">","<","@","[","]","}","{","=","~","#");
$count = 1;

foreach (@valid) {
	ord($_);
}

open(RH, $file);
binmode(RH);

while (<RH>) {
	@con = split('',$_);
	foreach $con (@con) {
		ord($con);
		foreach $val (@valid) {
			if ($con eq $val){
				push(@1,$con);
			};
		};
	};
	@con = ();
};

open(WH,">test.out");
	print WH @1;
close WH;

open(RH,"<test.out");
	my $content = do { local( $/ ) ; <RH> } ;
	$content =~ s/\.\./\./ig;
	$content =~ s/\´\´/\´/ig;
	$content =~ s/\-\-/\-/ig;
	$content =~ s/\+\+/\+/ig;
	$content =~ s/\,\,/\,/ig;
	$content =~ s/\;\;/\;/ig;
	$content =~ s/\=\=/\=/ig;
close RH;

$wanted = length($content)/5.7;
$wanted = int($wanted+.99999);

@content = split('',$content);

foreach $line (@content) {
	$count++;
	if ($count <= $wanted) {
		print "$line";
		undef $line;
	}
}

@content = ();


#>
