Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

hi all,
Im facing a problem while executing my perl file named "Index".
I have defined a function called "Read_text_File" at line 107.
when i compiled, it is giving an error message as Index: Subroutine Read_text_File redefined at /pl/TEST/Scripts/Index line 107.
I checked whole file, i have no where defined that function twice.
Im unable to understand what is the mistake.
Could anyone pls help me...
Thanks in advance.

Replies are listed 'Best First'.
Re: error regarding definition of function
by virtualsue (Vicar) on May 06, 2004 at 12:43 UTC
    Hi, welcome aboard. I suggest that you wander over to the Tutorials and browse through the section called "Welcome to the Monastery". It contains some excellent tips on how to get the most out of this site. I hope you'll register as a user and stick around.

    Now, getting to your problem Since I can't see proof that says otherwise, I'm going to believe Perl, since I find it is usually right when it complains. I think you have, probably quite unwittingly, redefined Read_text_File. Did you try to prototype that subroutine? Have you used your editor (or grep) to search the file for the string 'Read_text_File'? You'll need to show some code if you want more help.

Re: error regarding definition of function
by ysth (Canon) on May 06, 2004 at 16:55 UTC
    Some random thoughts: are you requiring "Index" from Index?? Do you have a constant declared with that name? Try putting just before the sub Read_text_File:
    BEGIN {use Devel::Peek; Dump \&Read_text_File if exists &Read_text_Fil +e}
    and see what the dump (to STDOUT) says on the FILE = and GVGV::GV = lines.