you have a question on how to do something in Perl, or
you need a Perl solution to an actual real-life problem, or
you're unsure why something you've tried just isn't working...
then this section is the place to ask. Post a new question!
However, you might consider asking in the chatterbox first (if you're a
registered user). The response time tends to be quicker, and if it turns
out that the problem/solutions are too much for the cb to handle, the
kind monks will be sure to direct you here.
Hoi, I just started with the Tk module and i am trying to get some text from an Entry widget to display on a label but it keeps being centered while i want it left aligned. I have been looking at internet sources but i can't bring it to work. Please help. Here is the code
my $mw = MainWindow->new;
my $entry = $mw->Entry();
my $label = $mw->Label(-justify=>'left');
my $but1 = $mw->Button(-text=>"go",-command=>\&go);
my $text = $entry->get;
I need help configure my Apache with mod_perl.
I have just installed mod_perl on via sudo apt-get install -y libapache2-mod-perl2 on Ubuntu 18. I am having a hard time figuring out what the next steps our to test perl script. I am looking at https://perl.apache.org/docs/2.0/user/handlers/http.html and trying to understand what would go in my virtual hosts file and what else I need to configure to get perl script working for Apach24 setup.
I've tried a few virtual host directives such as the one found here (with my own settings), but with no luck: https://wiki.archlinux.org/index.php/Apache_HTTP_Server/mod_perl
CustomLog /var/log/httpd/perlwebtest-access.log combined
AddHandler perl-script .pl
Allow from all
²) I've been asked what I mean with "sliding window", please see this sliding window description. There I start from the beginning, but it's often favorable to start from the end. (choroba++ for pm'ing me)
Hi all, I am trying to sort an array of arrays, but i am stuck. I have red some sources on the internet, but it is not helping me enough. I hope someone can tell me why i am failing. I am trying to sort this array on the second element. Here is the code:
I often have the case when reading a binary value from a file that it also has a textual representation. So I can use the dualvar functionality of Scalar::Util to solve this issue.
But that's not enough for me. Usually I have a corresponding table which contains the valid values and its representations. To avoid doing the same checks so often in code, I decided to tie the read scalar variable to a package which is doing these checks for me. Additionally on a change it shall always update the numeric and string context.
Here an example:
my %table = ( 1 => 'NORTH',
2 => 'SOUTH',
3 => 'EAST',
4 => 'WEST' );
# Case 1: Table num -> str
print "Case 1: Dualvar via num2str table\n\n";
my $direction = 2;
$direction = 4;
$direction = 'NORTH';
# Case 2: Table str -> num
print "Case 2: Dualvar via str2num table\n\n";
my $direction = 'SOUTH';
My::DualVar->tie($direction, reverse %table);
$direction = 4;
$direction = 'NORTH';
print "as num: " . ($_+0) . "\n";
print "as str: $_\n";
This code is working. But I would be interested in your opinion. What could I do better?
And the second thing. Currently my code would work randomly if the values of the given table (hash) are not unique. Is there an efficient way to check whether the values of a hash are unique? Then I would reject such a hash
Or would there be a solution to return several values if the hash is not unique, e.g. key 2 and 5 would have value 'SOUTH'?
In numeric context it would not work. If I would set a dualvar variable to 'SOUTH', then I would have to return 2 or 5 in the FETCH-method. Perhaps in numeric context the smaller value should be returned.
In string context I think it is possible. Because I could give back a concatenated string and I still would have a scalar.
I have an Autosys triggered Perl script that does a load of stuff and then sleeps for 15 minutes before doing it all again. I need to find a way to cleanly exit the program but I can't get it to respond to any signal handlers other than KILL and ALRM - both cause an immediate termination. If I add an ALRM signal handler, the ALRM stops working i.e. program keeps running!!!!