All Questions
443
questions
2
votes
1
answer
87
views
Perl subroutine in package to modify hash outside of it
to summarize:
i have a main script with a hash in it
this main script calls a package, where i have a subroutine from where i want to modify the contents of this global hash (to add elements to it)
...
1
vote
2
answers
79
views
How can I obtain the name of a perl sub from a ref to the sub?
My perl code contains many objects like
$wprAtnA
and
$wprAtnB
below, where a subroutine is specified with some set of arguments.
Other code, given a "wprAtn," applies the "wprAtn" ...
2
votes
3
answers
76
views
How to detect duplicate code references in an array?
I'm debugging some complex code I wrote (i.e.: I'm still writing).
At one point there is an array with code references (basically closures), populated dynamically.
There should not be any duplicates ...
3
votes
1
answer
165
views
Perl sort array creates new element if element being referenced
I have an array of strings, would like to record its original order in another array by referencing its elements, then I sort the array of strings, it creates new element in this array rather than the ...
1
vote
2
answers
87
views
Confusion when defining a list of array refs as constant
In some Perl code I'm doing some low-level coding accessing Perl constants that are lists, like this:
use constant LIST => ()
As Perl constants are actually implemented as functions, I'm trying ...
2
votes
2
answers
230
views
In perl is \*STDIN the same as STDIN?
I'm the author of Pythonizer and I'm trying to translate the code of CGI.pm from the standard perl library to Python. I came across this code in read_from_client:
read(\*STDIN, $$buff, $len, $offset)
...
0
votes
1
answer
199
views
How can I use "map" in "perl" to return a hash reference whose key is looked up from an array reference whose value is looked up from another array?
I've searched other many Stack questions on map however this requirement is particular and well try as I might I cannot quite get the solution I am looking for, or I think that does exist.
This ...
1
vote
1
answer
40
views
Perl: How to get a reference to the value associated with a key in a hash [closed]
Say I have a hash referred to by h, which contains the key a. I want to map b to a hash. I could do this directly using $h->{b}{key} = 123 but if I am inserting multiple key/value pairs, it is ...
1
vote
2
answers
241
views
how can I invoke a subroutine reference generated from a string in perl?
Several times in my code, I do the following.
generate a path from the name of a subroutine
invoke the subroutine and return a reference to what the subroutine created
store the reference to the path....
3
votes
1
answer
246
views
Perl: Can I use a variable to name an array?
Can I use a variable to name an array?
For example:
my $input1="AAA";
my $input2="BBB";
my @{$input1};
my @{$input2};
Because $input1=AAA.
So I want to create an array and its ...
2
votes
2
answers
114
views
Perl dynamic / symbolic function reference
Given a package name $package and a function name from within that package $function, I can create a reference to that function:
my $ref = eval( "\\&${package}::${function}" );
As a ...
1
vote
1
answer
56
views
Perl ... create horizontal children of a %hash using @array items
I've been banging my head on this awhile and searched many ways. I'm sure this is going to boil down to being really basic.
I have data in an @array that I want to move to a tree in a %hash.
This ...
1
vote
3
answers
168
views
Can I pass the code reference of an object's method in Perl?
In a network handler dealing with various parameters to get and set I'm using closures heavily.
I have a subroutine that receives a closure and builds another closure using that passed as parameter on ...
1
vote
1
answer
55
views
Dereferencing in Perl gives unexpected result
Sub1 can apply a regex1 on an input string (if it's defined) and collect the references to the special hash (%+) and arrays (@- and @+) variables for captured groups in an objs array. Alternatively, ...
1
vote
1
answer
122
views
Perl: Create a hash file using a loop
I import data from an XML-file and want to output the content into a log-file. Doing this I created for each entity a scalar (2). To output the entities with a loop I created a hash (3 and 4b) and ...