If
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.
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.
When i am installing an Digest::SHA1 module i am getting an error like below
sudo perl Makefile.PL
Checking if your kit is complete...
Looks good
ExtUtils::MM_Unix::tool_xsubpp : Can't find xsubpp at /usr/local/share
+/perl5/ExtUtils/MM_Unix.pm line 3903.
I'm doing some graphics hacking with the SVG module and it works great.. but... RBG is a bit of a crude color hammer. Is there a way to do HSL or HSV color selection with the SVG module?
Hello dear monks,
in my latest project I wanted to replace hard coded literals with constants.
In one case there was a simple loop, which used an expression with a constant for the terminal range value.
Here i stumbled upon an unexpected behavior.
Can someone shed some light on what is going on?
Thanks a lot!
This test program
use strict;
use warnings;
sub ten { 10 }
print "9 .. 10 - 1 without constant\n";
for my $i (9 .. 10 - 1) {
print $i, "\n";
}
print "-> expected\n\n";
print "9 .. 10 - 1 with constant()\n";
for my $i (9 .. ten() - 1) {
print $i, "\n";
}
print "-> expected\n\n";
print "9 .. 10 - 1 with constant\n";
for my $i (9 .. ten - 1) {
print $i, "\n";
}
print "-> unexpected\n\n";
print "9 .. 10 with constant\n";
for my $i (9 .. ten) {
print $i, "\n";
}
print "-> expected\n\n";
I see my values, but I ALSO want to see each corresponding key. Obviously it's a simple matter to write a for(){} to do this, but I'm thinking there is some elusive grep that can do it using the hash in list context? Oh maybe "each"..
My spidey sense says it in there somewhere.. Happy Friday the 13th team Perl!
I'm on attempt like 4 now. Problem is, wherever I build it (.) , @INC ends up with a bunch of ./.cpan/build/ entries. But the README , etc, doesn't state to build in any certain location so its perplexing.
After the build, I do:
I've looked everywhere--been stumped on this for over a day already: I thought it would be simple to install mod_perl.so into the Apache 2.4 setup...but it was not to be. Searching here and elsewhere online, it is unclear whether mod_perl itself is being phased out of existence. FastCGI, no longer downloadable from some servers (phased out already), seems to be promoted here; but I am left wondering where one obtains it?
A friend wants to run my scripts on his Windows computer. I haven't been a Windows user in over 10 years, but thought it should be doable. I installed MySQL, Apache24, and Strawberry Perl, being careful to configure them along the way. But that's just where the problem was...it seems to be an impossible combination on a Windows 11 platform.
First, there was no 'mod_perl.so'. In attempting to compile this from the source tarball I found online (had to install WinRAR just to unpack it), I was unable to compile mod_perl owing to lack of 'make'. I downloaded a heap of stuff from Microsoft (over 8 GB) just trying to get their 'make' program among all of the other C++ development tools they wanted to feed me. And when I finally had 'nmake', it failed to compile anything on one error after another. Looking online, I was not alone. No site has a compiled version, and it's not possible to compile one. After many hours of pure frustration, I tried to substitute a packaged arrangement instead: XAMPP. So, I uninstalled everything, then installed XAMPP, which is supposed to have it all. But, even after starting the apache and mysql services, and making sure perl was in the path, I still saw code displayed in the browser instead of it's getting executed.
Turns out, XAMPP provided no mod_perl either. None.
And then I find threads here discussing whether mod_perl is even needed anymore? The future of mod_perl
If one chooses not to use mod_perl, what other option is there to get a script to actually run under Apache 2.4?
This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-li
+nux-thread-multi
(with 39 registered patches, see perl -V for more detail)
Copyright 1987-2012, Larry Wall
Perl may be copied only under the terms of either the Artistic License
+ or the
GNU General Public License, which may be found in the Perl 5 source ki
+t.
Complete documentation for Perl, including FAQ lists, should be found
+on
this system using "man perl" or "perldoc perl". If you have access to
+ the
Internet, point your browser at http://www.perl.org/, the Perl Home Pa
+ge.
Hello Monks, I need help understanding how to format some text. I opted for an array since I do not know how to add multiple values to key in a hash. Clearly, I do not understand how to manipulate the array of elements to create a table equally align.
desired output, name of probe on the left side then all (x,y) coords and units on the right:
#!/usr/bin/perl
#use strict;
use warnings;
use Data::Dumper;
my @records;
my @col;
my ($probe, $x_coord, $y_coord, $mils, $micron);
my $infile= 'coord.txt';
open (DATA,'<',$infile) or die "could not open the $infile: $!";
while (<DATA>) {
chomp;
my @col = split " ", $_;
push @records, \@col;
}
#print Dumper(\@col, @records);
for (\@col){
print join("\t",$col{$records[0]}, $col{$records[1]}, $col{$record
+s[2]}, $col{$records[3]});
} #this for loop doesn't work
sub process_variables {
my ( $value, $remove_undef ) = @_;
$value =~ s/ (?<! \\ ) \$ \{ ( .*? ) \} /
defined $variable{ $1 }
? $variable{ $1 }
: defined $remove_undef && $remove_undef
# for if statements, any variable that is not defined,
# we simple convert to 0
? '0'
# This could be an option that is used later, save
# it so we don't warn if this option is not one of
# ktests options. And put back the origin piece.
: ( $used_options{ $1 } = 1 and "\${$1}" )
/exg;
return $value;
}
The code above produces the warning message:
Found = in conditional, should be == at file line n.
If I change:
( $used_options{ $1 } = 1 and "\${$1}" )
To:
do { $used_options{ $1 } = 1 and "\${$1}" }
I still get the same warning message.
But obviously the message is wrong because there is no = in conditional.
$ perl -v
This is perl 5, version 24, subversion 1 (v5.24.1) built for x86_64-li
+nux-gnu-thread-multi
(with 90 registered patches, see perl -V for more detail)
Copyright 1987-2017, Larry Wall
Perl may be copied only under the terms of either the Artistic License
+ or the
GNU General Public License, which may be found in the Perl 5 source ki
+t.
Complete documentation for Perl, including FAQ lists, should be found
+on
this system using "man perl" or "perldoc perl". If you have access to
+ the
Internet, point your browser at http://www.perl.org/, the Perl Home Pa
+ge.
Then I encode the JSON like so, so I can send it over as HTTP DATA
my $rows = reader($mysqlFilename);
...in reader
my $json = encode_json($hashref, {
lastname => JSON_TYPE_STRING,
firstname => JSON_TYPE_STRING,
age => JSON_TYPE_INT}
);
...and I return $json which is the single record.
Snippets of code should be wrapped in
<code> tags not<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).