in reply to Re: Perl binary file reading
in thread Perl binary file reading
Stops after 38 records - it should go up to some thousands... The lenght says its about only 1300 characters - it should be also some thousands... Regards, Keplermy $filename = "Words.txt"; open(my $fh, '<', $filename) or die "Could not open file '$filename' $ +!"; binmode $fh; my $data = <$fh>; $data =~ s/\x00/\ /gi; close $fh; my $length = length($data); my $count = 0; for(my $i=0;$i < $length/36;$i++){ my $name = substr($data,$i*36,28); my $book = ord(substr($data,$i*36 + 28,1)) + 1; my $v1 = ord(substr($data,$i*36 + 29,1)) + 1; my $v2 = ord(substr($data,$i*36 + 30,1)) + 1; print $name . " - " . "$book\:$v1\:$v2\n"; $count += 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl binary file reading
by choroba (Cardinal) on May 02, 2016 at 19:54 UTC | |
by kepler (Scribe) on May 02, 2016 at 23:48 UTC | |
by afoken (Chancellor) on May 03, 2016 at 07:07 UTC | |
by kepler (Scribe) on May 03, 2016 at 13:33 UTC | |
by afoken (Chancellor) on May 03, 2016 at 20:19 UTC | |
by pryrt (Abbot) on May 03, 2016 at 02:14 UTC | |
|
Re^3: Perl binary file reading
by graff (Chancellor) on May 03, 2016 at 01:25 UTC |