bfdi533 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl @lines = <>; #print "Number of lines; $#lines\n"; $x = 0; foreach $ln (@lines) { @words = split /\s+/, $ln; foreach $word (@words) { $index{$word} = $x++; $count{$word}++; } } print "-=INDEX=-\n"; foreach $key (keys %index) { #print "[$key] $index{$key}\n"; #$bkey = pack("C*",$index{$key}); #print $key . chr(0) . $bkey . chr(0); printf "%s%c%x%c", $key, chr(0), $index{$key}, chr(0); } print "\n"; print "-=CONTENTS=-\n"; foreach $ln (@lines) { @words = split /\s+/, $ln; foreach $word (@words) { #print $index{$word} . " "; #$bword = pack("C*",$index{$word}); #print $bword . chr(0); printf "%x%c", $bword, chr(0); } print "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: help needed on encoding a text file
by hardburn (Abbot) on Apr 02, 2003 at 16:39 UTC | |
|
Re: help needed on encoding a text file
by dakkar (Hermit) on Apr 02, 2003 at 18:42 UTC | |
by bfdi533 (Friar) on Apr 02, 2003 at 19:55 UTC | |
by dakkar (Hermit) on Apr 03, 2003 at 11:17 UTC | |
by bfdi533 (Friar) on Apr 07, 2003 at 19:38 UTC | |
|
Re: help needed on encoding a text file
by Pardus (Pilgrim) on Apr 02, 2003 at 16:43 UTC | |
|
Re: help needed on encoding a text file
by bfdi533 (Friar) on Apr 02, 2003 at 18:06 UTC | |
by dakkar (Hermit) on Apr 02, 2003 at 18:36 UTC | |
|
Re: help needed on encoding a text file
by Thelonius (Priest) on Apr 02, 2003 at 18:18 UTC |