in reply to Re: hexdump/od/perl question
in thread hexdump/od/perl question

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

Replies are listed 'Best First'.
Re^3: hexdump/od/perl question
by ikegami (Patriarch) on Aug 10, 2007 at 17:37 UTC

    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
        That line doesn't add anything to %db — the next gets executed since the regexp doesn't match — so it's not the source of your problem.