April 15th, 2004
Another commonly used UNIX utility that I decided to quickly re-write, for fun. Takes a files a strips all the \r characters out, returning a pure UNIX-endline based file. The resulting snippet can be found below:
print map{s/\r//g;$_}<>;
Tags: cli, snippet, perl, unix
Comment on 'dos2unix Rewrite'
March 17th, 2004
This was a little challenge that I made for myself: Duplicate most of the features of the command-line 'bc' application in the fewest number of characters. The results:
eval('$o='.<>.';print\"$o\n\"')while(1);
Tags: cli, snippet, perl, unix
Comment on 'bc Rewrite'
December 2nd, 2003
This was a little chunk of code that I pulled together so that I could quickly view the textual contents of a Word Document. This can be used as a command line tool and does the trick fairly well, in my opinion. Of course, you will lose a lot of contextual information, so take it with a grain of salt. The code is provided below:
#!/usr/bin/perl use Text::Wrap; $Text::Wrap::columns = 80; my $file = join( '', <> ); $file =~ s/<[^>]*>//g; $file =~ s/\r//g; $file =~ s/[\t ]+/ /g; $file =~ s/\ //g; print wrap( '', '', $file );
Tags: convertor, cli, snippet, perl
1 Comment on 'Word Document to Text'