in reply to Re^3: Extracting Data from a second line
in thread Extracting Data from a second line
-s FILE is often too big — not just when using DATA — since read is to be given a number of characters (as opposed to a number of bytes) when binmode isn't set to raw.
open(FILE, $0) or die("Unable to open $0: $!\n"); $read = read(FILE, $buf='', -s FILE); print("Character mode:\n"); print("Bytes requested: ", -s FILE, "\n"); # 580 print("Chars read: ", $read, "\n"); # 560 print("Chars read: ", length($buf), "\n"); # 560 seek(FILE, 0, 0); binmode(FILE); print("\n"); $read = read(FILE, $buf='', -s FILE); print("Bin mode:\n"); print("Bytes requested: ", -s FILE, "\n"); # 580 print("Chars read: ", $read, "\n"); # 580 print("Chars read: ", length($buf), "\n"); # 580
But like you said, it's ok if it's too big.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Extracting Data from a second line
by kwaping (Priest) on Feb 16, 2006 at 19:25 UTC | |
by ikegami (Patriarch) on Feb 16, 2006 at 19:34 UTC | |
by kwaping (Priest) on Feb 16, 2006 at 19:37 UTC | |
by ikegami (Patriarch) on Feb 16, 2006 at 19:41 UTC | |
by kwaping (Priest) on Feb 16, 2006 at 20:04 UTC | |
|