Hello all,
Thank to all. I found out that there is a perl module member.pm available which should perform the same function as Skill language member().
Again I am stuck in the loop. I want to print the pair of integer values for only the member of @arr e.g. in this case the pair integer values for Stack3 and Stack5 should be printed. Somehow the member function is reading only the first element of my array.Somebody advice where I am doing wrong?
Here is my code;
#!/usr/bin/perl -w
sub member {
my $target = shift or die "No target in member/2 ";
for (0..$#_) {
return $_ if $_[$_] eq $target;
}
return undef ;
}
@arr =
qw/DRAM1.new_quad_stack.3 DRAM1.new_quad_stack.5 /;
open (IN , "$file");
while () {
next unless /@arr[member($_,@arr)]/ ;
while () {
last if /End/ ;
print $_ ; }
}
close IN ;
And here is the file; *******Voltage********* *[PRD=S][BLD=4.0.0][OS=2000][CN=MUCW6086][USR=
+Djordjev][PYM=1023.004MB][PKM=]
*[DC=Y][PSE=Y][TLML=N][NRTB=Y][IPC=N][PC=N][DLD=N][TS=232303]
*[FN=CA_2T_400_8ranks.cur][DT=Wed_Jul_14_02:15:17_2004][LC=red][LS=RL]
+[LP=NN][LW=1][LM=NN][LMS=1][LMI=1]
**************Curve***************
DRAM1.new_quad_stack.3 DRAM1.new_quad_stack.1::GND red V1.
0.000000e+000 1.508947e+0003
1.162272e-012 1.508947e+0003
2.324544e-012 1.508947e+0003
3.486816e-012 1.508947e+0003
4.649088e-012 1.508947e+0003
5.811360e-012 1.508946e+0003
**************End***************
*[PRD=S][BLD=4.0.0][OS=2000][CN=MUCW6086][USR=Djordjev][PYM=1023.004MB
+][PKM=]
*[DC=Y][PSE=Y][TLML=N][NRTB=Y][IPC=N][PC=N][DLD=N][TS=232303]
*[FN=CA_2T_400_8ranks.cur][DT=Wed_Jul_14_02:15:17_2004][LC=cyan][LS=RL
+][LP=NN][LW=1][LM=NN][LMS=1][LMI=1]
**************Curve***************
DRAM1.new_quad_stack.4DRAM1.new_quad_stack.1::GND cyan V2.
0.000000e+000 1.508947e+0004
1.162272e-012 1.508947e+0004
2.324544e-012 1.508947e+0004
3.486816e-012 1.508947e+0004
4.649088e-012 1.508947e+0004
5.811360e-012 1.508947e+0004
**************End***************
*[PRD=S][BLD=4.0.0][OS=2000][CN=MUCW6086][USR=Djordjev][PYM=1023.004MB
+][PKM=]
*[DC=Y][PSE=Y][TLML=N][NRTB=Y][IPC=N][PC=N][DLD=N][TS=232303]
*[FN=CA_2T_400_8ranks.cur][DT=Wed_Jul_14_02:15:18_2004][LC=red][LS=RL]
+[LP=NN][LW=1][LM=NN][LMS=1][LMI=1]
**************Curve*************** DRAM1.new_quad_stack.5DRAM1.new_qua
+d_stack.1::GND red V3. 0.000000e+000 1.508947e+0005
1.162272e-012 1.508947e+0005
2.324544e-012 1.508947e+0005
3.486816e-012 1.508947e+0005
4.649088e-012 1.508947e+0005
5.811360e-012 1.508947e+0005
**************End***************
20050627 Edit by ysth: code tags
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|