in reply to pattern matching

To remove trailing "^@", you could use the substitution operator:
use strict; use warnings; while (my $str = <DATA>) { chomp $str; $str =~ s/\^\@$//; print "$str\n"; } __DATA__ himanshu.txt^@ himanshu-prg.txt^@ hel_llo-workd.txt^@ foo

prints:

himanshu.txt himanshu-prg.txt hel_llo-workd.txt foo

Replies are listed 'Best First'.
Re^2: pattern matching
by Anonymous Monk on Mar 04, 2009 at 15:02 UTC
    Probably he wants =~ s/[^\w.]*$//; because
    $ perl -le print(chr(0)) |cat -v ^@