#!/usr/bin/perl if (scalar @ARGV < 1) { print "usage: perl vpl.pl xxx.x [xxx.x.v]\n"; exit; } $ivpl = shift @ARGV; $opl = "$ivpl.pl"; if (scalar @ARGV > 0) { $vfile = shift @ARGV; } else { $vfile = "$ivpl.v"; } open(fh, "$ivpl") || die "can not open $ivpl"; open(ofh, ">$opl") || die "can not open $opl"; print ofh "open (vfh, \">$vfile\");\n"; while($line = ) { chomp $line; if ($line =~ /^;(.*)/) { # is perl program $perl_line = $1; $perl_line =~ s/print\s*"/print vfh "/; print ofh "$perl_line" ."\n"; } else{ $line =~ s/\\/\\\\/g; $line =~ s/"/\\"/g; print ofh "print vfh \"$line\\n\"" .";\n"; } } close fh; close ofh; # excute .opl file, and then delete tmp .opl file $syscmd = "perl $opl"; $ret = system("$syscmd"); if ($ret == 0) { print "generate $vfile ok!\n"; @ar = glob "$opl"; foreach $tmp (@ar) { unlink ($tmp); } } exit 0;