in reply to Re: Handling japanese file & comparison
in thread Handling japanese file & comparison

Thanks a lot graff for the help!

1. file encoding is : utf-8
2. How to open zipped file with encoding?

I've written my code, review it & let me know my mistakes.
1. I've read cat file into %catHash
2. opened the main file from which I've to extract line if exists in cat file.
3. if $line17 doesn't have value, $line14 value to be used; if both don't have, then read next line. Am I right below?
4. $line17 & $line14 in main file, some have leading 0's but not in that value in cat file. for example: cat file value: 101010100 & main file has: 0101010100
What do you suggest to handle this situation. I've tried replacing these leading 0's.

I'm new to perl & programming both, please help.

#!/usr/bin/perl use strict; my $f = "vc_20151003_1.zip"; my $cat = "5426085.csv"; my $file = $f; my $file =~ s/.zip/.csv/; ## Read the cat file into hash %catHash = (); open(CAT, $cat) || die "$cat couldn't be opened\n"; while(<CAT>) { @line = split /,/; $catHash{$line[1]}++; } close(CAT); open(OUT, ">".$file) || "$file couln't be opened for write\n"; open(IN,sprintf("zcat %s |", $f)) || die "Could not open pipe for $f +: $!"; while(<IN>) { chomp; my @line = split /\t/; $line[17] =~ s/^0+//; $line[14] =~ s/^0+//; if(exists($catHash{$line[17]}) || exists($catHash{$line[14]})) + { print OUT join("\t", @line) . "\n"; } else { next; } } close(IN); close(OUT);

Replies are listed 'Best First'.
Re^3: Handling japanese file & comparison
by CSharma (Sexton) on Oct 05, 2015 at 13:39 UTC
    Well, I've done this myself.
    Thanks for help!

    ~Csharma