#!/usr/local/bin/perl

#
#Container for page's parts.
#

$main_folder='.';

if(chdir("rc")){
	print "find dir\n";
	chdir("..");
} else {
	print "create dir\n";
	mkdir("rc",777);
};

if(opendir DEMODIR, $main_folder){
	@item=readdir DEMODIR;
	for($cnt=2; $cnt<@item;$cnt++){
		if($item[$cnt] =~ /[^.]*?\.pl/){
			$temp_file="$main_folder/rc/$item[$cnt]";
			open (INFILE,"<$main_folder/$item[$cnt]");
			binmode( INFILE ); 
			open (OUTFILE,">$temp_file");
			binmode( OUTFILE ); 
			$ret_sym="\x0d";
			while ($bytesread=read(INFILE,$buffer,1)) {
				if($buffer eq $ret_sym){
			  	print "Find!\n";
			} else {
			  	print OUTFILE $buffer;
			};
		};
		close (OUTFILE);
		close (INFILE);
	};
};
closedir DEMODIR;
} else {print "Fatal!\n"};
exit;
