Because u are using strict u need to declare all of ur variables with "my". I can't see such a declaration for "@sre" in ur example. If u can tell something abt the error that would be very helpful. May be it's too early for me but i have a hard time figuring out what u are trying to do with every element of @modify?? Thanx, -Sharad
-----Original Message----- From: Boon Chong Ang [mailto:[EMAIL PROTECTED] Sent: Saturday, June 14, 2003 1:38 AM To: Gupta, Sharad; [EMAIL PROTECTED] Subject: RE: compare, checking and listing Hi, This is the script that I wrote using the Gupta approached. However, I received error when I run it. The goal is to get three output file. One is contains all the pin matched from array 1 to array 2, the second one is the elements from array 1 that don't match any elements from array 2 and third file is elements from array 2 that don't match any elements from array 1. Can some one help me to debug it. Thanks in advance! #!/usr/bin/perl -w use strict; my $infile = "port_dir_net_list.txt"; my $infile1 =$ARGV[0]; open IN, "$infile" or die $!; open INJ, "$infile1" or die $!; open (OUT, "> data.out") || die $!; open (OUTE,"> error-layout.out")|| die $!; open (OUTF,"> error-netlist.out")|| die $!; my @content=<IN>; my @modify=<INJ>; close(IN); close(INJ); foreach my $mod (@modify){ if($mod=~s/pin/pin/g){ if($mod=~s/VCC/VCC/g){} elsif($mod=~s/VSS/VSS/g){} else{ my @ml=split(/\s+/, $mod); $ml[1]=~s/\"//g; push @sre,$ml[1]; } } else{} } print OUT 'Layout Netlist'; print OUT "\n"; print OUTE 'Layout Error Pin'; print OUTE "\n"; print OUTF 'Netlist not matched pin'; print OUTF "\n"; @[EMAIL PROTECTED]; @[EMAIL PROTECTED]; foreach my $item (@content) { my $check=$item; $check=~s/\[//g; $check=~s/\]//g; chomp($check); foreach my $test (@sre){ chomp($test); if($check eq $test){ print OUT "$test $check \n"; } else{} } } foreach my $element (@content){ print OUTF "$element if(!grep{$element} @sre)"; } foreach my $mu (@sre){ print OUTE "$mu if(!grep{$mu} @content)"; } close(OUT); close(OUTE); close(OUTF); Best regards, ABC -----Original Message----- From: Gupta, Sharad [mailto:[EMAIL PROTECTED] Sent: Saturday, June 14, 2003 12:37 PM To: Boon Chong Ang; [EMAIL PROTECTED] Subject: RE: compare, checking and listing One way: To find out elements which are in test2 and not in test1: #!-*-perl-*-<ur perl path> use strict; my @test1 = qw(1 2 3 4); my @test2 = qw(1 2 5 6 7 8); foreach my $element(@test2) { print $element if([EMAIL PROTECTED]); } -Sharad -----Original Message----- From: Boon Chong Ang [ mailto:[EMAIL PROTECTED] Sent: Friday, June 13, 2003 9:19 PM To: [EMAIL PROTECTED] Subject: compare, checking and listing Hi, I have two array, @test1, @test2. Just say, I want compare @test2 with @test1 in such manner. @test2 could contains more, less or equal elements compare to @test1 which I don't know. I want to write a perl script to compare @test2 to @test1 and list out those element within @test2 that is not represent within @ test1 and those elements within @test1 that has not found the match from the @test2 How do I accomplish such task efficiently? Thank you & best regards, ABC