Hi , I am new to perl scripting. I have 2 new input files, file1 and file2. I have to retrieve second field of each record from first file and check if it is existing in second file, file2. I have read file2 contents and stored it in an array. Please find my file2(npn.txt) contents below:
File1 contents:11111111 10001781 11111222
Based on above files, what i need is to print records if second field is not matching.Hence my record should contain:abc,,,, abc,10001781,,, abc,10001782,,, abd,10001783,,,
But it prints:abc,,,, abc,10001781,,, abc,10001782,,, abd,10001783,,,
Can anyone please guide me what is the bug in thi. Please find my code snippet below:abc,10001781,,, abc,10001782,,, abd,10001783,,,
... open (info, "<npn.txt"); chomp (@contents = (<info>)); close info; $record = $_."~"; @flds = split(/\,/, $record); if (grep !/^$flds[1]/, @contents) { print $record; } ' >hi5res.txt
In reply to grep in Perl by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |