Before you say this isn't a Perl question, hear me out. I run a very poor machine -- a Chromebook running Arch Linux. I use this because I want people overseas who are very resource limited to be able to run any example I give them. These Chromebooks run out of space and my cue to go out and get something else comes along when I try to install a module and start getting really strange errors that I would not get on my Ubuntu-running desktop. I'll try to update the machine and essentially run out of space.
Here are some quick hardware and os specs:
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues
+"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo
[joel@PLANTER1 tmp]$ uname -r
6.13.5-arch1-1hostname
[joel@PLANTER1 tmp]$ hostnamectl
Static hostname: blah
Icon name: computer-laptop
Chassis: laptop 💻
Machine ID: 431546e29fab402dba950af2652c39ca
Boot ID: 6642a71047814218b7785c68524132a4
Operating System: Arch Linux
Kernel: Linux 6.13.5-arch1-1
Architecture: x86-64
Hardware Vendor: GOOGLE
Hardware Model: Candy
Firmware Version: MrChromebox-2408.1
Firmware Date: Sat 2024-09-14
Firmware Age: 1y 7month 3w 6d
I kept trying to use tiny Linux distros but would run into all sorts of hardware issues like my mouse would not work of my monitor would flicker. I settled on old Chromebooks because I could get them for a song on eBay. What prompted today's writing is that I tried to install Tk. I think I installed the pre-reqs:
sudo pacman -S tk
....
warning: tk-8.6.16-1 is up to date -- reinstalling
...
sudo pacman -S tcl
warning: tcl-8.6.16-1 is up to date -- reinstalling
...
cpan -i Tk
....
cc -c -I/usr/include/freetype2 -I.. -I/usr/include/freetype2 -I. -Ib
+itmaps -I/usr/include/freetype2 -D_REENTRANT -D_GNU_SOURCE -fwrapv -
+fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/include/db5
+.3 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -march=x86-64 -mtune=ge
+neric -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wforma
+t -Werror=format-security -fstack-clash-protection -fcf-protection -f
+no-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-m
+ap=/build/perl/src=/usr/src/debug/perl -flto=auto -DVERSION=\"804.0
+36\" -DXS_VERSION=\"804.036\" -fPIC "-I/usr/lib/perl5/5.40/core_perl/
+CORE" Xlib_f.c
In file included from Xlib_f.c:17:
Xlib.t:334:1: warning: ‘XKeycodeToKeysym’ is deprecated [-Wdeprecated-
+declarations]
334 | VFUNC(KeySym,XKeycodeToKeysym,V_XKeycodeToKeysym,_ANSI_ARGS_((
+Display *, unsigned int, int)))
| ^~~~~
In file included from Xlib_f.c:4:
/usr/include/X11/Xlib.h:1683:15: note: declared here
1683 | extern KeySym XKeycodeToKeysym(
| ^~~~~~~~~~~~~~~~
Xlib.t:334:14: error: initialization of ‘KeySym (*)(Display *, unsigne
+d int, int)’ {aka ‘long unsigned int (*)(Display *, unsigned int, i
+nt)’} from incompatible pointer type ‘KeySym (*)(Display *, KeyCode,
+ int)’ {aka ‘long unsigned int (*)(Display *, unsigned char, int)’}
+[-Wincompatible-pointer-types]
334 | VFUNC(KeySym,XKeycodeToKeysym,V_XKeycodeToKeysym,_ANSI_ARGS_((
+Display *, unsigned int, int)))
| ^~~~~~~~~~~~~~~~
Xlib_f.c:15:35: note: in definition of macro ‘VFUNC’
15 | #define VFUNC(type,name,mem,args) name,
| ^~~~
Xlib.t:334:14: note: (near initialization for ‘XlibVtable.V_XKeycodeTo
+Keysym’)
334 | VFUNC(KeySym,XKeycodeToKeysym,V_XKeycodeToKeysym,_ANSI_ARGS_((
+Display *, unsigned int, int)))
| ^~~~~~~~~~~~~~~~
Xlib_f.c:15:35: note: in definition of macro ‘VFUNC’
15 | #define VFUNC(type,name,mem,args) name,
| ^~~~
make[1]: *** [Makefile:865: Xlib_f.o] Error 1
make[1]: Leaving directory '/root/.cpan/build/Tk-804.036-2/pTk'
make: *** [Makefile:1659: pTk/libpTk.a] Error 2
SREZIC/Tk-804.036.tar.gz
/usr/bin/make -- NOT OK
So what I am looking for a machine/linux OS with longevity that virtually anyone can afford. I'm looking a lot into mini PCs, figuring I'll just carry around a foldable keyboard and small HDMI mini capable monitor or something around. Of course I've looked around online and found a resource on reddit talking about this issue but since my main interest is ensuring that Perl modules will compile and install correctly my guess is that module authors might already have some rigs set up that they go to for these testing scenarios.
By the way, thank you everyone who has read and responded my posts. Your help is greatly appreciated.
Celebrate Intellectual Diversity
|
I am looking for an authoritative list of all of the currently experimental features in Perl (I thought it would be here in the experimental POD or here in the perlexperiment POD but the class feature does not appear in them so these cannot be considered authoritative). When I try to discuss Perl experimental features like the new native classes I get the anticipated warning:
#!/usr/bin/perl -w
use strict;
no CGI;
use v5.36;
use feature 'class';
# notice that I commented this out
#no warnings "experimental::class";
package Signals;
our $VERSION=1.0;
package Foo;
class Alpha 0.01 {
field $longname = "alpha!";
}
package main;
#...
When I compile this or run it I get:
class is experimental at cgiuser3.pl line 16.
field is experimental at cgiuser3.pl line 17.
Which is exactly what I want and it appears to be consistent with how other popular languages are handling experimental features. But what I need upon seeing this is as follows:
- A single list for all experimental features currently in 'play.' I can see tickets flagged as 'experimental' on Github for Perl5. Is that the only/official way?
- (Hopefully) access to a repository of modules being built against the experimental features (or perhaps some way to easily identify them in CPAN?)
Celebrate Intellectual Diversity
|
I have a question. Is it okay to use "undef" as a placeholder to skip a variable when you're capturing return elements from a list?
use strict;
use warnings;
$| = 1;
my (undef, $min, $hr, undef, $mon) = localtime; # Okay
# my (undef, $min, $hr, , $mon) = localtime; # Okay but unexpecte
+d/weird result
# my ( , $min, $hr, , $mon) = localtime; # Syntax error
print "\nMinutes = $min\nHours = $hr\nMonths = $mon\n\n";
I have noticed that it's also okay to just write blank, but when I try to substitute blank in place of the first undef, I get a syntax error. What would be the official or best practice to skip a variable in a list? I am asking this question, because what if they change Perl and in version 5.79 they introduce some new feature which means that "undef" as a placeholder will raise an error or warning in the code?
|
perlfaq6:
In versions 5.6 and later, Perl won't recompile the regular expression if the variable hasn't changed, so you probably don't need the /o option. It doesn't hurt, but it doesn't help either.
perlop:
... the largely obsolete /o ...
The bottom line is that using /o is almost never a good idea.
Then what about something like benchmark below (this is 5.42, and I _do_ see a small but noticeable performance bump with real code which does some heavy lifting when parsing. I don't think any variables have changed; just wanted to split pieces of a regex into separate variables for clarity):
use strict;
use warnings;
use feature 'say';
use Benchmark 'cmpthese';
my $pat = qr/\d+/;
my $s = '123abc' x 1e6;
cmpthese -1, {
foo => sub { 1 while $s =~ /\G $pat \D+ /cgx },
bar => sub { 1 while $s =~ /\G $pat \D+ /cgxo },
};
__END__
Rate foo bar
foo 1213522/s -- -88%
bar 10345112/s 752% --
|
So I am looking around in perlvar and I learn that if you preface a scalar variable name with an underscore it will by default be in the main package...wow, I think. I want to try that:
perl -e 'package Nether; our $val = 2000; my $_nonesuch = 3000; packa
+ge main; print __PACKAGE__ . qq~\t~ . $main::_nonesuch;'
Makes: main
What? ...what happened by my value? So I take away the package portion:
perl -e 'package Nether; our $val = 2000; my $_nonesuch = 3000; packa
+ge main; print __PACKAGE__ . qq~\t~ . $_nonesuch;'
main 3000
As an aside I should mention why I keep posting these cryptic things about basic Perl functionality. I am researching why people run into problems with Perl and give up. The target audience (for now) includes project management and product owners who have enough familiarity with the language to recommend its use but want to simultaneously reduce the backlash that might come from doing so.
Celebrate Intellectual Diversity
|
I noticed some inconsistent entries in perllocal
for modules that have EXE_FILES:
Acme::MetaSyntactic (script/ is typical)
EXE_FILES: script/meta script/metafy
Pod::Parser
EXE_FILES: scripts/podselect
CGI-Kwiki
EXE_FILES: inc/SCRIPTS/kwiki-install
GD
EXE_FILES: bdf_scripts/bdf2gdfont.pl
App::FatPacker (bin/ is typical too)
EXE_FILES: bin/fatpack
Despite all that, everything listed as EXE_FILES ends up
in the same directory, specified (on my system) by 12 %Config variables
with the same exact value as $Config{bin}:
/Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
My question is this: do these 12 Config variables have the same
value on all Perl installations? I guess there are actually 14
of these same vars, but the vendor values are blank on my system.
Here's a little script to check. I'd like to know if these
can be different values so I know which one(s) to use.
Thanks in advance.
#!/usr/bin/perl -l
# Check if all the bin and script dirs in %Config are the same.
use strict;
use warnings;
use Config;
@_ = qw/bin
binexp
initialinstalllocation
installbin
installscript
installsitebin
installsitescript
scriptdir
scriptdirexp
sitebin
sitebinexp
sitescript
sitescriptexp
vendorbin
vendorbinexp/;
printf "%-24s %-100s\n", $_, $Config{$_} for @_;
Output on my system:
bin /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
binexp /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
initialinstalllocation /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
installbin /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
installscript /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
installsitebin /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
installsitescript /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
scriptdir /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
scriptdirexp /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
sitebin /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
sitebinexp /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
sitescript /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
sitescriptexp /Users/u/perl5/perlbrew/perls/perl-5.42.0/bin
vendorbin
vendorbinexp
|
perlver seems to do a good job of figuring out the syntax (except that --blame often fails to find the reason), but what about modules? Perl::MinimumVersion says "Future plans are to also add support for tracing module dependencies"
but that hasn't happened yet. One might think corelist would help with core modules but it can be misleading. Let's say we use List::Util:
% corelist List::Util
List::Util was first released with perl v5.7.3
But 5.7.3 is not the version needed if uniq or uniqnum are used:
https://metacpan.org/dist/Scalar-List-Utils/changes:
1.44 -- 2016/03/17 23:08:46
CHANGES
* Added List::Util::uniq() and uniqnum()
% corelist -a List::Util | grep 1.44
NOPE
% corelist -r | grep 2016
v5.22.2 2016-04-29
...
5.22.2 is required to support uniq (or maybe an updated List::Util if that's possible). How do you determine what version of Perl your program requires? A robot told me this is a real gap in the Perl ecosystem...
|
Why does "perldoc -lf splice" return perlfunc and perlop when the word "splice" does not exist in perlop?
% perldoc -lf splice
/Users/u/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/pods/perlfunc.pod
/Users/u/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/pods/perlop.pod
% grep 'splice' /Users/u/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/pods/perlfunc.pod
L<C<splice>|/splice ARRAY,OFFSET,LENGTH,LIST> has three scalar arguments
... (19 lines deleted for brevity)
% grep 'splice' /Users/u/perl5/perlbrew/perls/perl-5.42.0/lib/5.42.0/pods/perlop.pod
% <- NOTHING!
|
shell> perldoc perlootut
"...This document was created in February, 2011, and the last major revision was in February, 2013....
I check metacpan...same document. I want to learn the latest techniques for OO in Perl. I remember reading that there were native classes added in 5.38. Is someone updating perlootut? Is is being superseded by another POD?
Celebrate Intellectual Diversity
|
I feel like I have learned a lot in the past 10 years since I started learning Perl, but I still probably don't know more than half of what's possible using regex. I have often come across situations where I needed to identify which pattern occurs first in a string. So, I am not trying to capture a part of the pattern nor am I trying to identify if it occurs at all or where. I am just trying to figure our which of the possible patterns is FIRST in the string. For example:
Sample string: "AB ABDA DCACCB AAA BSAA CAAB ACS ABA DBA BA DASSABACA A"
I'm looking for either: BA[ABC]{2} OR CA[CD]{2} OR DA[SC]{2}
So, I would write: /BA[ABC]{2}|CA[CD]{2}|DA[SC]{2}/
Is there a way to get a return value of 1, 2, or 3 depending on which pattern was matched first? How would I do that?
|