in reply to hexdump/od/perl question

tr/\0375//d;
or
s/\0375//g;

Update: As shown by oxone, \0375 is wrong. It should be \375. While I tested the above, my test was incomplete/flawed.

Replies are listed 'Best First'.
Re^2: hexdump/od/perl question
by EvanCarroll (Chaplain) on Aug 10, 2007 at 17:33 UTC
    This is what I had originally thought too, but
    my %db; foreach my $file ( @ARGV ) { print "Opening $file" if DEBUG; open ( my $fh, '<', $file ) or die "can not open $file" ; while ( my $line = <$fh> ) { chomp $line; $line =~ tr/\0375//d; next unless $line =~ /(.*?)[.-]*\t(.*)/; my ( $k, $v ) = ( $1, $2 ); $db{$k} = undef; } } print for keys %db;
    still has the funky characters on output.


    Evan Carroll
    www.EvanCarroll.com

      I tested my code, so something doesn't jive. Try adding the following to your code:

      use Data::Dumper qw( Dumper ); local $Data::Dumper::Useqq = 1; print(Dumper($line));

      Put the print before the tr///d.

        Nice application of data::dumper:
        $VAR1 = "STOCK NO\375--------................... D53006\t\r";


        Evan Carroll
        www.EvanCarroll.com