Wondering if I could get some assistance.
Deleting paragraphs based on match in a hash.
Where I'm lost is getting the 'key' (PORNUM: *key*) from the paragraph in $_.
I'm very new to Perl, just a few long days/nights ... whatever they are!
Example data.#!/usr/bin/perl my @a, %hash; my $file = shift; open(list, "< $file") or die; chomp( @a=<list> ); close(list); @hash{@a}=@a; $/ = ""; # Example data # # $ cat hash # PP22x43@.5 # $ cat data # \n # Random lines # PORNUM: PP22x43@.5 # Random lines # \n # Random lines # PORNUM: PC12x120/25 while (<>) { ## manual test # print if !m/PORNUM: PP22x43@.5/ms; print unless exists $hash{ } } exit(0);
Example data file (Records have a leading blank line, first line is blank)PORNUM: PP22x43@.5 PORNUM: PC12x120/25
random lines of data PORNUM: PC21x21!2 random lines of data random lines of data random lines of data PORNUM: PP22x43@.5 random lines of data PORNUM: PP12x60@1 random lines of data random lines of data random lines of data PORNUM: PC12x120/25
In reply to Deleting paragraphs based on match in a hash by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |