a short non-working Perl script

P

Paul Lalli

Gunnar said:
Then I have a problem with the maths. Which 4 posts explain that the
STDIN contents in $buffer is replaced by the return value from read()?


Alright, fine, I overestimated. Two posts:
http://groups.google.com/group/comp.lang.perl.misc/msg/e9017fc8aa1c572d
:: From perldoc -f read:
::
:: Attempts to read LENGTH characters of data into variable SCALAR from
:: the specified FILEHANDLE. Returns the number of characters actually
:: read...
::
:: You are overwriting the $buffer contents with the number of
characters.

http://groups.google.com/group/comp.lang.perl.misc/msg/7479274c2876d0d4
:: $buffer is passed as the second argument to the function, and
:: the function fills that buffer. It then returns HOW MANY BYTES
:: WERE READ, not the actual text. Therefore, you're reading, for
:: example, "Hello World", which Perl is storing into $buffer
:: automatically. But then you immediately replace that string with
:: the number 11, because you assigned the $buffer variable to the
:: return value of read().

The second one I just quoted.
What about ability to count? ;-)

Damnit, Gunnar, I'm a programmer, not a mathematician! ;-)

Paul Lalli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top