Hello Perl Experts,

I am facing a problem day-in and day-out with my perl code. There are
a couple of subroutines in it.  Below I am writing the stub-form of my
perl code.

===================================================================
#!/usr/local/bin/perl
#Some comments
...
use strict;
use warnings;
no warnings 'uninitialized';
use Switch;
use IPC::Open2;
use FileHandle;

use vars qw($BFE_INST_DIR $techNode $gdsFile $netFile $topCellName
$excludeCells $outputFileName $pgNets $signalNetsOnly);

sub main {
        &setup ();
        &extractSPRL ();
        &prepSVDB ();
        &updateNetPairsDB ();
}

sub setup {
}

sub extractSPRL {
}

sub prepSVDB {
}

sub loadNxfDB {
}

sub preProSprlDB {
}

sub readDefectData {
        my $defectDataFH=new FileHandle;
        open ($defectDataFH,$_[0]) or die "Error: Cannot load defectivity
data, $_[0]\n";
        print "Loading defect data ... ";
        my %short;
        while ($_=$defectDataFH->getline) {
                chomp;
                print "P8: $_\n";
                @_=split (/ /,$_);
                print "P9: @_\n";
                if ($_[0]=~/SHORT/) {
                  .... # performs some initializing kind of stuff and
returns a hash to the caller.
                }
}

sub readLayerMap {
}

sub execQuery {
}

sub calcWCAR {
}

sub updateNetPairsDB {
        my %nxfDB=&loadNxfDB
("\/tmp\/${topCellName}\/LVS\/svdb\/${topCellName}.nxf");
        &preProSprlDB 
("\/tmp\/$topCellName\/SPRL\/sprl.dat","\/tmp\/$topCellName\/SPRL\/mod_sprl.dat");
        my %short=&readDefectData ("$BFE_INST_DIR\/decks\/$techNode.ymps");
        my %layerMap=&readLayerMap ("$BFE_INST_DIR\/decks\/$techNode.map");
        my $readBuff=new FileHandle;
        my $writeBuff=new FileHandle;
        my $queryLogFH=new FileHandle;
        my $sprlDBFH=new FileHandle;
        my $queryResponse;
        my %wcarDB;
        ........
         #lot of stuff goes on after this.
}

#Finally I call the main subroutine
&main ();
===================================================================

I am calling lot of subroutines in updateNetPairsDB () subroutine and
readDefectData () is one of them. If I define all the subroutines in
the sequence mentioned above then, I face lot of wierd problems in
readDefectData () function. For example, have a look at the
readDefectData () function, the construct where I am comparing whether
$_[0]=~/SHORT/ never works. You will say that the file from where I am
reading might not have the data in expected format. Let me give one or
two exmaple entries from that file

===================================================================
mechanism=ME1_SHORT x=3 y=10 k0=90
mechanism=ME2_SHORT x=5 y=10 k0=20
===================================================================

There are a couple of things which I tried to make my code work in the
expected fashion

+ I substituted the '=' in $_[0] with ':'   --- This worked

+ I used another variable instead of $_ for reading line and
performing other operations ---  did not work

+ I tried to split the value in $_[0] before comparing --- did not
work and infact it dont even performed splitting ..heaven knows why?

+ I declared one or two dummy variables and performed some unecessary
comparison operations --- again did not work and infact comparison in
those unecessary options also did not work.

+ I changed the sequence in which I had called the various functions
in updateNetPairsDB () function ---- did not work either

+ I changed the sequence in which the functions are defined/declared
to a different sequence --- THIS ONE WORKED LIKE A CHARM.

Also, any of the above attempts I did not get any warnings or errors
during initial compilation.
Also, the subroutine readDefectData when written in another perl
program with only this function worked seamlessly.

This is something extremely unusual for me as I am a beginner in perl
or rather I should say scripting languages. It had never use to happen
with C/C++. I had earlier faced similar issues with some perl programs
which I had written before.

Is there something wrong in the coding style which I am using, which
can potentially cause perl parser to behave abnormally? Are there any
specific guidelines to avoid these kind of problems afront? I am
planning to implement another big job in perl and need to make a
decision whether I should stick with perl or go back to C/C++. Please
help me out with this.

-- 
Regards
Madhur Kashyap

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to