This question already has answers here:
Can I dynamically get a list of functions or function names from any Perl module?
(3 answers)
How do I list available methods on a given object or package in Perl?
(5 answers)
List all the subroutine names in perl program
(3 answers)
Get list of methods/functions defined explicitly in a module
(1 answer)
Closed 6 months ago.
First of all, I am entirely new in perl so I apologize if this is a rather basic question.
We have a perl script that calls on a module — lets name it module_x
It’s called in the script using this line.
require module_x
Sadly, this does not have a documentation and we can’t access the server where this script is.
Is there a way to know what functions are available in the module? Similar to desc in python.
Related
This question already has answers here:
How can I inline Perl subroutines?
(4 answers)
Closed 7 years ago.
I know non-constant subroutines usually will not be inlined, since they can be redefined on the fly. However, I have code where inlined subroutines would actually offer a small but non-trivial optimization; but I don't want to unroll them myself since it would make the code much harder to read.
Is there some way to make Perl inline these methods, a way to indicate that the subroutine will not be modified at runtime and I want the interpreter to inline during the preprocessing phase?
Constants can be folded, but Perl subs are never inlined. Practically, they can't be. macro and Macro attempt to provide inlinable subs, but I don't know how reliable they are. You will definitely find limitations.
This question already has answers here:
How to execute multiple statements in a MATLAB anonymous function?
(5 answers)
Closed 7 years ago.
Is it possible to create multiline anonymous function in Matlab?
There are no appropriate examples in documentation, but also no direct denials. In web discussions I found some derisions of askers as if it silly wish. Nowadays, when most languages introducing lambda expressions with multiline capability this looks strange.
No, unfortunately this is not possible.
This question already has answers here:
How can I generate a list of function dependencies in MATLAB?
(2 answers)
Closed 8 years ago.
Assume I have written two MATLAB functions foo.m and bar.m
I want to know if foo.m calls bar.m
I tried using depfun and listing dependencies and checking if bar is a member. It didn't work.
It seems depfun only returns builtin functions.
Is there a way around this when bar.m is not a built in function?
There are various techniques listed in the documentation to identify file dependencies, one of them should do the trick.
Note: the techniques listed in the documentation page I mentioned are for the latest release R2014b, they may not all be available in earlier releases.
This question already has answers here:
How do I access program arguments in Swift?
(6 answers)
Closed 8 years ago.
I'm writing a command line app using Swift but I'm not sure how to get access to the arguments passed in. In C/Obj-c it seems relatively painless but if I try:
argv[0]
I get an error: Use of unresolved identifier 'argv'
There are two ways to do this:
The constants C_ARGC and C_ARGV. They are analogous to the argc and argv you'd see in a main() function.
The CommandLine.arguments array will contain all of the arguments to the process. (In Swift 2, CommandLine was called Process)
This question already has answers here:
When should I use the & to call a Perl subroutine?
(4 answers)
Closed 9 years ago.
Every now and then I see Perl scripts where subroutines are called with a leading '&'.
Is this legacy, or does it give any benefit?
As calling the subroutine without the ampersand sign works as well.
sub mysub {
print "mysub\n";
}
mysub;
&mysub;
Thx/Hermann
Calling with & is generally a code smell that somebody doesn't know what they're doing and are in a Perl4 mindset. In your specific example, it works exactly the same. However, calling with & disables function prototypes, so advanced users may use it in certain circumstances. You should expect to see a comment why next to the call in that case.