LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-06-2008, 04:54 AM   #1
sharath.bv
LQ Newbie
 
Registered: Feb 2008
Posts: 17

Rep: Reputation: 0
Question perl recursion


Hi all,

Does perl supports recursive function calls ?
 
Old 02-06-2008, 05:00 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
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.
 
Old 02-08-2008, 04:26 AM   #3
sharath.bv
LQ Newbie
 
Registered: Feb 2008
Posts: 17

Original Poster
Rep: Reputation: 0
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);
}
----------------------------------------------------

Last edited by sharath.bv; 02-08-2008 at 04:28 AM.
 
Old 02-08-2008, 08:21 AM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 122Reputation: 122
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Recursion and its culture Bassy General 3 06-19-2007 05:39 PM
Spinlock Recursion wahming Linux - General 2 02-15-2007 03:44 AM
Recursion in C hubabuba Programming 12 10-03-2005 08:46 AM
Perl, recursion ivanatora Programming 11 03-14-2005 02:49 PM
tar: '--no-recursion' option doesn't prevent recursion Earl Parker II Slackware 12 08-17-2004 03:49 AM


All times are GMT -5. The time now is 11:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration