#!/usr/bin/perl -w # # $Id: mktitle,v 1.2 2009/04/24 00:24:41 vogelke Exp $ # #< mktitle: turn a document title into a decent filename use strict; # slurp stdin or join the arguments together if (-f STDIN || -p STDIN) { while (<>) { chomp; title($_); } } else { $_ = join(' ', @ARGV); title($_); } exit(0); # ------------------------------------------------------------------------- # Kill quotes, level out the case, and kill spaces. sub title { local($_); $_ = shift; if (length) { tr/'"//d; tr/A-Z/a-z/; s/\s+/-/g; tr!,/!-!; s/--*/-/g; } print "$_\n"; }