|
楼主 |
发表于 2006-8-11 17:50:52
|
显示全部楼层
呵呵~
不好意思呀,我以为只是一些语法上的东西,所以没有贴。
只见过s/,就是s#这种东西我没有见过,在perl的模式匹配里替换的语法是这样的:s/pattern/replacement/,所以我猜测是不是用#代替了/,但是我把所有的#替换成了#运行的时候有错误。不知用意何在,大家见过这种写法吗?
#!/usr/bin/perl
$help = 1 unless @ARGV; // 命令行参数
foreach (@ARGV)
{
$help = 1 if /^-h(elp)?$/i;
push @files, $_ if (/^\S+.v$/ && -e $_ && -f _);
}
@files = () if $all;
if ($help)
{
$name = $0;
$name =~ s#.*/##;
print <<msg;
Display some help infomation...
Note: The output file is ".inst"
Usage:
$name #this help
$name -h #this help
$name -help #this help
$name m1.v #generate instance of modules in m1.v
msg
exit;
}
open FO, ">.inst";
print "output file: .inst\n\n";
foreach $file(@files)
{ do_inst($file); }
close FO;
sub do_inst()
{
my $file = $_[0];
open FI, "$file" || die "$!";
@fifo = (<FI>);
close FI;
print "Dealing $file ... \n";
$_ = join "", @fifo;
s#//.*\n##g; #Here, what's the mean #....
s#`timescale.*##;
s#task(.|\n)*endtask##g;
s#`(include|define|ifdef|else|endif).*##g;
s#^\s*##;
s#\s*$##;
@modules = split /endmodule/, $_;
foreach (@modules)
{
}
} |
|