#!/usr/bin/perl # ==================================================================== # Copyright (c) 1998-1999 Astonish Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ==================================================================== # # untabify.pl # blazonry.com # Mon Oct 30, 2000 10:34:03 # # Expand tab character to N spaces # # USAGE: untabify.pl use strict; # expand to how many spaces my $n = 4; my $file = $ARGV[0]; my $wholefile; print "untabify.pl ver 0.0.1\n"; print "blazonry.com\n\n"; if (!$file) { print " No File Specified.\n"; print " Please specify which file to convert tabs to spaces.\n"; print " Usage: untabify \n\n"; exit(1); } # read in file open (IN, "<$file") || die ("Error Opening $file for Reading.\n"); { # slurp in whole file undef $/; $wholefile = ; } close(IN); my $spacestr=""; my $i=0; # create space str to n spaces while ($i<$n) { $spacestr = $spacestr . " "; $i++; } # convert tabs to spaces $wholefile =~ s/\t/$spacestr/gms; # write out file open (OUT, ">$file") || die ("Error Opening $file for Writing.\n"); print OUT $wholefile; close (OUT); print "Finished.\n"; exit(0);