It certainly makes sense that if you've been stuck for a week you would need answers, and fast, I'm sure. So I'm sure you have by now taken a moment to look over perlmod, as previously recommended. And that being the case, I can now ask the following:
What are your package names?
You see, having read perlmod, you would now know that giving package names gives you namespaces. You might, for example, set a package Process; in Process.pl, and a package Program; in program.pl. Then, depending on an object oriented interface or a functional interface, you might export functions from program.pl, importing them into Process.pl's namespace, or you might inherit a class from program.pl into Process.pl. At that point you would have a framework that would be easy to manipulate.
Having read perlmod as recommended in my previous answer you would also have discovered that there is an advantage to using .pm as the extension for the filenames of your packages. In fact, a package name, a file ending in .pm, some functions defined, and a '1' at the end is the simplest and most basic framework of a Perl5 module.
But even if you only give your functions a different namespace for each file using package, at least we would be able to use fully qualified names to manipulate our symbol tables so that we're using the version of a function that we want to use.
If you haven't given packages namespaces, and you've got one function in one file and another in another file both with the same name, you could, I suppose, take a function reference to the first function and save it away, and then after requiring the second file, take a function reference to its function by the same name. Now you've got two function references; one pointing to the original function, and one pointing to the other one. From there you could invoke whichever one you please.
But that's going to get old fast... devising your own manipulations to avoid having to read the Perl documentation enough to know how to create packages (namespaces), and how to use either Exporter or inheritance, you'll be reinventing the wheel at every corner, and will continue being held up by a week here, and a week there.
So having followed the previous advice, where are you now hung up? And if you haven't followed the previous advice, what is the motivation for me to provide additional? Of course maybe you have done the required reading. If that's the case I apologize for wasting your time with this explanation, and ask that you post an example, boiled down to a couple dozen lines type of real code showing where you're hung up.
Dave
In reply to Re^3: Does perl allow overriding a function in two different files(.pl)
by davido
in thread Does perl allow overriding a function in two different files(.pl)
by codewalker82
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |