commit fc1b723dc656d2ee824749cc1651197e23771018 Author: Anna Wiggins Date: Fri Mar 20 01:54:35 2009 -0400 Initial commit into git control diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..bd69c5c --- /dev/null +++ b/INSTALL @@ -0,0 +1,18 @@ +INSTALLATION +------------ + +To install these scripts, simply copy them into your $PATH somewhere. I recommend creating a local bin directory at ~/bin and adding it to your path. To do so, edit the file ~/.bashrc and add the line + +export PATH=$PATH:~/bin + +Install ALL of the scripts, since some of them depend on others. + +cdripper requires the CDDB and CDDB_get perl modules. + +You will also need the following programs: +cdparanoia +mplayer, mpg321, or mpg123 +oggenc +cdrecord +vorbiscomment +metaflac (for flac support) diff --git a/all2sane b/all2sane new file mode 100755 index 0000000..54fcd07 --- /dev/null +++ b/all2sane @@ -0,0 +1,63 @@ +#!/usr/bin/perl +# +# All of MP3 to Sane +# usage: all2sane +# +# Renames the files to a sane format, then calls vcfromfilename +# to set the vorbis comments +# +# Requires vcfromfilename, fixname +# +# Changelog: +# 0.2: version now aligned with ds-audiotools +# 0.1.2: automated artist determination +# 0.1.1: added VERSION variable +# added call to fixname +# 0.1: initial implementation + +$VERSION = "0.2"; +$HELP_MSG = "All of MP3 to Sane v$VERSION\n\tusage: all2sane \n"; + +$END_CHUNK = '_\d{3}_ogg_.*\.ogg$'; # match the unwanted end of the string +$DESIRED_END = '.ogg'; # replace the end chunk with this +$ALLOFMP3_FORMAT = '^\d{2}_?-_?.*' . $END_CHUNK; + +if ($#ARGV < 0) { die $HELP_MSG; } +foreach (@ARGV) +{ + if (/^(--help)|(-h)$/) { die $HELP_MSG; } +} + +$artist = `cd .. && pwd`; +$artist =~ s/^.*\///; + +foreach (@ARGV) +{ + next unless /$ALLOFMP3_FORMAT/; + my $old_name = $_; + + $_ = $artist . '-' . $_; # prepend artist + s/_-_/-/g; # clear up the _ problem + s/$END_CHUNK/$DESIRED_END/; + + system('mv', $old_name, $_); + system('fixname', $_); + system('vcfromfilename', $_); +} + + +# Copyright (c) 2005 John Wiggins +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA diff --git a/burnmusic b/burnmusic new file mode 100755 index 0000000..1dec369 --- /dev/null +++ b/burnmusic @@ -0,0 +1,65 @@ +#!/usr/bin/perl +# +# Music Burner +# usage: burnmusic +# +# Burns the specified ogg, mp3, and wav files to a cd +# The track order is as passed on the commandline +# +# Requires oggdec, mpg321, cdrecord +# +# ChangeLog: +# 0.2: Aligned version with ds-audiotools +# 0.1.2: Added version variable +# 0.1.1: Added command-line wrapper, cleaned code +# 0.1: Initial code + +$VERSION = "0.2" +$HELP_MSG = "# Music Burner v$VERSION\n\tusage: burnmusic \n"; +$temp_dir = '/tmp/burnmusic-' . `whoami`; + +die $HELP_MSG if ($#ARGV < 2); +foreach (@ARGV) +{ + die $HELP_MSG if (/^(--help)|(-h)$/); +} + +system("rm -rf $temp_dir 2>/dev/null"); +system("mkdir $temp_dir"); + +# Parse required arguments +$cdspeed = shift(@ARGV); +die "Fatal: Invalid CD Speed.\n" if ($cdspeed =~ /\D/); +$device = shift(@ARGV); + +#Parse and handle files +$track = '01'; +foreach (@ARGV) +{ + if (/\.ogg$/) { system('oggdec', "-o $temp_dir/$track.wav", $_); } + elsif (/\.mp3$/) { system('mpg321', "-w $temp_dir/$track.wav", $_); } + elsif (/\.wav$/) { system('cp', $_, "$temp_dir/$track.wav"); } + else { print STDERR 'Invalid argument (non-fatal): ' . $_ . '\n'; } + $track++; +} + +# Burn and clean +system('cdrecord', '-v -pad -audio', "speed=$cdspeed", "dev=$device", "$temp_dir/*.wav"); +system("rm -rf $temp_dir"); + + +# Copyright (c) 2005 John Wiggins +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA diff --git a/cdripper b/cdripper new file mode 100755 index 0000000..96fb837 --- /dev/null +++ b/cdripper @@ -0,0 +1,284 @@ +#!/usr/bin/perl +# +# CD Ripper +# usage: cdripper [-o num] [--no-cddb] [-a] [-y] [target_directory] +# +# Rips the contents of an audio CD into Ogg Vorbis files +# Puts the files in target_directory/artist/album_name/ +# (default target_directory is ./) +# +# Requires cdparanoia, oggenc, vcfromfilename +# +# Changelog: +# 0.2: Aligned version with ds-audiotools +# Implemented CDDB support (disabled with --no-cddb) +# Ability to preview and edit all text before it's used +# -y option to suppress all user input, taking defaults +# -a option to be asked about CDDB options +# 0.1.2: Removed the erroneous fixname, updated fixname to do what I need +# Now you can name things with natural characters, and it should be +# automatically fixed +# Added the -o option, functions as -o num, makes the first track +# num + 1 +# 0.1.1: Added version variable +# 0.1: changed to perl (from bash) +# improved file naming mechanism +# added Vorbiscomment updating (using vcfromfilename script) +# added program to ds-audio package +# 0.0.4: fixed track #s above 10 not happening :P +# 0.0.3: fixed the bug with track #s +# 0.0.2: changed entire code to bash script (from C++) +# 0.0.1: basic code in place + +use CDDB_get qw( get_cddb ); + +$VERSION = "0.2"; +$HELP_MSG = "# CD Ripper v$VERSION\n\tusage: cdripper [--no-cddb] [-a] " . + "[-y] [-o num] [target_directory]\n\n" . + "Options:\n-a:\t\tAsk users about multiple CDDB options\n" . + "-o [num]:\tOffset track numbers by num. The first track will be num+1\n" . + "-y:\t\tDon't prompt for user confirmation of CDDB information\n\t\t(assume defaults are okay).\n" . + "--no-cddb:\tDon't use CDDB. Prompt the user for all information.\n"; + +$CDPARANOIA_FORMAT = 'track*.cdda'; +$TRACK_ZERO = 'track00'; +chomp($orig_dir = `pwd`); +chomp($temp_dir = '/tmp/ds-cdripper-' . `whoami`); +$target_directory = $orig_dir; +$offset = 0; +$useCDDB = 1; +$noInput = 0; +$askCDDB = 0; + +foreach (@ARGV) +{ + if ($offsetOnNext) + { + $offset = $_; + $offsetOnNext = 0; + } + else + { + if (/^(--help)|(-h)$/) { print $HELP_MSG; exit; } + elsif (/^-o$/) { $offsetOnNext = 1; } + elsif (/^--no-cddb$/) { $useCDDB = 0; } + elsif (/^-f$/) { $noInput = 1; } + elsif (/^-a$/) { $askCDDB = 1; } + else + { + $target_directory = $_; + } + } +} + +# Create temp location +system("rm -rf $temp_dir 2> /dev/null"); +mkdir($temp_dir); +chdir($temp_dir); + +# Get the filenames to use later +handle_names(); + +# Rip, convert +system('cdparanoia -B'); +system("oggenc $CDPARANOIA_FORMAT.wav"); +$sanityTest = `ls -1 | wc -l`; +chomp $sanityTest; +die "No files were created. Aborting." unless ($sanityTest > 0); + +# Fix filenames +init_old_tracks(); +fix_files(@new_tracks); + +# Move files to final location +$final_location = "$target_directory/$artist/$album"; +mkdir($target_directory); +mkdir("$target_directory/$artist"); +mkdir("$target_directory/$artist/$album"); +system('mv', @new_tracks, $final_location); +chdir($final_location); +warn "Some files were not automatically named." if $unhandledFiles; + +# Add vorbiscomment data +system('vcfromfilename', @new_tracks); + +# Clean up +chdir($orig_dir); +system("rm -rf $temp_dir"); + +# Converts the filenames created by cdparanoia +# to my arbitrary file name standard, using CDDB or User Input +sub handle_names +{ + init_current_track(); + + if ($useCDDB) { getinfo_cddb(); } + else { getinfo_user(); } + + # final check for user + confirm_filenames() unless $noInput; +} + +# Gets user input to create the @new_tracks array +sub getinfo_user +{ + die "Trying to ask for user input with user input disabled. THIS SHOULD NOT HAPPEN." if $noInput; + + print 'Artist: '; + chomp($artist = ); + $artist = `fixname -o "$artist"`; + print 'Album: '; + chomp($album = ); + $album = `fixname -o "$album"`; + + my $numTracks = get_number_of_tracks(); + for (my $i = 1; $i <= $numTracks; $i++) + { + print "Track $current_track: " ; + chomp (my $input = ); + my $input = `fixname -o "$input"`; + + my $track_name = $artist . '-' . $current_track . '-' . $input . + '.ogg'; + + push @new_tracks, $track_name; + $current_track++; + } +} + +# Uses CDDB to populate the new_tracks array +sub getinfo_cddb +{ + my %config; + $config{input} = 1 if $askCDDB; + + my %cd=get_cddb(\%config); + if (! defined $cd{title}) + { + die "No CDDB entry and user input disabled. Quitting." if $noInput; + warn "Couldn't find CDDB entry for disc. Switching to user input.\n"; + getinfo_user(); + return; + } + + $artist = `fixname -o "$cd{artist}"`; + $album = `fixname -o "$cd{title}"`; + + foreach (@{$cd{track}}) + { + my $track_name = $artist . '-' . $current_track . '-' . + `fixname -o "$_"` . '.ogg'; + + push @new_tracks, $track_name; + $current_track++; + } +} + +# Fixes the files listed in @old_tracks with the names given +# in @new_tracks +sub fix_files +{ + my @newTracks = @new_tracks; + + foreach (@old_tracks) + { + my $newName = shift @newTracks; + if ($newName) { system('mv', "$_", $newName); } + else + { + push @new_tracks, $_; + $unhandledFiles = 1; + } + } +} + +# Sets $current_track to the correct value +sub init_current_track +{ + $current_track='01'; + for ($i = 0; $i < $offset; $i++) { $current_track++; } +} + +# Populates the @old_tracks array +sub init_old_tracks +{ + foreach (`ls $CDPARANOIA_FORMAT.ogg`) + { + chomp; + next if /$TRACK_ZERO/; + push @old_tracks, $_; + } +} + +# Create and open a file for final adjustments to filenames +sub confirm_filenames +{ + my $savedComma = $,; + $, = "\n"; + + # Dump the file + open TMPFILE, "> $temp_dir/filenames"; + print TMPFILE $artist . "\n"; + print TMPFILE $album . "\n"; + print TMPFILE @new_tracks; + print TMPFILE "\n"; + close TMPFILE; + + $, = $savedComma; + + # Allow editing + my $editor = $ENV{'EDITOR'}; + if ($editor) { system($editor, "$temp_dir/filenames"); } + elsif ( -x '/usr/bin/vi') { system('vi', "$temp_dir/filenames"); } + else + { + warn "No \$EDITOR variable defined, and no default editor found. Filename editing disabled.\n"; + return; + } + + # Read the changes + @new_tracks = (); + open TMPFILE, "< $temp_dir/filenames"; + + chomp ($artist = ); + chomp ($album = ); + + while (chomp($_ = )) + { + push @new_tracks, $_; + } + close TMPFILE; +} + +sub get_number_of_tracks() +{ + my @tracks; + + # Get the track numbers + foreach (`cdparanoia -Q 2>&1`) + { + next unless /^\s{1,2}\d{1,2}/; + s/\..*$//; # Kill everything after the number + s/^\s*//; # Kill the leading whitespace + push @tracks, $_; + } + + # Return the last track number, and we should be golden + return pop @tracks; +} + +# Copyright (c) 2004 - 2007 John Wiggins +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA diff --git a/dirclean b/dirclean new file mode 100755 index 0000000..47e99ac --- /dev/null +++ b/dirclean @@ -0,0 +1,40 @@ +#!/usr/bin/perl +# +# Takes a directory tree and breaks it down, displaying in this format: +# +# first_dir: +# sub_dir1 +# sub_dir2 +# second_dir: +# sub_dir3 +# +# This information is printed to stdout. +# Further, the script only goes two levels deep. +# +# ChangeLog: +# 0.2 - aligned version with ds-audiotools +# 0.1 - initial version + +$VERSION = "0.2"; +$HELP_MSG = "# dirclean v$VERSION\n\tusage: dirclean \n\t"; + +foreach (@ARGV) +{ + $target = $_ unless /(-[Hh])|(--help)/; +} + +foreach (`ls -1 $target`) +{ + chomp; + $full_name = "$target/$_"; + next unless (-d $full_name); + + print " $_:\n"; + foreach (`ls -1 $full_name`) + { + chomp; + my $full_name = "$full_name/$_"; + next unless (-d $full_name); + print "\t$_\n"; + } +} diff --git a/fixname b/fixname new file mode 100755 index 0000000..e579db8 --- /dev/null +++ b/fixname @@ -0,0 +1,75 @@ +#!/usr/bin/perl +# +# File Name Fixer +# usage: fixname +# +# Renames files to comply with darkside's arbitrary standard +# +# This is darkside's standard: +# 1) all letters are lowercase +# 2) Whitespace becomes underscore +# 3) Never more than one consecutive underscore +# 4) No underscores flanking dashes +# 4) Never more than one consecutive dash +# +# ChangeLog: +# 0.2: Made everything more robust - better at multiple spaces and special +# characters now. Also now renumbering along with ds-audiotools +# 0.1.4: Added -o option, which prints to stdout instead of renaming the file +# 0.1.3: Added version variable +# 0.1.2: Added help message +# 0.1.1: Made code compile and run, no known bugs +# 0.1: Switched code to perl with regular expressions +# 0.0.4: Minor bugs fixed, __ was becoming - instead of _ +# 0.0.3: Minor bugs fixed, code improved +# 0.0.2: Takes command-line arguments instead of parsing entire directory +# 0.0.1: basic code in place + +$VERSION = "0.2"; +$HELP_MSG = "# Filename fixer v$VERSION\n\tusage: fixname \n\t fixname -o \"name\"\n"; + +die $HELP_MSG if ($#ARGV < 0); +foreach (@ARGV) +{ + die $HELP_MSG if (/^(--help)|(-h)$/); + if (/^-o$/) + { + $toStdOut = true; + } +} + +@ARGV = grep(!/^-o$/, @ARGV) if ($toStdOut); + +foreach (@ARGV) +{ + my $oldname = $_; + + s/(.*)/lc($1)/e; # Lowercase it + s/[^\w\s\.-]//g; # Remove odd characters + + s/\s/_/g; # Change whitespace to _ + s/_+/_/g; # Squash multiple spaces + s/^_*//; # Remove leading space + s/_*$//; # Remove trailing space + s/_*(-|\.)_*/$1/g; # Remove space flanking a - or . + + if ($toStdOut) { print; } + else { system('mv', $oldname, $_); } +} + + +# Copyright (c) 2004 - 2007 John Wiggins +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA diff --git a/mp32ogg b/mp32ogg new file mode 100755 index 0000000..49d5390 --- /dev/null +++ b/mp32ogg @@ -0,0 +1,100 @@ +#!/usr/bin/perl +# +# MP3 - Ogg converter +# usage: mp32ogg +# +# Creates ogg files from the selected mp3 files +# +# Requires one of mpg321, mpg123 or mplayer, and oggenc +# +# Changelog: +# 0.2.1: Added new options to mplayer for mplayer's new features +# Added support for m4a if using mplayer +# 0.2: Aligned version with ds-audiotools +# 0.1.3: Added mplayer support, automatically select decoder +# Fixed option passing to system() calls to be as secure as possible +# 0.1.2: added support for passing flags +# Use a temp dir for storage of intermediate wav file +# Cleaned up some syntax +# Added version variable +# 0.1: converted to perl +# changed to use command-line args +# 0.0.1: Initial bash script + +$VERSION = "0.2"; +$HELP_MSG = "# MP3 - Ogg Converter v$VERSION\n\tusage: mp32ogg "; +$DEC_ERROR = "Couldn't find a decoder to use. Please install one of mplayer, mpg321, or mpg123"; +$ENC_ERROR = "Couldn't find oggenc, which is necessary for encoding. Please install the package that provides oggenc (probably named 'oggenc' or 'vorbistools')"; + +chomp($tempdir = '/tmp/mp32ogg-' . `whoami`); + + +# Do we need help? +foreach (@ARGV) +{ + if (/^(--help)|(-h)$/) { die $HELP_MSG; } +} + +# Select the encoder and decoder +chomp($decoder = `which mplayer`); +$decoder_options = '-vc null -vo null -ao pcm:fast:file='; + +if (! -x $decoder) +{ + $decoder_options = '-w '; # The others both use this format + chomp($decoder = `which mpg321`); +} +chomp($decoder = `which mpg123`) if (! -x $decoder); + +chomp($encoder = `which oggenc`); + +# Dependency checks +die $DEC_ERROR if (! -x $decoder); +die $ENC_ERROR if (! -x $encoder); + +# Set up the temp directory +system('rm', '-rf', $tempdir) if (-d $tempdir); +mkdir($tempdir); + +foreach(@ARGV) +{ + $filename = $_; + $short_name = $_; + if ($decoder =~ /mplayer/) + { + next unless (/\.(m4a|mp3)/); + $short_name =~ s/\.(mp3|m4a)$//; + } + else + { + next unless (/\.mp3$/); + $short_name =~ s/\.mp3$//; + } + + # Transcode the file + system("$decoder $filename $decoder_options$tempdir/$short_name.wav"); + system($encoder, "$tempdir/$short_name.wav", '-o', "$short_name.ogg"); + + # Remove cruft + system('rm', "$tempdir/$short_name.wav"); + system('rm', "$filename"); +} + +# Remove last of the cruft +system('rm', '-rf', $tempdir); + +# Copyright (c) 2005 - 2008 John Wiggins +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA diff --git a/vcfromfilename b/vcfromfilename new file mode 100755 index 0000000..8873810 --- /dev/null +++ b/vcfromfilename @@ -0,0 +1,130 @@ +#!/usr/bin/perl +# +# Vorbiscomment from Filename +# usage: vcfromfilename [options] +# options: +# -n: Only set the track number +# +# Adds Vorbiscomment data to ogg vorbis and flac files based on the filename. +# Files should be in darkside's arbitrary file name standard, which is: +# album/artist-tracknum-title.(ogg|flac) +# +# Requires vorbiscomment and metaflac +# +# Changelog: +# 0.2.2: added flac support +# 0.2.1: fixed version in help message +# fixed handling of dashes in artist name and title +# 0.2: aligned version with ds-audiotools +# 0.1.1: added version variable +# 0.1: initial implementation + +$VERSION = "0.2.2"; +$HELP_MSG = "Vorbiscomment from Filename $VERSION\n\tusage: vcfromfilename [options] \n"; + +chomp($COMMENTFILENAME = '/tmp/vcfromfilename-' . `whoami`); + +# Look for options +foreach (@ARGV) +{ + if (/^(-h)|(--help)$/) { die $HELP_MSG; } + if (/^-n$/) { $tracknumonly = true; s/.*//g; } +} + +# Set the album name +$album = `pwd`; # We WANT the newline here +$album =~ s/^.*\///; # Remove everything up to the last / +$album = formatName($album, 'album='); + +# Parse the file list, set vorbiscomments +foreach (@ARGV) +{ + next if (/^$/); + # check filename format + next unless (/^\w+-\d{1,2}-(\w|-|\d)+\.(ogg|flac)$/); + + $isflac = true if (/\.flac$/); + + open COMMENTFILE, '>' . $COMMENTFILENAME; + + # Remove old flac comments that match + if ($isflac) + { + system("metaflac --remove-tag=tracknumber $_"); + if (!$tracknumonly) + { + system("metaflac --remove-tag=title --remove-tag=artist --remove-tag=album $_"); + } + } + # Preserve existing comments, except the ones we'll replace + else + { + foreach (`vorbiscomment -l $_`) + { + if ($tracknumonly) { print COMMENTFILE $_ unless (/^tracknumber/); } + else { print COMMENTFILE $_ unless (/^(title)|(artist)|(tracknumber)|(album)/); } + } + } + + # Create new comments from the filename + if (!$tracknumonly) + { + # Add the artist + my $artist = $_; + $artist =~ s/^(.*?)-\d{2}-.*/\1/; # grab everything to the track number + $artist = formatName($artist, 'artist='); + print COMMENTFILE $artist; + + # Add the title + my $title = $_; + $title =~ s/.*-\d{2}-(.*)\.(ogg|flac)$/\1/; # grab everything after the track number + $title = formatName($title, 'title='); + print COMMENTFILE $title; + + # And the album + print COMMENTFILE $album; + } + + # Now get the track number + my $tracknum = $_; + $tracknum =~ s/.*-(\d{2})-.*/\1/; + $tracknum =~ s/\b0*//; # removing leading zeros + $tracknum = formatName($tracknum, 'tracknumber='); + print COMMENTFILE $tracknum; + + close COMMENTFILE; + + if ($isflac) { system("metaflac --import-tags-from=$COMMENTFILENAME $_"); } + else { system("vorbiscomment -c $COMMENTFILENAME -w $_"); } + system('rm', $COMMENTFILENAME); +} + +# Formats the first argument, adds the second argument to it +sub formatName +{ + my $name = shift; + my $prepend = shift; + chomp $name; # we add a newline ourselves + $name =~ s/_/ /g; # underscore - space + $name =~ s/^\s*//; # Remove leading space + $name =~ s/\s*$//; # Remove trailing space + $name =~ s/\b(\w)/uc($1)/eg; # Cap the words + $name = $prepend . $name . "\n"; +} + + +# Copyright (c) 2005 - 2008 John Wiggins +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA