#!/usr/bin/perl -w

# takes every given file and gets rid of mime attachment (lines with no spaces)

$dir = "./";
opendir( DIR, $dir ) or die "CANNOT OPEN \'$dir\'\n";
rewinddir( DIR );

foreach $file ( @ARGV )
{
	open( IN, "$file" );
	@lines = <IN>;
	close( IN );

    open( OFILE, ">>test" ) or die "CANNOT OPEN OR WRITE TO \'test\'\n";

    $msg = 0;
    foreach $line ( @lines )
    { 
    	$myline = $line;
    	chomp( $line );
        if( $line =~ /(\s)/ )
    	{
    		print ":".$1."\t".$myline;
    		$msg = 1;
    	}
        else
        {
			if( length( $line ) < 30 )
			{ 
				$msg = 1;
			}
			else
			{ 
				$msg = 0;
			}
        }
        if( $msg == 1 )
        {
            print OFILE $myline;
        }
    }
}

