Skip to content

Instantly share code, notes, and snippets.

@hitode909
Created March 17, 2012 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitode909/2056036 to your computer and use it in GitHub Desktop.
Save hitode909/2056036 to your computer and use it in GitHub Desktop.
Perlのソースコードに自動でセミコロンつけるやつ
#! /usr/bin/env ruby
file = ARGV.first
code = open(file).read
def append_semicolon(code, time)
code.split(/\n/).enum_with_index.map{|line, num|
time[num] == 1 ? line + ";" : line
}.join("\n")
end
(1.upto 1.0/0).each{ |i|
system "clear"
new_code = append_semicolon(code, i)
puts new_code
puts
puts
system("echo '#{new_code}' | perl -wc")
if $? == 0
puts "created out.pl"
open("out.pl", "w"){ |f|
f.write new_code
}
exit
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment