Create a program that output's itself as a series of punch cards Create a program that output's itself as a series of punch cards:



Rules:


You can use any programming language.
The output (i.e. punch cards) can be ASCII art.
Each line of code must be able to be punched into a single 80 column x 9 row punch card - i.e. you can only use 80 characters.
To fit in the 9 rows you need to encode your characters using 4-bit BCD.
Extra kudos if you use an old programming language like FORTRAN.


Background


You can find out more about computer punch cards here.
Doug Jones paper on punch card codes.
Ruby - 925

I'll get the ball rolling. Run as "ruby hammer.rb hammer.rb".

Golfed


def z x
l=x.unpack u='C*'
d=[]
(0..9).each do|i|d&lt;&lt;[].fill(48+i,0,80);end
d&lt;&lt;a=[].fill(32,0,80)
d&lt;&lt;a.dup
h=Hash.new
i=0;' abcdefghi'.unpack(u).each do|c|h[c-32]=[i,11];h[c]=[i,11,0];i+=1;end
i=0;' jklmnopqr'.unpack(u).each do|c|h[c-32]=[i,10];h[c]=[i,10,11];i+=1;end
i=0;'  stuvwxyz'.unpack(u).each do|c|h[c-32]=[i,0];h[c]=[i,0,10];i+=1;end
h[47]=[1,0]
i=0;'0123456789-&'.unpack(u).each do|c|h[c]=[i];i+=1;end
i=0;'  :#@\'="'.unpack(u).each do|c|h[c]=[i,8];i+=1;end
i=0;'  [.&lt;(+|'.unpack(u).each do|c|h[c]=[i,8,11];i+=1;end
i=0;'  ]$*);^'.unpack(u).each do|c|h[c]=[i,8,10];i+=1;end
i=0;'  \,%_&gt;?'.unpack(u).each do|c|h[c]=[i,8,0];i+=1;end
h[32]=[]
i=0;l.slice(0,80).each do|c|h[c].each do|r|d[r][i]=215;end;i+=1;end
puts'    %s'%('_'*81)
puts'   /%-80s |'%l.pack(u)
puts'  / %s |'%d[11].pack(u)
puts' /  %s |'%d[10].pack(u)
(0..9).each do|i|puts'|   %s |'%d[i].pack(u);end
puts'|%s|'%('_'*84)
end
ARGF.each do|l|z l.chop;end


Ungolfed


def punch029(line) # line is array of ASCII characters in ordinal (integer) form
  chad=[]
  (0..9).each do |i| chad&lt;&lt;[].fill(48+i,0,80) end
  chad&lt;&lt;[].fill(32,0,80)
  chad&lt;&lt;[].fill(32,0,80)

  r10 = 10-10
  r11 = 11-1
  r12 = 12-1
  # Reward "bad" input characters with all-row multi-punch.
  # hash = Hash.new( [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] )
  #
  #   OR
  #
  # Reward "bad" input characters by letting Ruby puke. (Jam the machine.)
  hash = Hash.new
  '0123456789-&'.unpack('C*').each_with_index do|c,i| hash[c]=[i] end
  ' ABCDEFGHI'.unpack('C*').each_with_index do|c,i| hash[c]=[i,r12] end
  ' JKLMNOPQR'.unpack('C*').each_with_index do|c,i| hash[c]=[i,r11] end
  ' /STUVWXYZ'.unpack('C*').each_with_index do|c,i| hash[c]=[i,r10] end
  '  :#@\'="'.unpack('C*').each_with_index do|c,i| hash[c]=[i,8] end
  '  [.&lt;(+|'.unpack('C*').each_with_index do|c,i| hash[c]=[i,8,r12] end
  '  ]$*);^'.unpack('C*').each_with_index do|c,i| hash[c]=[i,8,r11] end
  '  \,%_&gt;?'.unpack('C*').each_with_index do|c,i| hash[c]=[i,8,r10] end
  ' abcdefghi'.unpack('C*').each_with_index do|c,i| hash[c]=[i,r12,r10] end
  ' jklmnopqr'.unpack('C*').each_with_index do|c,i| hash[c]=[i,r11,r12] end
  '  stuvwxyz'.unpack('C*').each_with_index do|c,i| hash[c]=[i,r10,r11] end
  hash[32] = []              # fix space

  hole = 215
  line.slice(0,80).each_with_index do |c, index|
    hash[c].each do |row| chad[row][index] = hole end
  end

  puts '    %s' % ('_'*81)
  puts '   /%-80s |' % line.pack('C*')
  puts '  / %s |' % chad[11].pack('C*')
  puts ' /  %s |' % chad[10].pack('C*')
  (0..9).each do |i|
    puts '|   %s |' % chad[i].pack('C*')
  end
  puts "|%s|" % ('_'*84)
end
#        1         2         3         4         5         6         7         8
#2345678901234567890123456789012345678901234567890123456789012345678901234567890

ARGF.each do |line|
  punch029(line.chomp.unpack('C*'))
end