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.
I have a task that can be best summarized by the keywords in the title, and I wonder if there is a somewhat ready-made solution, preferably in Perl, that I've overlooked.
I have a set of points in a plane (originally coordinates of known features in an image), in two versions: one from a reference version of the image, the other from a distorted and warped version of the same image. The points themselves belong to two subsets: for the first subset, let's call them "known" points, I know the coordinates from both images, and for the second subset, "target" points, I know their coordinates only from the reference image. What I want is to determine the coordinates of these "target" points, based on the transformation determined by the corresponding "known" points.
Maybe I'm not looking right, but I haven't found anything besides Imagemagick, dodgy Matlab recipes and a bunch of research articles.
Let's assume I have a module which needs 3 import parameters.
package My::Test;
use strict;
use warnings;
use Carp;
sub import
{
my $class = shift;
croak "Number of import parameters is wrong, stopped " unless @_ =
+= 3;
# ...
}
1;
I want to test that this exception was thrown and I also want to check its error message for correctness. Usually I use throws_ok for this. But in this case it doesn't work because the use command is at compile time. I have no idea how to test for this exception.
Hello friends,
I am exploring using MySQL cluster with MySQL router with Perl 5. I have not been able to find any information on how to modify my database interface in Perl to connect to a cluster. Have any of you done this? My objective is for both fail over and scaling.
Here is my existing code for how I connect to MySQL. Currently, this is just a single instance of MySQL.
use DBI;
use strict;
use warnings;
my $driver= "mysql";
my $dsn = "DBI:$driver:database=$database;host=$host";
my $dbh = DBI->connect($dsn, $user, $pw);
$dbh->do('INSERT INTO test_table (fname, lname, email, comment) VALUES
+ (?, ?, ?, ?)',
undef,
$fname, $lname, $email, $comment);
The above works fine. My hope is that MySQL clustering magically lets me use DBI and everything just like above. However, in the literature it seems that I would point my application to a MySQL router (mysqlrouter) instead of directly to the MySQL database.
If I should be taking an entirely different direction to clustering for fail over and scaling feel free to let me know. The only requirements for the project are that we stick with Perl 5 and MySQL.
Thank you in advance!
i am writing a code where i have to find version associated with the name from a file. i am trying below code but the pattern match is not working.
the file /home/test.txt contains multiple entries like below:
I programmed a site in Perl back in 2007, from then until about 2012. I wrote well over 100k lines, maybe 250k lines in over 100 files.
I cannot remember how I did it, but I remember something about it, isn't there a way to have something execute before the headers?
Like if we already printed the headers but then need to do something to do before them, I remember I used to have to do that somehow, but I for the life of me cannot find it in my programming, or on here, but I'm pretty sure someone on here helped me with it back then.
I may not be describing it right, but I think it was for window redirects, when we already had printed header files.
but I cannot recall for sure.
Do you know what I'm trying to say? or what I'm talking about?
Sorry, I got sleep apnea so severe I almost died and it ruined my brain, I cannot recall a lot of things in whole sentences.
I would appreciate anyone who can understand what I'm trying to say.
How do we have CLI of Perl's sed's n command ?
e.g. illustration:
cat script.txt| perl -nle 'if (/^===\w+\s*$/){ next # ??? how to ignor
+e first $_, here eg. ===Hello, to directly become replaced by next li
+ne ; # ... } print'
Hey Im coding a perl script which needs to get data from a database. But when I get a return value its comes back in an array so i dereference it. Yet it still prints out nothing. I ran the command in sqlplus and it worked there without issue. Im not sure how to solve this
my $sth = $dbh->prepare("select XMLRECORD from F_COMPANY") or
die "Couldnt prepare statement: " . $dbh->errstr;
$sth->execute();
# loop through the returned data
while( my ($row) = $sth->fetchrow_array()){
print "@$row\n";
}
Hi Monks,
I am trying to write a function that takes a string argument $str of the form shown below (letter + weight) and need to generate
all combinations with certain restrictions; for example, no repeating numbers. I also need a perlish way to move the
letter $firstLetter with the largest weight into first position. The order of the other substrings do not matter.
As a secondary restriction, I also want to ensure that the combination contains the substring $substring. So, for this particular $str example,
[ c?6, b?2, a%3, a?1] is a valid combination.
Thank you very much for your help
use strict;
use Math::Combinatorics;
my $firstLetter="c";
my $str="a?1,a?2,a%3,b?2,b?3,b%5,c%4,c%5,c?6,d%2";
my $substring = "a?,b%,c?";
my @combos = Math::Combinatorics::combine(4,split ",",$str);
foreach my $combo (@combos) {
## check if numbers are all unique
my $hash = {};
my ($count) = grep { ++$hash->{$_} > 1 } map { (split '')[2] } @$c
+ombo;
next if defined $count;
## place $firstLetter with largest weight in first position
## ensure that substring strings are contained within the combinat
+ion
}
I’m developing an API application. In the API response I get a pdf in a string. If I use the “from_string” and then the “save” method of the PDF::API2 module the pdf works fine.
If I write the API response string into a file (without using PDF::API2) or use the “from_string” and then the “to_string” method of the PDF::API2 module (which should be the same as I understand) I get an error message and a blank document (or blank with part of the header) when I try to open the file with a pdf reader.
I was wondering what is the difference between the contents of the outputs of the “to_string” and “save” methods?
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).