vikashiiitdm has asked for the wisdom of the Perl Monks concerning the following question:
dear monks, i had been trying to make a file analyzer which reads keys from a file named labels seperates them using the delimiters @ each line and then checking for the keys from other file en_1000 and hi_1000 and printing them on another. i wrote this code , but its outputting nothing. i tried to check it by placing a print @ the 3rd line of the main program. but still no clue.
#!/bin/env perl use strict; use warnings; use Data::Dumper; sub split_english() { open(ENGLISH,">>en_index") or die $!; my @engli=<ENGLISH>; foreach my $keys(@engli) { chomp($keys); my @key_en = split(/\:/,$keys); print ENGLISH @key_en; } my $key_enco= join '|',my @key_en; my $file2='/home/vikash/pro_1/en_1000'; open my $fh1, $file2 or die $!; my %key_en; while (<$fh1>) { while (m{\b($key_enco)\b}g) { $key_en{$1}++; } } open(INFOO,">>result"); print INFOO Dumper(\%key_en); close INFOO; } sub split_hindi() { open(HINDI,">>hi_index") or die $!; my @hin=<HINDI>; foreach my $key(@hin) { chomp $key; my @key_hin = split(/\;/,$key); print HINDI @key_hin; } my $key_hico= join '|',my @key_hin; my $file='/home/vikash/pro_1/main_database_hindi'; open my $fh, $file or die $!; my %key_hin; while (<$fh>) { while (m{\b($key_hico)\b}g) { $key_hin{$1}++; } } open(INFOOO,">>result"); print INFOOO Dumper(\%key_hin); close INFOOO; print "*************************************************************** +***********\n******************************************************** +******************"; } open(HANDLE, ">>/home/vikash/pro_1/labels") or die $!; my @keys=<HANDLE>; close HANDLE; print @keys; foreach my $line(@keys) { chomp($line); (my $english_index, my $hindi_index ,my $nua)=split(/\|/,$line); open (HANDLE,">en_index") or die $!; print HANDLE $english_index; open(HANDLE_HI,">hi_index") or die $!; print HANDLE_HI $hindi_index; split_english(); split_hindi(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reading from and writing to a file
by toolic (Bishop) on Jul 14, 2011 at 13:17 UTC | |
by vikashiiitdm (Novice) on Jul 14, 2011 at 14:26 UTC | |
|
Re: reading from and writing to a file
by jethro (Monsignor) on Jul 14, 2011 at 13:18 UTC |