perl recursion
Hi all,
Does perl supports recursive function calls ? :study: |
yes, but it's not really something that is "supported". Recursion is just a way of coding, not a function that is provided in itself. if you can call a function at all, you could recurse through it. unless your language of choice is extremely bizarre, or not procedural. even functional languages like ml will still have the ability to recurse afaik.
|
Hi all,
i have a problem while performing recursion...... ------------------------------------------------- func() { open(INPUT,file_name) --------> "file_name is provided by user" while(<INPUT>) { ....perform comutation here......... .................................... if (condition) { funct() ->------> #whenever control comes after last visiting this functions #it displays a message saying "readline() on closed # filehandle INPUT on file_name at ** line. } } close(INPUT); } ---------------------------------------------------- |
Probably because the recursive call closed the file, so when it returns to the outer call and it tries to read again, it discovers the file is closed. You may want to move the open/close outside the recursively-called function.
|
All times are GMT -5. The time now is 08:45 AM. |