Ruby to perl 请帮帮忙看一下!
不熟悉ruby,现需改一脚本,好心人进来帮我一下#!ruby
#
# Cut header of SPL in spool folder to raw EMF
#
def spl2emf(fnm)
File.open(fnm + ".emf", "wb") {|fo|
File.open(fnm, "rb") {|fi|
str = fi.read
pos = str.index(" EMF")
if pos == nil
print "No EMF marker found; probably wrong file\n"
next
end
fo.write(str[(pos-40)..-1])
}
}
end
if __FILE__ == $0
ARGV.each {|fnm|
print fnm, "\n"
spl2emf(fnm)
}
end
-----------------------------------------
fo.write(str[(pos-40)..-1]) ########<---------------
------------------------------------------
#perl
$infile = "08017.SPL";
$outfile = "08017.SPL.emf";
open FH1,"<$infile";
$info = <FH1>;
close FH1;
#
#
#
open FH2,">$outfile";
print FH2 $info
close FH2
#end :em17: :em17:
页:
[1]