Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

The Monastery Gates

( #131=superdoc: print w/replies, xml ) Need Help??

If you're new here please read PerlMonks FAQ
and Create a new user.

Quests
Monk Quips Quest
Starts at: May 01, 2023 at 08:00
Ends at: Dec 31, 2023 at 18:59
Current Status: Active
7 replies by erzuuli
    Esteemed Monk kcott has recently proposed an excellent idea.

    heretoforthwithstanding, we invite all monks to submit ideas for new monk quips!

    Your quip suggestion should include the following details:

    • Intended quip location: either XP Nodelet, Chatterbox, or Monkbar (that's the page header).
    • Text of quip.
    • Optional: background & foreground colours. If you include these, be sure they are nicely contrasting.

    .

poll ideas quest 2023
Starts at: Jan 01, 2023 at 00:00
Ends at: Dec 31, 2023 at 23:59
Current Status: Active
2 replies by pollsters
    First, read How do I create a Poll?. Then suggest your poll here. Complete ideas are more likely to be used.

    Note that links may be used in choices but not in the title.

Perl News
A Roguelike in Perl Tutorials by Chris Prather
on Aug 08, 2023 at 05:19
1 reply by ait
berrybrew version 1.40 released
on Aug 02, 2023 at 13:38
1 reply by stevieb

    I have released version 1.40 of berrybrew. It comes with some extensive changes over this, and the previous 1.39 version. (See the changes list).

    User facing changes include:

    • Ability to install and use the new 5.36 and 5.38 releases of Strawberry Perl
    • berrybrew archives hidden command. It displays the list of portable Strawberry Perl zip files previously downloaded
    • berrybrew download hidden command. Download, but do not extract the zip archive of a perl version
    • berrybrew snapshot command. Export an installed perl version to a zip archive, and import a previous zip snapshot to a new installed instance

    berrybrew snapshot usage:

    • bb snapshot export <perl version> [snapshot name]
    • bb snapshot import <snapshot name> [new instance name]

    As far as changes on the developer side, the changes are significant. Here's a high-level list:

    • Broke out like functionality in the main berrybrew.cs source file, and spread it across several new classes, each in their own source file
    • Removed the deprecated berrybrew upgrade command. Upgrades shall be done via the installer
    • Created a very extensive MANIFEST checking system for the installer. This ensures that all files that need to be installed are, those same files are removed upon uninstall, and no rogue files when building the installer are accidentally leaked in
    • Added a significant amount of documentation for the development, build, test and release lifecycle of the project. If I get hit by a bus, I've created a fantastic roadmap for someone to carry on the project quite readily (bb dev docs)
    • A few minor bug fixes, and one major one

    -stevieb

Supplications
A bug in GNU make ?
2 direct replies — Read more / Contribute
by syphilis
on Aug 26, 2023 at 22:27
    Hi,

    This pertains to the Makefile generated by perl when building Glib-Object-Introspection-0.050.
    It's the same problem with version 4.2.1 and version 4.4.1 of GNU make. (I haven't tested with any other versions.)

    For Windows only, the Makefile.PL directly inserts a few lines into the generated Makefile.
    One of those lines is:
    PATH += ;build
    The intention is to append ";build" to $ENV{PATH} but it instead appends " ;build".
    This means that my PATH, which originally terminated in "...D:\msys64\mingw64\bin" then terminates in "...D:\msys64\mingw64\bin ;build".
    Hence the (crucial) "D:\msys64\mingw64\bin" folder is no longer in my PATH - causing baffling load_file failures during 'gmake test'.

    Notably, my original PATH doesn't terminate with a ';'. While that is perhaps not a good defensive programming approach, I don't believe it's a bug ?
    Or, perhaps, the bug is in the instruction being provided by the Makefile.PL. Here is the relevant excerpt from the G-I-O-0.050 Makefile.PL:
    $inherited =~ s/($target)/.IMPORT: PATH\nPATH += ;build\n.EXPORT: PATH +\n$1/;
    which results in this entry in the generated Makefile:
    .IMPORT: PATH PATH += ;build .EXPORT: PATH test_dynamic :: subdirs-test_dynamic $(FULLPERLRUN) "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "u +ndef *Test::Harness::Switches; test_harness($(TEST_VERBOSE), '$(INST_ +LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES)
    Cheers,
    Rob

    PS I tried the obvious and naive fix of changing "PATH += ;build" to "PATH+=;build" but the errant space is still being included in the PATH.

    PPS Working around the problem is as simple as ensuring that my original path terminates with a semi-colon.The PATH then ends up terminating with "...D:\msys64\mingw64\bin; ;build", which seems to not be a problem.
Why don't *glob assignments affect the current pacakge?
1 direct reply — Read more / Contribute
by jimav
on Aug 25, 2023 at 19:56

    Aliasing symbol table entries does not work unless the aliasing assignment is executed by code in a different package. Why is this? BEGIN{ *main::mainvar = *someotherpkg::whatever } does not define $mainvar in package main if that assignment is executed in package main... or so it seems (see demo script below).

    Can someone explain what is going on here? I've read 'perlmod' carefully and think I understand Perl symbol tables. But.

    #!/usr/bin/env perl use strict; use warnings; use feature qw/say/; package Foo; our $foovar; BEGIN{ $foovar = 42 } package main; # This does not work (gets "Variable $mainvar is not imported") BEGIN{ package main; *main::mainvar = \$Foo::foovar; } # But this does work ... why? #BEGIN{ package xyzzx; *main::mainvar = \$Foo::foovar; } say $mainvar;
Locate emement in array and delete
3 direct replies — Read more / Contribute
by g_speran
on Aug 25, 2023 at 15:13
    Hello Perl Monks,
    	I'm sure one you see what I am doing you may be like "What in the BLEEP, are or doing or thinking".
    	Well, this is why I am reaching out to the Monks, as i believe there has to be a better way to do this.
    	
    	I am trying to locate all the element in the @ARGV that were passed via command line and ONLY delete some of them.
    	in the example, I want to delete --config and --enter
    	
    	Now this is only a snippet of the code
    	
    	The results I get are now expected, but there has to be a much simpler way
    
    > splice_tst.pl --debug --config --enter --config --config --enter +--help
    use strict; Splice_Array("--config"); Splice_Array("--enter"); sub Splice_Array { print "Before Array Splicing: \n"; print "\t" . join(',', @ARGV), "\n"; my $value=shift; print "Splicing Value: $value\n"; my @matches = grep { $ARGV[$_] eq $value} 0..$#ARGV; # Just to Cou +nt the number of times the variable was identified print "$value is located at index(s): " . join(',', @matches), "\n +"; for my $match (@matches) { # just used for a Max loop count my @index = grep { $ARGV[$_] eq $value} 0..$#ARGV; print "Index:$index[0]\n"; splice @ARGV, $index[0] ,1; } print "After Array Splicing: \n"; print "\t" . join(',', @ARGV), "\n\n\n"; }
    Output: C:\Temp>splice_tst.pl --debug --config --enter --config --config --ent +er --help Before Array Splicing: --debug,--config,--enter,--config,--config,--enter,--help Splicing Value: --config --config is located at index(s): 1,3,4 Index:1 Index:2 Index:2 After Array Splicing: --debug,--enter,--enter,--help Before Array Splicing: --debug,--enter,--enter,--help Splicing Value: --enter --enter is located at index(s): 1,2 Index:1 Index:1 After Array Splicing: --debug,--help C:\Temp>
Perl script works on Centos but not Ubuntu
3 direct replies — Read more / Contribute
by harryhendo
on Aug 25, 2023 at 14:10
    Hello Folks,

    We've recently upgraded our LDAP server from Centos (due to the IBM takeover of RedHat) to run on Ubuntu Server. The server has 64GB of RAM, and an 8 GB swap partition on a 480 GB SSD drive. We have a perl script that queries a main LDAP server and returns hits on first or last name as well as userid. The total volume of returned data is less than 4K.

    This script ran for years on Centos, but will not run on Ubuntu, with an error output of "Out of memory!".

    The ulimit command output shows identical values on both Centos and Ubuntu for all relevant memory limits, with:
    max memory size (kbytes, -m) unlimited virtual memory (kbytes, -v) unlimited
    The free command on the Ubuntu server shows 557MB of free uncached memory, with 61GB available:
    # free -h total used free shared buff/cache + available Mem: 62Gi 557Mi 867Mi 5.0Mi 61Gi + 61Gi
    I've searched here and via search engines for a solution, but can find none. Thanks for any idea you have to resolve this.
Translating python math to Perl
3 direct replies — Read more / Contribute
by cavac
on Aug 25, 2023 at 04:57

    I'm the first to admit that my math skills are limited. "Normal" math is no problem, nor is writing software that deals with stuff like basic accounting or sensor data conversion. But i'm completely stumped by linear algebra and matrix multiplication.

    I own a Boox Note Air, and there is python code that can render notes from the old export format. I'm currently in the process of reverse engineering the new format(*), and i think i found nearly all the data i need to write a new renderer in Perl. From what i can tell, the export format has changed, but the internal representation of the data in the software (and the rendering process) has stayed pretty much the same.

    Unfortunately, the points that define a drawn line aren't saved as coordinates per se, but need to go through some matrix math before the screen coordinates are obtained. I think that's so that you can scale or rotate a line without loosing the original coordinates or something along that.

    The old program has this python code:

    if matrix is None: # Compatibility with older note format matrix = np.eye(3,3) else: matrix = np.asarray(json.loads(matrix)["values"], +dtype=np.float32).reshape(3,3) d = np.frombuffer(points, dtype=np.float32) d = d.byteswap() d = d.reshape(-1, 6) pressure = (d[:,2] / pressure_norm) ** pressure_pow # Projection matrix points = d[:, :2] points = np.concatenate((points, np.ones([points.shape +[0],1])), axis=1) points = points @ matrix.T points = points[:, :2]

    As i said, i don't understand enough about matrices (or python for that matter) to translate that code to Perl. Can anyone help me on that?

    Here is the code i have so far for reading the basic SQLite databases, Testfiles and some of my guesses on the format of the binary "points" blobs:

    (*) Reverse engineering the SQLite databases and the binary points lists is comparatively easy. All it takes is a few basic tools, a desktop calculator, half a dozen pages of notes in my absolutely awful handwriting, and the assumption that a good software dev is a lazy bum who just serializes their internal data representation to a binary file...

    PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
Strawberry perl on Win 2016
2 direct replies — Read more / Contribute
by beckmanel
on Aug 23, 2023 at 10:45
    Apparently when I run a perl program from the task scheduler, and it runs a sub-process and returns data by standard out, the data does not get back to the calling process. This worked in older versions of Windows. I'm using Strawberry Perl v5.20.2 They now have a latest version as 5.32 . Would the new version work with this later version of Windows? If I upgrade the perl version, will modules that have been added to the basic distribution, be lost? Thank You
Daemonizing (or otherwise speeding up) a high-overhead script?
5 direct replies — Read more / Contribute
by Anonymous Monk
on Aug 23, 2023 at 10:09

    We have a large app built in Catalyst, that has a very high startup overhead, thanks to a large number of database connections that have to be set up at the start of every run. It takes about 30 seconds or so before it starts to respond. It's only the startup that's affected by this; once it's running, there's no memory pressure or CPU stress.

    Normally this isn't a big deal; we roll out new versions once every week or three, and deploy it on different boxes in turn, so it's always up. However, we also run a frequent cron script based on the app, and this gets to be a real problem. We run it with different parameters to process different tasks, sometimes every five minutes, and here, a 30-second startup cost gets to be significant. (Once again, after the app loads, the processing itself usually only takes a second or two.) In some cases, we need to run multiple versions in parallel, because some tasks have network delays from dealing with external APIs, so we'll do things like run one script to process odd-number IDs, another to run even-number IDs.

    We've looked at some discussions here and on Stack Overflow about daemonizing the script, but it's not really clear how we'd control it the way we do now. That is, currently we might run a dozen versions from cron, with "process task A", "process task B", "process even-number task C's", "process odd-number task C's", etc. This is easy to manage; if we add a "task D", we add another cron job to "process task D"; the tasks that only need to run once a day get a cron job that does them at 3 a.m.; etc.

    But communicating with daemons isn't something we have experience with--none of us are systems guys--and trying to write the logic into the script itself seems impossible. Are there guidelines for how to deal with this? Assume there's no way to reduce the startup costs.

Meditations
New built-in perl5.38 try/catch syntax
No replies — Read more | Post response
by eyepopslikeamosquito
on Aug 23, 2023 at 06:16

    After recently installing perl 5.38, I stumbled upon some cool improvements to Perl's built-in try/catch syntax while watching the excellent What's new in Perl v5.38 youtube talk, delivered by Paul "LeoNerd" Evans at TPRC 2023 Toronto.

    New perl 5.38 use feature 'try'

    • perl v5.34 added try/catch syntax based on CPAN module Syntax::Keyword::Try
    • perl v5.36 added "finally" blocks to try/catch, also inspired by Syntax::Keyword::Try
    • perl v5.36 added use feature 'defer', allowing you to create defer blocks that run at the time that execution leaves the block it's declared inside (which seems to be inspired by the classic RAII programming idiom)
    • use v5.38 implies use feature 'try'

    Some perldoc References

    To get a feel for how all this works in practice, I created a simple example, consisting of two files in a scratch directory, TestTry.pm and trytest.pl, shown below.

    TestTry.pm

    package TestTry; use strict; use warnings; print "TestTry: module load\n"; sub life { my $n = shift; defined($n) or die "error: no argument provided"; print "TestTry::life n='$n'\n"; $n =~ /^\d+$/ or die "input error: '$n' must consist of digits only +"; $n == 42 or die "Sadly there is no meaning in your life (n=$n) +"; print "TestTry: congrats, your life has meaning!\n"; print "TestTry::life end\n"; } 1;

    trytest.pl

    # trytest.pl - a simple test of new perl 5.38 try syntax: # Put TestTry.pm in same dir as trytest.pl and run with: # perl -I . trytest.pl # Note: use v5.38 implies use strict and warnings use v5.38; # use feature 'try'; # throws 'try/catch is experimental' warnings use experimental 'try'; use TestTry; sub do_one { my $number = shift; try { TestTry::life($number); } catch ($e) { chomp $e; print "trytest: caught '$e'\n"; } finally { print "trytest: in finally block\n"; } } print "trytest: start\n"; do_one("invalid"); do_one(13); do_one(42); print "trytest: end\n";

    Example run

    With that done, assuming you have perl 5.38 installed, you can run:

    $ perl -I . trytest.pl TestTry: module load trytest: start TestTry::life n='invalid' trytest: caught 'input error: 'invalid' must consist of digits only at + TestTry.pm line 11.' trytest: in finally block TestTry::life n='13' trytest: caught 'Sadly there is no meaning in your life (n=13) at Test +Try.pm line 12.' trytest: in finally block TestTry::life n='42' TestTry: congrats, your life has meaning! TestTry::life end trytest: in finally block trytest: end

    Summary

    I really like this new try/catch syntax and am looking forward to Perl providing built-in exception handling without having to install CPAN modules, such as Try::Tiny and TryCatch.

    Remembering the smartmatch/Switch debacle, I'm also a fan of this new gentler way of introducing experimental new features into the Perl core.

    See Also

Handling of Unicode File Names
No replies — Read more | Post response
by NERDVANA
on Aug 22, 2023 at 23:27

    The Problem

    I have long been bothered by the problem where I read a directory name which happens to be a UTF-8 representation of unicode, then append a unicode string to that name, then try writing out to that new filename but get an error that the directory does not exist:

    $ perl -E 'mkdir("\x{100}")' $ perl -MB -E 'my @d= <*>; say B::perlstring($_) for @d' "\304\200" $ perl -E 'my ($d)= <*>; open(my $f, ">", "$d/\x{101}.txt") or die "$! +"' No such file or directory at -e line 1.

    Why? Because Perl passes the scalar to C library's 'open' and that delivers a UTF-8 encoding of the entire string, and the bytes that came from glob (and were never decoded from UTF-8) get their individual UTF-8 bytes encoded as UTF-8 characters.

    Perl expects the user to keep track of which strings are unicode and which strings are bytes, and never mix the two. In the example above, the real problem/bug is that glob returns bytes, and "$d/\x{101}.txt" is mixing bytes with unicode, producing garbage.

    While that answer is technically correct, I'm not satisfied with it, because it results an a sub-optimal user experience. A user *ought* to be able to list a directory, and have Unicode, append unicode to it, and write them back out. This process ought to be easy, instead of splattering the code with calls to encode() and decode(). Why can't we have nice things?

    (The problem is even worse on Windows, where you must configure your program to run with the UTF-8 codepage or else you get even worse garbage, since Perl internally uses the ANSI variants of the Win32 API which replaces unrepresentable characters with placeholders)

    What Does Python Do

    Python 2 had a system where unicode strings were represented differently from ascii strings, and so the solution in Python 2 was "unicode in, unicode out". In other words, if you call a directory listing with a unicode directory path, all the results come back as unicode strings. So what happens if you try reading an invalid UTF-8 sequence when you requested Unicode return values? it just returns a non-unicode string in the mix with the unicode ones.

    $ python2.7 Python 2.7.18 (default, Oct 10 2021, 22:29:32) [GCC 11.1.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> l=os.listdir(".") >>> l ['\xc4\x80'] >>> l=os.listdir(u".") >>> l [u'\u0100']
    (now write a file alongside it which is one correct UTF8 character and one non-utf8 byte)
    $ perl -MB -E 'open(my $f, ">", "\x{C4}\x{80}\x{A0}.txt") or die "$!"' $ python2.7 Python 2.7.18 (default, Oct 10 2021, 22:29:32) [GCC 11.1.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> l=os.listdir('.') >>> l ['\xc4\x80\xa0.txt', '\xc4\x80'] >>> l=os.listdir(u'.') >>> l ['\xc4\x80\xa0.txt', u'\u0100']
    So, does this API behavior result in a sensible developer experience?
    >>> open(l[1]+'/'+l[0], 'w') Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 0 +: ordinal not in range(128)
    The answer to "what happens when you try combining ascii directory with unicode filename" is "it doesn't let you do that". So, that saves the developer from head-scratching i/o errors, and puts the exception closer to the source of the problem.

    Unfortunately, Perl can't adopt this solution because Perl doesn't have a logical separation between Unicode and Ascii strings. (yes there is Perl's utf8 flag, but that's not a logical difference between contents of scalars. References available upon request.)

    But, in Python 3.0, all strings are unicode! (similar in some ways to perl's stance) So what did they do for this situation?

    $ python3 Python 3.11.3 (main, Jun 5 2023, 09:32:32) [GCC 13.1.1 20230429] on l +inux Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> l=os.listdir('.') >>> l ['&#256;\udca0.txt', '&#256;'] >>>
    So, er.... they return an invalid representation of the bytes? That is "\x{100}" followed by "\x{DCA0}" in place of the byte "\x{A0}". What is the Unicode 0xDC00 range? It's called the "Low Surrogate Area", and unicode.org says
    Low Surrogate Area Range: DC00-DFFF Isolated surrogate code points have no interpretation; consequently, no character code charts or names lists are provided for this range. See http://www.unicode.org/charts/ for access to a complete list of the latest character code charts. ... For a complete understanding of high-surrogate code units low-surrogate code units, and surrogate pairs used for the UTF-16 encoding form, see the appropriate sections of the Unicode Standard
    So basically, Python 3 encodes stray non-utf8 bytes as values in a reserved-for-other-uses set of codepoints which should never appear in a real unicode string. Does it work correctly for round trips?
    >>> open(l[1]+'/'+l[0], "w") <_io.TextIOWrapper name='&#256;/&#256;\udca0.txt' mode='w' encoding='U +TF-8'> >>> l=os.listdir('\u0100') >>> l ['&#256;\udca0.txt'] ^d $ perl -E ' sub escapestr { $_[0] =~ s/([^\x20-\x7E])/sprintf("\\x%02X", ord $1)/egr } say escapestr($_) for <\x{100}/*>' \xC4\x80/\xC4\x80\xA0.txt

    Sure enough, it round-trips those 0xDC00-0xDCFF codepoints back to the single non-unicode bytes they came from.

    What Can We Do In Perl?

    The python3 +0xDC00 solution could be used in Perl to handle non-utf8 characters in a new unicode-friendly API. But, how does this work out alongside our other APIs?

    Lets suppose we add a new feature "unicodefilenames". (hopefully we wouldn't have to type that much, and could eventually lump it in with "use v5.50")

    use feature 'unicodefilenames'; my ($d)= <*>; open(my $f, ">", "$d/\x{101}.txt") or die "$!";
    This works now. But what happens if we pass these file name to other modules in our program?
    package New; use v5.42; use feature 'unicodefilenames'; Old->foo($_) for <*>; package Old; use v5.38; sub foo($fname) { open my $fh, "<", $fname; }

    Whoops. The new unicode names get passed to a module that expects "a filename", and all filenames were previously strings of bytes, so it will get encoded as plain-old-utf8 which doesn't respect the conversion from "\xDCA0" to "\xA0". So, anyone with a european locale having lots of upper Latin-1 will end up with frequent breakage.

    What if Perl handled the "\xDC00" range specially regardless of the feature bit? This would break any old code that had been writing filenames using those characters. But nobody should ever be writing them... because it would only ever occur in a UTF-16 encoding. So the only reason anyone would legitimately want to write them was if they took a UTF-16 encoded string and then further encoded that as utf-8 and wanted it to be a filename.

    Assuming p5p decided that was an acceptable amount of back-compat breakage, what else could go wrong?

    package New; use v5.42; use feature 'unicodefilenames'; Old->foo($_) for <*>; package Old; use v5.38; sub foo($fname) { my $dir= "tmp\x{85}"; mkdir $dir or die "$!"; system("cp -a $fname $dir/$fname") == 0 or die "$!"; }

    Whoops, there are two bugs here. First, the Old module doesn't know that it is being given a unicode filename. Then, not anticipating this to be a problem, it combines that string with a non-unicode string, resulting in garbage. Then as a second problem, it shells out to a command, and the Perl interpreter has no way of knowing whether this is a "filename" situation where 0xDC00 should be re-interpreted. Keep in mind that people might have all sorts of reasons for passing invalid unicode (or utf-16 codes) as arguments to external programs. (well, maybe not, but it seems a lot more likely than passing them as filenames to filesystem APIs)

    But wait, what does Python do for passing bytes to external programs if all their strings are unicode?

    $ python3 Python 3.11.3 (main, Jun 5 2023, 09:32:32) [GCC 13.1.1 20230429] on l +inux Type "help", "copyright", "credits" or "license" for more information. >>> import subprocess (Wrapped for readability) >>> subprocess.run([ 'perl','-E', 'sub escapestr { $_[0] =~ s/([^\x20-\x7E])/sprintf("\\x%02X", ord $1)/egr } say escapestr($ARGV[0])', "\x80"]) C280 >>> subprocess.run([ 'perl','-E', 'sub escapestr { $_[0] =~ s/([^\x20-\x7E])/sprintf("\\x%02X", ord $1)/egr } say escapestr($ARGV[0])', "\x80"]) 80

    Woah! Pretty bold there, Python! If you want to pass the byte 0x80 as a parameter to an external program, you'd need to encode it as "\xDC80" in your always-unicode strings. (Or, use the Python3 "bytes" object instead of trying to carry around raw bytes inside unicode strings, which is what all the tutorials teach) Anyway, interesting and all, but I'm guessing this is a step too far for perl 5.

    So back to filenames. What can we do? It looks like the only way we can prevent bugs from erupting everywhere is to keep using strings of plain bytes, with unicode converted to UTF-8 (or perhaps encoded according to locale, if anyone ever uses non-utf8 locales anymore). But, what if we wrap filenames with objects?

    package New; use v5.36; use Path::UTiny; # imagine a unicode-aware Path::Tiny # Create directory named "\xC4\x80" path("\x{100}")->mkdir; for (path(".")->children) { # compares as unicode Old->foo($_) if $_->name eq /\x{100}/; } package Old; use v5.36; sub foo($dir) { # stringify to bytes, creates file "\xC4\x80/\x80.txt" open my $f, '>', "$dir/\x80.txt"; }

    This actually works! To be clear, I'm proposing that the path object would track unicode internally (where it could use Python3's trick of remapping the ambiguous bytes) and any time it was coerced to a string by unsuspecting legacy code, or by PerlIO API calls, it would yield the usual UTF-8 bytes.

    The downside is that you still can't write

    $path= path("$path/$unicode")
    because that would still be combining unicode with non-unicode. The ".=" operator could be overloaded to return new Path objects, but that might also surprise users when $x .= "/$y" has different results than $x= "$x/$y" so maybe not.

    Conclusion

    I don't see any practical way for Perl 5 to upgrade to unicode filenames in plain strings and native PerlIO functions. It would create about as many problems as it would solve. But, a new path object library that works with unicode internally but stringifies to bytes would have a chance of being useful for working with unicode without breaking too many common assumptions.

Cool Uses for Perl
MCE Sandbox 2023-08
1 direct reply — Read more / Contribute
by marioroy
on Aug 28, 2023 at 02:03

    The MCE Sandbox repository is where I try writing fast code using Perl MCE + Inline::C, Math::Prime::Util, and the C/C++ libprimesieve library. The examples folder is new for the 2023 update. I learned Codon, a Python-like language that compiles to native code.

    .Inline/ Where Inline::C is configured to cache C object file +s. bin/ algorithm3.pl Practical sieve based on Algorithm3 from Xuedong Luo + [1]. primesieve.pl Calls the primesieve.org C API for generating primes +. primeutil.pl Utilizes the Math::Prime::Util module for primes. examples/ primes1.c Algorithm3 in C with OpenMP directives. primes2.codon Algorithm3 in Codon, a Python-like language. primes3.c Using libprimesieve C API in C primes4.codon Using libprimesieve C API in Codon lib/ Sandbox.pm Common code for the bin scripts. src/ algorithm3.c Inline::C code for algorithm3.pl. bits.h Utility functions for byte array. output.h Fast printing of primes to a file descriptor. primesieve.c Inline::C code for primesieve.pl. sandbox.h Header file, includes bits.h, output.h, sprintull.h. sprintull.h Fast base10 to string conversion. typemap Type-map file for Inline::C.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2023-08-29 00:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?