File: hsplit.rb

package info (click to toggle)
howm 1.4.4-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,708 kB
  • sloc: lisp: 7,770; sh: 3,408; ruby: 996; makefile: 96
file content (33 lines) | stat: -rwxr-xr-x 668 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/ruby -s
# -*- coding: euc-jp -*-
# -*- Ruby -*-

def usage
  name = File::basename $0
  print <<EOU
#{name}: howm , եʬ (ȴ)
()
  #{name} 2004_10_10.txt
   2004_10_10.txt.aa, 2004_10_10.txt.ab,  Ǥ
(ץ)
  -prefix=hoge.      hoge.aa, hoge.ab,  Ǥ
  -help ޤ -h    Υåɽ
EOU
end

#####################################

if ($help || $h || ARGV.length == 0)
  usage
  exit 0
end

$prefix ||= ARGV[0] + '.'
ext = 'aa'

ARGF.readlines.join.split(/^= /).each_with_index{|x, i|
  next if x.empty?
  x = '= ' + x if i > 0
  open($prefix + ext, 'w'){|io| io.print x}
  ext.succ!
}