pdl2(3pm)

πŸ¦‹ pdl2 β€” it's giving "simple shell (version 2) for PDL" πŸ’–

okay bestie, listen. this is pdl2(3pm), a User Contributed Perl doc, and it's basically the group chat where you and PDL hang out interactively. let's get into it ✨


✨ SYNOPSIS ✨

so like, you wanna use PDL interactively? say less:

%> pdl2

pdl> $x = sequence(10)  # or any other perl or PDL command

pdl> print "\$x = $x\n";
$x = [0 1 2 3 4 5 6 7 8 9]

pdl> with_time { print +($A->matmult($B))->info, "\n" } for 1..5;

look at her go. main character energy fr fr πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

The pdl2 program β€” also known as the Perldl2 shell, iykyk β€” is the second generation version of the original perldl interactive PDL shell. she's the glow-up version πŸŽ€. she tries to stay backward compatible in usage while bringing improved features, better support for Perl syntax, and a framework that's way easier to extend, built on top of the Devel::REPL shell.

here's the tea tho: if you have Devel::REPL version 1.003011 or later, then pdl2 starts up with full functionality, no cap πŸ”₯. but if Devel::REPL isn't installed or can't be found? pdl2 prints a warning and just runs the legacy perldl shell command instead. the show must go on πŸ’€

now, by default, command lines that begin with the default prompt of either pdl2 or perldl β€” that's one of 'pdl> ', 'PDL> ', or 'perldl> ' β€” will have that prefix string and the surrounding whitespace stripped right off. why do we care? because it lets you easily cut-and-paste from sample PDL shell sessions or other examples straight into another PDL shell session. obsessed with the convenience honestly 🫢

and for shell-like Ctrl-C handling? you need Sys::SigAction installed. that's the whole vibe check on that one.


🌸 FUNCTIONS 🌸

πŸŽ€ do_print

Toggle print-by-default on and off (default value: off)

so here's why this matters, bestie: by default, pdl2 does not print the results of operations, because those results can be very large (like, a small 640x480 RGBA image is still more than 1_000_000 elements. yeah. a million. 😭). but when you're experimenting and debugging more complex structures, it genuinely helps to see the results of every single operation. the do_print routine lets you toggle between the default "quiet" operation and a full Read, Evaluate, Loop style. periodt ✨

pdl> $x = pdl(3,2)

pdl> do_print
1
pdl> $x = pdl(3,2)
$PDL1 = [3 2];
pdl> do_print

pdl> $x = pdl(3,2)

see how the vibes shift? πŸ’–


🌈 VARIABLES 🌈

  • $PDL::toolongtoprint β€” the maximal size pdls to print (defaults to 10000 elements). and heads up, this is not just a perldl or pdl2 variable β€” it's something that's usually needed in an interactive debugging session. so she's a whole independent icon πŸ‘‘

⭐ SEE ALSO ⭐

  • perldl
  • Devel::REPL

ngl bestie, that's the whole page. no missing pieces, no skipped sections, we kept every crumb πŸ“

and that's a wrap on pdl2(3pm) from the User Contributed Perl Documentation, sitting pretty at perl v5.38.2, dated 2024-04-10. mwah πŸ’…βœ¨πŸ’œ

πŸ“¦ where this page comes from