in reply to Need to read certain number of chars in a file
Dunno how you can fail to do this with a C prog -- this is one of the rare instances where it would probably be simpler.
Anyway, if you want to work with individual characters in perl here's some clues:
#!/usr/bin/perl -w use strict; open (IN, "<$0") || die; # $0 is this script my $data; read(IN,$data,30); # read in first 30 characters close(IN); # now split those into an array of individual values my @chars = unpack('c*',$data); print chr($_)."\n" foreach (@chars);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need to read certain number of chars in a file
by ranrodrig (Novice) on Oct 18, 2010 at 20:35 UTC | |
by ikegami (Patriarch) on Oct 19, 2010 at 03:10 UTC |