Bluetooth LE?
1 direct reply — Read more / Contribute
|
by cavac
on Aug 05, 2025 at 04:37
|
I'm trying to connect to a Bluetooth LE (low energy) device, specifically the MXTP-100 printer (that extremely cheap thermal printer with the cat ears). I tried Net::Bluetooth, but that doesn't seem to support Low Energy devices.
I can connect and print just fine to an old Epson bluetooth printer (not LE), but newer LE devices don't seem to work with Net::Bluetooth.
To be honest, i have absolutely no idea what i'm doing. Does anyone have any suggestions?
EDIT: Ooops, sorry, forgot to include my test code:
(I just hacked one of the examples, so code quality is low. Also please ignore the mentioning of GPS, i just didn't bother to update all variable names and comments)
|
Say, a string has embedded palindromes (PD); a PD in this case has odd (at least 3) number of letters. I want a piece of code to be executed exactly once for every PD including nested ones. Let "piece of code" be 'say'. Regex to extract a PD is well-known, and of course TIMTOWTDI, the question is not how to better solve the task.
Almost accidentally I found a solution, which I'm puzzled about. I don't know if it could be a simpler SSCCE without recursion.
say 'match' if 'abABCDCBAdeXYZYXfg' =~ /
(?>^.*?)
(
(
(.)(?-3)\g-1 | (.).\g-1
)
(?{
say $2
})
)
/x;
Output:
YZY
XYZYX
CDC
BCDCB
ABCDCBA
Bingo, just what I need. Match fails -- it's irrelevant. But HOW? If either of the following is removed: (1) "^" anchor; (2) independence (s/>/:/), or (3) entire 1st pair of parens, then there are multiple visits to each PD i.e. not what I want. In fact, for (3) the PD groups are also visited in reversed order, this I don't understand neither. And why both PD groups (not only 1st one) are visited.
Being greedy (s/\*\?/*/) produces no output, this I understand (I hope).
If, in case of code above i.e. without removing anything, the engine gives characters back one by one (I thought this is how backtracking works) before it ultimately fails when it (suddenly, somehow) remembers about independence, then I'd expect YZY is found and said; and then XYZYX is found and embedded code executed for both YZY and XYZYX, i.e. both are said (i.e. YZY said twice in total).
P.S. I've seen "Embedded Code Execution Frequency" section in perlre.
|
Documentation for ->&
2 direct replies — Read more / Contribute
|
by ikegami
on Aug 03, 2025 at 13:40
|
|
I'm using perlbrew, recently installed 5.42 using "perlbrew install stable". Now some programs don't work any more. For example, the error message says the version doesn't match for XS.c. How do you find out which module it means?
perl -E 'use namespace::clean'
Perl API version v5.40.0 of XS.c does not match v5.42.0
perl -v
This is perl 5, version 42, subversion 0 (v5.42.0) built for x86_64-li
+nux
Copyright 1987-2025, Larry Wall
i tried looking in ~/.cpan/work to find a XS.c file, found one in the build for List::MoreUtils::XS. try to get cpanm to install List::MoreUtils and it provides the error as the reason it can't install:
Checking whether perlapi is accessible... Perl API version v5.40.0 of
+XS.c does not match v5.42.0-> N/A
-> FAIL Configure failed for List-MoreUtils-0.430.
|
My environment: Perl 5.24.1 on Windows 10.
The following SSCCE uses the "qr" operator to quote a string as a regular expression. The non-capturing part of the regex curiously has a "caret" inserted between the question mark and the colon. I've looked and can find no explanation or example of what the "caret" does in the regex produced by "qr". The "caret" does NOT (thankfully) anchor the regex at the beginning of the line, so what does it do?
#!/usr/bin/perl
use strict;
use warnings;
my $text = 'abcd';
my $regex = qr/$text/;
print "\n\$text = |$text| \$regex = |$regex|\n\n";
__END__
Output:
$text = |abcd| $regex = |(?^:abcd)|
"It's not how hard you work, it's how much you get done."
|
In the past, when I've built unthreaded perls on MSWindows, they have been built without defining USE_IMP_SYS and without defining USE_MULTI. There was no readily available option to do otherwise.
However, as of a few days ago, building unthreaded bleadperl with both USE_MULTI and USE_IMP_SYS defined has been facilitated.
Which option do I want ? Do I want (unthreaded) MSWin32-x64-multi or do I want (unthreaded) MSWin32-x64-perlio ?
What are the pros and cons ?
Cheers, Rob
|