in reply to manipulating file contents

Here are two examples that does the same thing. I think the second one is easier to understand for someone new to Perl.
while(<>){ print "$1;\n" if /^(Key [0-5] 0x[\da-f]{14})/i; } while( my $line = <>){ if( my ($match) = $line =~ /^(Key [0-5] 0x[\da-f]{14})/i ){ print "$match;\n"; } }
or maybe you want a one-liner:
perl -ni -le 'print "$1;" if /^(Key [0-5] 0x[\da-f]{14})/i' file.txt
This will change "file.txt".