MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

  • Ruby

Ruby

Ruby is a general purpose programming language.

Receive data in stdin from pipe

   1 #!/usr/bin/ruby
   2 # cat records.txt | ruby processrec.rb
   3 startRec=false
   4 endRec=false
   5 records=[]
   6 STARTREC="START\n"
   7 ENDREC="END\n"
   8 EMPTY=""
   9 
  10 ARGF.each do |line|
  11 
  12   if line.end_with?(STARTREC)
  13     startRec=true
  14   end
  15 
  16   if line.end_with?(ENDREC)
  17     endRec=true
  18   end
  19 
  20   if startRec and endRec==false and line.end_with?(STARTREC)==false and  line.end_with?(ENDREC)==false
  21     records.push(line.gsub(/\n/,EMPTY) )
  22   end
  23 
  24   if startRec and endRec
  25     out=EMPTY
  26 
  27     records.each do |item|
  28       out = "#{out} #{item}"
  29     end
  30 
  31     puts out
  32     startRec=false
  33     endRec=false
  34     records=[]
  35   end
  36 end
  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01