Hello,
The content of DATA are modified %hash value. Need to include %hash key before or after SOME_DATA to respective modified %hash key
Don't know how to search modified value and include respective key after or before SOME_DATA
__HASH__ $VAR1 = { 'Key1' => 'Cat.Mouse.Game.Lion.Tiger.Elephant', 'Key2' => 'Cat.Mouse.Game.Lion.Tiger.Lion', 'Key3' => 'Cat.Mouse.Game.Lion.Tiger.Monkey', };
__DATA__ Pigeon.Lion.Tiger.Elephant SOME_DATA Pigeon.Lion.Tiger.Lion SOME_DATA Pigeon.Lion.Tiger.Monkey SOME_DATA
__Example code__ my %hash = () my $file = 'master.txt'; open (my $OUT_FILE, '<', "TEXT_FILE") or die "ERROR"; while (<$OUT_FILE>) { print "$. \n" if /SOME_DATA/; #searching SOME_DATA and printing }
__OUTPUT__ Pigeon.Lion.Tiger.Elephant SOME_DATA (Key1) Pigeon.Lion.Tiger.Monkey SOME_DATA (Key3)
UPDATED:
%hash value "Cat.Mouse.Game" is replaced with "Pigeon" and placed in a text file along with SOME_DATA
Ignore "Pigeon" and match other characters. If there is a match, then include respective %hash Key before "SOME_DATA"
In reply to Array and Hash by waytoperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |