It's contents that transform words matched keyword in regular expression into other words.
Keywords are ProjectName , author and date.
Next codes are this program.
#!/usr/bin/ruby
class TextValue
# class's member
TABLE = {
"ProjectName"=>"AAA",
"author"=>"bulldog",
"date"=>Time.now.strftime("%Y-%m-%d")}
end
begin
TextValue::TABLE["ProjectName"] = ARGV[1]
# open the file
tmp = open(ARGV[1])
while line = tmp.gets()
if /\$(\w*)\$/ =~ line thenprint line.gsub(/\$(\w*)\$/, TextValue::TABLE[$1])
else
print line
end
end
tmp.close
end
 


No comments:
Post a Comment