anirbanphys:

Sorry, but this is turning out to be a longish post. Anyway, I've read your post, but don't know exactly what you're having trouble with. It's nice to see that you've provided some sample data and some code, but you didn't make it easy enough for (most) people to try to help. I happened to be in the right mood to slog through it, so you at least get a response from me, if no others. The easier you make it for people to try your code, the more likely it is that people will give it a go and respond. As it is, you have to slog through all the code to figure out how to build the file directory, and how to figure out what parameters to call it with. I'm not certain I guessed at everything correctly, but here goes!


OK, when I tried running your code with "perl -c pm_11105228.pl", it had a couple complaints:

$ perl -c pm_11105228.pl Unrecognized escape \v passed through at pm_11105228.pl line 47. Unrecognized escape \v passed through at pm_11105228.pl line 72. Scalar value @vol_temp[1] better written as $vol_temp[1] at pm_1110522 +8.pl line 38. Scalar value @vol_temp[0] better written as $vol_temp[0] at pm_1110522 +8.pl line 39. Scalar value @vol_temp[0] better written as $vol_temp[0] at pm_1110522 +8.pl line 41. Scalar value @vol_temp[0] better written as $vol_temp[0] at pm_1110522 +8.pl line 42. pm_11105228.pl syntax OK

Lines 47 and 72 have the same issue. Looking at line 47, we get:

my $file_name2 = "$in_macro/lib_pg/$in_macro\_$process_two$volt_1\v$te +mp\_pg.lib";

The problem is that you're using backslashes ('\') instead of forward slashes ('/') in your filename, so I just changed it to:

my $file_name2 = "$in_macro/lib_pg/$in_macro/_$process_two$volt_1/v$te +mp/_pg.lib";

I also made a similar fix to line 72. Perl generally "just works" if you use forward slashes to delimit the parts of path names. If you wanted to use backslashes, then you'd need to be sure you escaped your backslashes properly, which is a nuisance I avoid entirely by using forward slashes exclusively.

For the warnings on lines 38 through 42, it's telling you what to do to fix the problem, so I made those changes, too.

Since you don't use strict and warnings in your program, I was expecting more issues to crop up when I added them. However, I was pleasantly surprised to see that other than the issues listed, everything was fine. I left in strict and warnings, though, as it's an easy way to prevent errors.

Your directory structure and file naming was a bit much for me to try to reproduce, so I just made a subdirectory lib_pg and dumped your sample files in there. Then, to make it so that the code would find the files, I changed lines 46 and 47 to:

my $file_name1 = "lib_pg/$in_macro"; my $file_name2 = "lib_pg/$in_macro";

At this point, the code ran, discovered the files and printed some stuff. But I don't know if I structured everything correctly or not--this is where you could've done a little more work to make it easy on us. Anyway, it printed some stuff. However, I don't know (a) which lines in the code printed stuff, nor (b) what the correct content would be. To handle (a), I added a bit of info to the print statements, so I could see what was printing what, in an attempt to get a little further.

Your indentation was messy and inconsistent, so I cleaned that up a bit. I then noticed that the last section of your code was essentially duplicated, so I pulled it out into a subroutine to handle things.

I also noticed a few other things:

I stopped here, because I got the code in a nice enough state to work on. But I don't really know what you're asking for help with, at the moment. It looks like you've done most of the work in parsing the files and collecting the data. You're not doing anything with the data though. So I don't know if you're asking for help in storing the data in a structured form, or how to figure out what to compare with what, or exactly what the issue is.

I'll leave you with the code I ended up with:

use strict; use warnings; my $in_macro = $ARGV[0]; my $alpha_config = $ARGV[1]; if ($#ARGV!=1) { print "USAGE :: perl bias_vol_chk.pl <<CELL_NAME>> <<config_FILE> +> \n\n"; exit(1); } my $pvt_name; my $bias_voltage; my @bias_voltage; open my $ALPHAFILE, "<", $alpha_config or die "Can not open config_FIL +E"; while (my $line = <$ALPHAFILE>) { chomp $line; print "alpha[$.]: $line \n"; if ($line =~m/\s*cornerData\((.*)\)\s*\{(.*),TEMP\s*(.*)/g) { $pvt_name = $1; $bias_voltage = $2; print " PVT_NAME: $pvt_name\n"; print " BIAS_V: $bias_voltage\n"; @bias_voltage = split (',',$bias_voltage); if ($pvt_name =~m/^([a-z].*)([0-9]p.*)/) { my ($process, $vol_temp) = ($1, $2); my $process_two = substr($process, 0, 2); #got ff from ffg +p my @vol_temp = split ('v',$vol_temp); my $temp = $vol_temp[1]; my $volt_1 = $vol_temp[0]; $volt_1 =~ s/[0]$//; $vol_temp[0] =~ s/[0]$//; my $volt_2 = $vol_temp[0]; my @volt_2 = split('p',$volt_2); $volt_2 = join('.',@volt_2); #replacing p with . my $file_name1 = "lib_pg/$in_macro"; print " FNAME 1: $file_name1\n"; if (-e $file_name1) { my $data = handle_library_file($file_name1); # Do something with the $data } my $file_name2 = "lib_pg/$in_macro"; print " FNAME 2: $file_name2\n"; if (-e $file_name2) { my $data = handle_library_file($file_name2); # Do something with the $data } } } } sub handle_library_file { my $file_name = shift; open my $LIBFILE, "<", $file_name or die "Can not open INPUT liber +ty file $file_name: $!"; while (my $libline = <$LIBFILE>) { chomp $libline; if ($libline=~m/^\s*voltage_map\((.*)\)/g) { my @volt_array = ("$1"); my $lib_volt = $1; my @lib_volt = split (',',$lib_volt); print "FILE lib_volt: @lib_volt \n"; } } # After gathering and processing the data, return it! }

And if anyone else has any guesses as to what to do, I took his second code chunk, named it 'mnk_alpha' and put it in the same directory as the script (which I called 'pm_1115228.pl'). I then created a subdirectory named 'lib_pg' and dropped his third, fourth and fifth code chunks in that directory named 'ss0p905v100c', 'ffg0p82v100c' and 'tt0p4v100c', respectively. I'm pretty sure I got the $file_name1 and $file_name2 bit wrong, but at this point the question became unclear enough and I have written enough, that I'm kinda done with it, pending further input from the OP.

A sample run gives me:

$ perl pm_11105228.pl ffg0p82v100c mnk_alpha alpha[1]: put cornerData(ffg0p82v100c) {VDD 0.825,VDDQN 1.17,VDDM 1.17 +,TEMP 100} PVT_NAME: ffg0p82v100c BIAS_V: VDD 0.825,VDDQN 1.17,VDDM 1.17 FNAME 1: lib_pg/ffg0p82v100c FILE lib_volt: VDDQN 1.1 FILE lib_volt: VDDM 1.1 FILE lib_volt: VSS 0 FNAME 2: lib_pg/ffg0p82v100c FILE lib_volt: VDDQN 1.1 FILE lib_volt: VDDM 1.1 FILE lib_volt: VSS 0 alpha[2]: put cornerData(ssg0p905v100c) {VDD 0.825,VDDQN 1.1,VDDM 0.17 +,TEMP 100} PVT_NAME: ssg0p905v100c BIAS_V: VDD 0.825,VDDQN 1.1,VDDM 0.17 FNAME 1: lib_pg/ffg0p82v100c FILE lib_volt: VDDQN 1.1 FILE lib_volt: VDDM 1.1 FILE lib_volt: VSS 0 FNAME 2: lib_pg/ffg0p82v100c FILE lib_volt: VDDQN 1.1 FILE lib_volt: VDDM 1.1 FILE lib_volt: VSS 0 alpha[3]: put cornerData(tt0p40v100c) {VDD 0.825,VDDQN 1.07,VDDM 2.15, +TEMP 100} PVT_NAME: tt0p40v100c BIAS_V: VDD 0.825,VDDQN 1.07,VDDM 2.15 FNAME 1: lib_pg/ffg0p82v100c FILE lib_volt: VDDQN 1.1 FILE lib_volt: VDDM 1.1 FILE lib_volt: VSS 0 FNAME 2: lib_pg/ffg0p82v100c FILE lib_volt: VDDQN 1.1 FILE lib_volt: VDDM 1.1 FILE lib_volt: VSS 0 alpha[4]:

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: Comparing values from two different files and flag error by roboticus
in thread Comparing values from two different files and flag error by anirbanphys

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.