package subst;
sub subst_casename
{
my ($file,$tmp) = @_;
open(FILE,"<$file") || die "Cannot open this file!";
my @lines = <FILE>;
close FILE;
my @newlines;
foreach(@lines)
{
$_ =~s/\/case.*\.(v|fsdb)/\/$tmp/g;
push(@newlines,$_);
}
open(FILE,">$files") || die "Connot open this file!";
print FILE @newlines;
close FILE;
}
1;
使用:
#!/usr/bin/perl -w
use lib ‘/home/wudw/script/perl_lib’;
use subst;
subst::subst_casename(参数1,参数2);