#!/usr/local/bin/perl
# 
# ascii2mush - convert ascii art to a mush attribute
#
# Usage: ascii2mush < ascii.txt > mush.txt
# (Or as a pipe with tinyfugue's /quote, etc.)
#
for ($i = 80; $i > 3; $i--) {
  $spaces = " " x $i;
  $prog .= "s/$spaces/[space($i)]/g;";
}
while (<>) {
  chop;		# Remove the newline
  s/\\/\\\\/g;  # Escape backslashes
  s/\[/\\[/g;   # Escape brackets
  s/\]/\\]/g;   # Escape brackets
  s/%/\\%/g;	# Escape percent signs
  s/^\$/\\\$/;  # Escape leading $
  s/^\^/\\\^/;  # Escape leading ^
  eval $prog;   # Change multiple spaces to space() calls
  s/ /%b/g;	# Change spaces to %b's
  $output .= $_ . "%r";		# Add the line, with a %r at the end
}
print "&ATTRIBUTE OBJECT = $output\n";


