subroutine Questions
4
Solved
I have a set of subroutines that look like this:
sub foo_1($) {
my $name = shift;
my $f;
run_something();
open($f, $name) or die ("Couldn't open $name");
while (<$f>) {
//Something f...
Carbonous asked 23/5, 2011 at 17:59
1
Solved
I have a Perl function, which does not return any value. It does not take any arguments also.
sub test {
#do my logic
}
Can I do as :
sub test() {
#do my logic
}
Will the subroutine test be...
Wizardry asked 19/6, 2018 at 6:4
1
Solved
I've read http://www.perl101.org/subroutines.html but I just don't understand optional parameters.
I want to call the following sub in PDF::API2. The doc says "-indent" is an option. How exactly d...
Dandelion asked 10/5, 2018 at 23:1
3
Solved
I just want to know if the return statement in Fortran 2008 is obsolete, because it seems to be unnecessary to write it at the end of subroutines and functions.
Does it have some other utility?
Saw asked 12/4, 2018 at 16:47
2
Solved
In Fortran, I need a procedure pointer inside a derived type that can point to one of several subroutines. This problem seems to be common on SO:
Fortran save procedure as property in derived type...
Durer asked 12/4, 2016 at 23:27
1
Solved
Since a couple of years ago or so I was completely new to Fortran, I overused SUBROUTINEs with no arguments, together with shared data, so that these procedures have made calculations on the actual...
Floorer asked 2/4, 2018 at 9:1
2
Solved
Is there a way to do an assignment to a formal parameter?
Something like:
sub myfunc($n) {
$n = $n + 5;
return $n;
}
Or, would I have to create a new variable and assign the value of $n to it...
Mutation asked 18/3, 2018 at 21:38
4
I have a code which calls the function. But I don't know the module this function belongs to. I need it to modify this function.
How can I check it?
Tanana asked 10/9, 2010 at 13:26
3
Solved
What is the Perl 6 way to tell the difference between an argument and no argument in a block with no explicit signature? I don't have any practical use for this, but I'm curious.
A block with no e...
Bataan asked 1/8, 2017 at 2:43
1
Solved
I'm trying to decide which one of these two options would be the best:
subroutine sqtrace( Msize, Matrix, Value )
integer, intent(in) :: Msize
real*8, intent(in) :: Matrix(Msize, Msize)
real*8,...
Equinox asked 20/12, 2017 at 20:19
9
I have asked this question before or searched and seen others ask - why am I getting the warning "Subroutine mySub redefined at ../lib/Common.pm line x"? and you always get the answer you declared ...
Monaural asked 6/8, 2010 at 22:33
4
Solved
When I dereference an array using @$arrayRef or @{$arrayRef} it appears to create a copy of the array. Is there a correct way to dereference an array?
This code...
sub updateArray1 {
my $aRef = ...
Lawman asked 23/7, 2017 at 6:58
2
Solved
I have next program:
use warnings;
use strict;
BEGIN {
print \&mysub;
}
sub mysub {};
print \&mysub;
Its output:
CODE(0x118e890)CODE(0x118e890)
The BEGIN block is processed in co...
Economist asked 4/7, 2017 at 12:22
3
Solved
I have been reading up and exploring on the concept of unit testing and test driven development in Perl. I'm looking into how I can incorporate the testing concepts into my development. Say I have ...
Oldworld asked 26/5, 2017 at 9:26
3
Solved
I have a package in perl , which uses two other package as its base.
Parent1:
package Parent1;
use strict;
use warnings;
sub foo
{
my $self = shift;
print ("\n Foo from Parent 1 ");
$self-&g...
Conoscenti asked 12/4, 2017 at 6:26
2
Solved
What is the syntax for passing subroutine names as arguments? Schematically:
.
.
call action ( mySubX ( argA, argB ) )
.
.
subroutine action ( whichSub ( argA, argB ) )
...
call subroutine w...
Tilsit asked 27/9, 2015 at 15:46
2
Let say I have one array that contains all subroutine name and I want to call all one by one.
foreach $sub (@arr){
print "Calling $sub\n";
#---How to call $sub?----
&$sub; ## will not...
Trounce asked 5/1, 2017 at 9:48
1
I have the following subroutine which i should pass the routine as hashtable and that hashtable should be again called inside another subroutine using perl?
input file(from linux command bdata):
...
Endocrine asked 4/1, 2017 at 6:10
3
Solved
I want to scan a code base to identify all instances of undefined subroutines that are not presently reachable.
As an example:
use strict;
use warnings;
my $flag = 0;
if ( $flag ) {
undefined_s...
Laughry asked 2/1, 2017 at 13:53
1
Solved
I'm trying to make a convenient function to convert a System.Classes.TShiftState into a user-readable string. To make it easier, I've made a subroutine to perform common code, to make the function ...
Bula asked 19/11, 2016 at 2:36
1
Solved
What is the difference between ESP and EIP registers using the following examples? Explain what the code is doing.
main PROC
0000 0020 call MySub
0000 0025 mov eax, ebx
.
.
main ENDP
MySu...
Overbuild asked 29/10, 2016 at 23:2
2
Solved
You can invoke a subroutine as a method using the two syntaxes in the example below.
But you can also invoke it not as an object.
#====================================================
package Opa...
Tarlatan asked 10/10, 2016 at 10:56
1
Solved
Let's assume we have this code, why it fails with the explicit package name error since the function is called only after the declaration of the $value?
use strict;
use warnings;
sub print_value{...
Narayan asked 6/10, 2016 at 13:10
1
Solved
for a Perl subroutine, if passing 0 argument, I can use 4 forms to call it. But if passing 1 or more arguments, there is one form that I can't use, please see below:
sub name
{
print "hello\n";
}...
Rad asked 21/9, 2016 at 7:37
1
Solved
Please take a look at the following code:
use strict;
use warnings;
print "subroutine is defined\n" if defined &myf;
myf();
sub myf
{
print "called myf\n";
}
undef &myf;
#myf();
print...
Marlenamarlene asked 20/9, 2016 at 10:52
© 2022 - 2024 — McMap. All rights reserved.