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 situation with DBI and the Sybase drivers. If I specify a TDS level, and I use a query with placeholders, and that query returns no results, the fetchall_arrayref() call hangs. If I don't do all three of those things, the call returns an array, as expected.
wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.2.20.tar.gz
tar xfvz freetds-1.2.20.tar.gz
cd freetds-1.2.20/
./configure --prefix=/home/username/tdslib
make
make install
Kindly seeking assistance in rendering images (any static file from /public) in a default Mojolicious-Hypnotoad-Nginx setup. Following the standard guides, this setup successfully renders the default welcome page. However adding one exception: a .png image to this page, it is not rendered, even the favicon.ico doesn't appear.
There is mention of "hooks" needed to correct for the workings of a Reverse Proxy, but after a long search one doesn't find a clear full example -- particularly for Nginx.
The welcome.html.ep has this simple addition: . It appears alone as an image when one enters this url: http://example.com/tree.png
Hello,
Am trying to use Win32::SerialPort on a portable strawberry perl implementation, version 5-32-1. (32 bit). Using it to try and set up a datalogger on a Win10 machine, for an instrument that reports through a RS232 output. Also have a general test bed which is two windows PCs connected by a serial cable, and one sending messages (from Powershell) to the other - which testing has shown acts in the same way as the end use.
Have come across a variety of scripts online. For some reason though, I can't get any Perl script to output the RS232 input on its own. However, if I open and close the port in powershell, suddenly the exact same Perl script DOES work! The perl script continues to work as expected until the PC is rebooted. So I'm wondering if there's a key parameter needing to be set, which is sorted by Powershell but not by Perl? Couldn't see anything obvious in the SerialPort documentation.
An example script that only works when powershell has "activated" the port is:
use Win32::SerialPort; # Use instead for Windows
my $port=Win32::SerialPort->new("COM1") || die "couldn't open COM1";
$port->baudrate(9600); # Configure this to match your device
$port->databits(8);
$port->parity("none");
$port->stopbits(1);
#$port->handshake("none");
$port->user_msg(ON);
print "Port COM1 successfully opened\n";
$count = 0;
my $chars=0;
my $buffer="";
print "1\n";
do {
print "2\n";
my ($count,$saw)=$port->read(255); # will read _up to_ 255 char
+s
print "3\n";
if ($count > 0) {
$chars+=$count;
$buffer.=$saw;
print $saw;
}
print "4\n";
$port->lookclear;
print "5\n";
} while 1;
$port->close;
This code stops after printing "2" if I've not opened/closed the port in Powershell yet - it's the reading of RS232 input where the script seems to get blocked quite consistently across different scripts.
Powershell code to open and close is:
Powershell to send RS232 on test bed is:
$port.WriteLine("test")
Unfortunately access permissions do not let me run a powershell script, and I'd rather not have the end user have to manually type in powershell code each time the PC is turned on...
Many thanks for any advice provided.
...
my $mt = Mojo::Template->new( vars => 1, auto_escape => 1 );
my $data = ... # Not where the issues is.
my $code = "PERL";
print $q->header( -charset => 'utf-8' ), $mt->render_file( myfile.html
+.ep, { data => $data }, { test => $code } );
...
Hello All, I am getting the following error Crypt-Random-Source: 0.14 fails to install while installing OIDC::Lite. I am in Windows 10 platform
Please check below errors
t/sugar.t .............. 1/? Undef did not pass type constraint "Class
+Name" (in $self->{"weak_source"}) at (eval 121) line 17
"ClassName" is a subtype of "Str"
"Str" is a subtype of "Value"
"Value" is a subtype of "Defined"
Undef did not pass type constraint "Defined" (in $self->{"weak_sou
+rce"})
"Defined" is defined as: (defined($_))
# Tests were run but no plan was declared and done_testing() was not s
+een.
# Looks like your test exited with 255 just after 3.
t/sugar.t .............. Dubious, test returned 255 (wstat 65280, 0xff
+00)
All 3 subtests passed
Test Summary Report
-------------------
t/factory.t (Wstat: 65280 Tests: 1 Failed: 0)
Non-zero exit status: 255
Parse errors: No plan found in TAP output
t/sugar.t (Wstat: 65280 Tests: 3 Failed: 0)
Non-zero exit status: 255
Parse errors: No plan found in TAP output
Files=7, Tests=17, 4 wallclock secs ( 0.11 usr + 0.09 sys = 0.20 CP
+U)
Result: FAIL
Lockfile removed.
ETHER/Crypt-Random-Source-0.14.tar.gz
C:\Strawberry\perl\bin\perl.exe ./Build test -- NOT OK
//hint// to see the cpan-testers results for installing this module, t
+ry:
reports ETHER/Crypt-Random-Source-0.14.tar.gz
Stopping: 'install' failed for 'Crypt::Random::Source'.
Failed during this command:
ETHER/Crypt-Random-Source-0.14.tar.gz : make_test NO
I've got a script that uses named capture groups to parse file records. The
record format is always the same (four fields wide, colon separated), just like
a passwd file (except for the number of fields).
For example:
0:1:bob:Bob
1:1:bob:Bob
1:0:alice:Alice
You get the idea. At first I used to split it, but later I came to the
conclusion that using a regex with named groups could provide a more
understandable code. The (simplified) example below might help you get the
picture.
Now, I've noticed (according to
perlretut)
that named capture groups were introduced in Perl 5.10. I don't expect the
script to run in older versions, but would it be wise to use v5.10
pragma?
Would it have any unwanted side effects? I'm not using any of the
features of the
bundle, just wanted to state that version 5.10 is required. Is that a good
idea?
I am trying to use ExifTool to extract some Metadata TAGS. I've searched for a specific use case but was unsuccessful. Ive constructed some simple code to accomplish what I am trying to do, but I am looking for verification that I am doing it correctly to extract the necessary variables or is there a simpler way.
use Image::ExifTool qw(:Public);
use Data::Dumper;
$file='d:/60486581538__715F9238-09E5-4806-8146-0626DAFB0E36.JPG';
$ExifTool = new Image::ExifTool;
#$ExifTool->Options(DateFormat => '%Y-%m-%d');
$info = $ExifTool->ImageInfo($file,'SubSecCreateDate','LensModel');
#$info = $ExifTool->ImageInfo($file);
print "INFO: $info\n";
$createdate=$$info{'SubSecCreateDate'};
$lens=$$info{'LensModel'};
print "\nCreate Date: $createdate\n";
print "Lens Model: $lens\n\n";
print Dumper($info);
exit;
D:\>metadata.pl
INFO: HASH(0x2b9f148)
Create Date: 2020:03:02 13:16:55.336-05:00
Lens Model: iPhone 7 back camera 3.99mm f/1.8
$VAR1 = {
'LensModel' => 'iPhone 7 back camera 3.99mm f/1.8',
'SubSecCreateDate' => '2020:03:02 13:16:55.336-05:00'
};
D:\>
I have this line in my code and I am trying to see if there is a way to add more than one file match in this line, the files comes as "*.txt", "*.TXT", "*.png", "*.PNG".
It breaks if in this line the file extension is "*.TXT" instead of "*.txt".
If it is called as get_ids( 'format' => 'json' ); it works fine but asking it to return a text string returns undef and warns Useless use of string in void context at line 229. The way I think it should work is that if $result{'message'} evaluates as true, that will get returned but if it evaluates as false then "$result{'api-key'}:$result{'session'}" wil be returned instead.
Can you explain why this is not behaving as expected?
As an aside, in searching for an answer I found this post -> Useless use of string in void context
There it is suggested that Perl reports the wrong line number for this warning so it is quite possible that I'm actually looking in the wrong place!