#!/usr/bin/env ruby # -- ruby to perl converter (just a joke ;P) # # NISHI Takao # Time-stamp: <2004-04-01 10:28:51 zophos> # def usage $stderr<< <<'_EOS_' convert from ruby script to perl script Usage: ruby2perl [option] rubyscript option: -o filename : output filename [STDOUT] -p path : path to perl [guess] -r path : path to ruby [guess] -h, --help : show this message and quit _EOS_ exit(-1) end def convert(infile,outfh,perl_path,ruby_path) begin outfh<< DATA.read.sub('#{perl}',perl_path).sub('#{ruby}',ruby_path) File.foreach(infile){|l| outfh<1); ($fh,$filename)=tempfile(DIR=>$dir); while(){ print $fh $_; } $ruby="#{ruby}"; if($ruby eq ""){ $ruby=readpipe("which ruby"); chomp($ruby); } system($ruby,$filename,@ARGV); __END__