Next | Trivial Utilities | 118 |
If -t type is not supplied, or after decompressing a file, print must guess what to do next
This is an awful hack that worked really well
Unix has a command for guessing file types:
sub file_type { my $file = shift; local $_ = qx{file -Lb $file}; # -b: Do not prepend filename to output /JPEG/ && return 'jpg'; /GIF/ && return 'gif'; /HTML/ && return 'html'; /PostScript/ && return 'ps'; /HP PCL/ && return 'pcl'; /(ASCII( English| mail)?|news) text/ && return 'txt'; /PDF/ && return 'pdf'; /TeX DVI/ && return 'dvi'; /gzip/ && return 'gz'; /compress/ && return 'Z'; /troff/ && return '3'; /perl script/ && return 'pl'; /\w+ script/ && return 'txt'; /PPM/ && return 'ppm'; /Microsoft Office/ && return 'doc'; return '???'; }
This should be in the config file, not hardwired
I guess I'll do that in version 2.0
Next | Menu | Copyright © 2012 M. J. Dominus |