in reply to print the values

First, I would say that your indenting style is quite frankly horrible. I really like what grizzley did and I commend it! Your code also doesn't "run".

If you have a choice of print instead of push and print later, print it now!

#!/usr/bin/perl -w use strict; my %names = qw (NAME 1 AGE 1); while(<DATA>) { s/[{}\n]//g; #this substitute gets rid of {} and also #does the job of chomp; print "$_\n" if !exists($names{$_}); } # Prints: # SEX # ADDRESS # ADDRESS __DATA__ {NAME} {AGE} {SEX} {ADDRESS} {ADDRESS}