use strict; use warnings; while (my $str = ) { chomp $str; $str =~ s/\^\@$//; print "$str\n"; } __DATA__ himanshu.txt^@ himanshu-prg.txt^@ hel_llo-workd.txt^@ foo