LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 03:54 AM   #1
sharath.bv
LQ Newbie
 
Registered: Jan 2008
Posts: 17

Rep: Reputation: 0
Question perl recursion


Hi all,

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

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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, 03:26 AM   #3
sharath.bv
LQ Newbie
 
Registered: Jan 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 03:28 AM.
 
Old 02-08-2008, 07:21 AM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
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



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 04:39 PM
Spinlock Recursion wahming Linux - General 2 02-15-2007 02:44 AM
Recursion in C hubabuba Programming 12 10-03-2005 07:46 AM
Perl, recursion ivanatora Programming 11 03-14-2005 01:49 PM
tar: '--no-recursion' option doesn't prevent recursion Earl Parker II Slackware 12 08-17-2004 02:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:13 AM.

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
Open Source Consulting | Domain Registration