Advertisement
cd62131

Substitute

Feb 16th, 2017
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.48 KB | None | 0 0
  1. #!/usr/bin/ruby                                      
  2. param, template = ARGV                              
  3. params = nil                                        
  4. open(param) do |f|                                  
  5.   keys = f.gets.split                                
  6.   params = f.map {|line| keys.zip(line.split).to_h }
  7. end                                                  
  8. templ = open(template).gets                          
  9. params.each {|prms| puts templ.gsub(/\$\d+/, prms) }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement