perlprint has asked for the wisdom of the Perl Monks concerning the following question:

i have a string where each character(can be an alphabet,digit,slash,dot etc.,) is followed by a null charater ..i want to remove the null character and retain the rest of string ...the string on stdout appers like this "P A T C H I N S T " i thought its a space and used a reg ex but i didnot work ...can u pls give a regex..

Replies are listed 'Best First'.
Re: help me in giving a reg ex
by johngg (Canon) on Oct 21, 2009 at 11:10 UTC
    i thought its a space

    If you are not sure what it is then you could try to find out with something like this.

    $ perl -e ' > $string = qq{P\0A\0T\0C\0H\0I\0N\0S\0T\0}; > printf( qq{0x%02x: %s\n}, ord, $_ ) for split m{}, $string;' 0x50: P 0x00: 0x41: A 0x00: 0x54: T 0x00: 0x43: C 0x00: 0x48: H 0x00: 0x49: I 0x00: 0x4e: N 0x00: 0x53: S 0x00: 0x54: T 0x00: $

    I hope this is of use.

    Cheers,

    JohnGG

Re: help me in giving a reg ex
by Anonymous Monk on Oct 21, 2009 at 09:48 UTC
Re: help me in giving a reg ex
by rovf (Priest) on Oct 21, 2009 at 09:59 UTC

    If you are really sure that this is what you want to do, why use a regexp? You could remove it using tr//d. If you fancy regexps, s/\0//g should do the job.

    -- 
    Ronald Fischer <ynnor@mm.st>