james28909 has asked for the wisdom of the Perl Monks concerning the following question:
it is returning an almost correct value of 10.65, but that is a little higher than what HxD hex editor reports in statistics... which is 10.43. Also i am pretty sure my math is right, but im not the best mathamagician though, loluse File::Slurp; my $file = read_file("file.bin"); my $data = unpack( 'H*', $file ); my $count =()= $data =~ /ff/g; my $size = (stat("file.bin"))[7]; my $dec = $count/$size; my $percentage = ($dec*100); print "$count\n"; print "$size\n"; print $percentage;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Computing the percentage of certain characters in a file
by AnomalousMonk (Archbishop) on Aug 04, 2014 at 23:38 UTC | |
by james28909 (Deacon) on Aug 05, 2014 at 02:24 UTC | |
by james28909 (Deacon) on Aug 05, 2014 at 05:03 UTC | |
by james28909 (Deacon) on Aug 06, 2014 at 00:02 UTC | |
by AnomalousMonk (Archbishop) on Aug 06, 2014 at 08:39 UTC | |
by james28909 (Deacon) on Aug 07, 2014 at 04:19 UTC | |
by AnomalousMonk (Archbishop) on Aug 07, 2014 at 09:02 UTC | |
|