hey mate
is this what you need?
use Inline::Files; %h = qw/and nand or xor/; $f = sub { $fh = shift; while(<$fh>){ chomp; $m = $_ and $a{$m} = {} and next if /^module/; $l = \@{$a{$m}{'in'}} if /^input/; $l = \@{$a{$m}{'out'}} if /^output/; $l = \@{$a{$m}{'op'}} and ($_ = $_) =~s/$&/$h{$&}/ if /^and|^o +r/; $l = \@{$a{$m}{'cond'}{$_}} if /^if/; next if /endmodule/; push @{$l}, $_; } return %a; }; %r = &$f(FILE1); %s = &$f(FILE2); for( keys %r){ print "\n\n$_\n"; print "@{$r{$_}{'in'}}\n"; print "@{$r{$_}{'out'}}\n"; print "$r{$_}{'op'}[0]"; for $x (keys %{$r{$_}{'cond'}}){ if(defined $s{$_}{'cond'}{$x}){ print "\n",join"\n",@{$s{$_}{'cond'}{$x}}; } else { print "\n",join"\n",@{$r{$_}{'cond'}{$x}}; } } print "\nendmodule\n"; } __FILE1__ module and_1 (y,a,b); input a, b; output y; and x1 (y,a,b); if ( a == b) y = 1'b0; else y = 1'bx; if ( a == 1 ) y = 1'b1; else y = 1'b0; endmodule module or_1 (y,a,b); input a, b; output y; or x1 (y,a,b); if ( a == b) y = 1'b0; else y = 1'bx; if ( a == 0 ) y = 1'b0; else y = 1'b1; endmodule __FILE2__ module and_1 (y,a,b); input a, b; output y; and x1 (y,a,b); if ( a == b) y = 1'bx; else y = 1'b0; if ( a == 0 ) y = 1'bx; else y = 1'b1; endmodule module or_1 (y,a,b); input a, b; output y; or x1 (y,a,b); if ( a == b) y = 1'b1; else y = 1'b0; if ( a == 0 ) y = 1'bz; else y = 1'bx; endmodule

In reply to Re: Read conditional strings from a file, search and replace same string in another file in perl by Lennotoecom
in thread Read conditional strings from a file, search and replace same string in another file in perl 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.