Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
The first function must take a list of elements as an argument and check if there are
any duplicate elements in the list. And the second must delete duplicate elements from the list.
CODE:
for ($i=0;$i<$no;$i++)
{
print "Enter an element: ";
chomp ($text=(<STDIN>));
@content[$i]=$text;
}
@data=list(@content);
@new_data=del(@content);
sub list()
{
@data=@_;
$size=@data;
$i=0;
for($j=0;$j<$size;$j++)
{
for($k=$j+1;$k<$size;$k++)
{
if(@data[$j]==@data[$k])
{
@duplicate[$i]= @data[$j];
$i++;
}
}
}
print "Dupliacte items are: @duplicate\n";
}
sub del ()
{
@data=@_;
$size=@data;
for($j=0;$j<$size;$j++)
{
for($k=$j+1;$k<$size;$k++)
{
if(@data[$j]==@data[$k])
{
delete (@data[$j]);
}
}
}
return @data;
OUTPUT:
9. Write a Perl script that prints the count of all the cells used in the given module of a netlist in
a report file. The script must get two arguments. First is the name of the netlist and the second
is the name of module for which to determine the cell counts. Script must generate a log file
named "netlist_report.log"
CODE:
$lines=0;
$size=@text;
#print "$size\n";
for($i=0;$i<=$size;$i++)
{
if($text[$i]=~/^module\s*$module\s*\(/)
{
$end=0;
$cell_count=0;
for($j=$i+1;$j<=$size;$j++)
{
if($text[$j]=~/^\s*(\w+)\s\w+\s\(\s*\./)
{
$cell_count++;
}
if($text[$j]=~/^endmodule/)
{
last;
}
}
}
}
print "Total Cell count in the Module \"$module\": $cell_count\n";
OUTPUT:
10. Write a Perl programme that creates the skeleton of a test suite such that the directory
structure should be as in fig. 1. Also assume you need to copy two different #.v files residing in
the current working directory to test each test directory. Prompt the user to enter the number
of test directories to be created through the standard input. Pass the names of the #.v files that
need to be copied to each test directory as the command line argument.
CODE:
@v_files=@ARGV;
use Cwd;
$cur_dir = getcwd;
$temp="/";
$in_file_1=$cur_dir.$temp.$v_files[0];
$in_file_2=$cur_dir.$temp.$v_files[1];
$temp2="/Testcases/";
$dir=$cur_dir.$temp2;
mkdir $dir;
chdir($dir) or die "Can't chdir to c:\\mnt : $!";
OUTPUT: