Another approach is read the file2 content and split each line based on ':', and save in a hash, key will be 'enable_pad','c_pad','b_pad',etc and other string as value.
Read file1 and check each line exists in hash or not, if exists print it.
use strict; use warnings; open my $FILE2, "<", "file2.txt" or die "Cannot open file2 file: $!"; open my $FILE1, "<", "file1.txt" or die "Cannot open file1 file: $!"; my %hash; while (my $eachline = <$FILE2>) { chomp($eachline); my($key,$value)=split(':',$eachline,2); $hash{$key}=$value; } while (my $line = <$FILE>) { chomp($line) if(exists $hash{$line}) { print $line:$hash{$line} } else{print "$line does not exist in file2"} }
In reply to Re: How to read the regular expression from another file?
by vinoth.ree
in thread How to read the regular expression from another file?
by sumathigokul
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |