Hi Richard,
Richard wrote:
while going over below example from the book, I am not understanding
why/how below program works.
Can someone explain this to me in better way?
Have you tried running it? does it work like what you expect?
what is READER exactly reading from???
and what does print while <READER> do ? I thought all the print
happens during factorial() and fibonacci()
It is reading from a pipe. Take a look at the description of the pipe
function and what a pipe is (in case you do not know):
http://perldoc.perl.org/functions/pipe.html
http://en.wikipedia.org/wiki/Pipe_(Unix)
<> is reading in from the pipe. Take a look at:
http://perldoc.perl.org/perlop.html#I%2fO-Operators
So, while there is something left to read, print it out. Go to the
above link and look at the first shaded box which says "The following
lines are equivalent". The line that is confusing you is the last line
in that box...as it says, all of those are equivalent.
to answer your last question, then, the answer is "no", the printing
isn't happening in just the two functions you named. Take a look at the
above links to see if they give you a clue. And if you are wondering
what the select line is doing, take a look at this and look up the
select function:
http://perldoc.perl.org/perlfaq5.html#How-do-I-flush%2funbuffer-an-output-filehandle%3f--Why-must-I-do-this%3f
And BTW, you can cut out almost half of the code if you just focus on
either fibonacci or factorial and not both.
Ray
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/