System...utoLoad(3pm)

πŸ“¦
version 0.162800 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– System::Sub::AutoLoad πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation, and the whole vibe is: System::Sub::AutoLoad β€” aka the module that turns your random unknown subs into actual external commands like it's nothing. no cap. πŸ¦‹


✨ NAME ✨

System::Sub::AutoLoad β€” auto-wrap external commands as DWIM subs 🫢


🌸 VERSION 🌸

version 0.162800 ✨


πŸŽ€ SYNOPSIS πŸŽ€

πŸ’… Basic usage

Any unknown sub will become a System::Sub. literally any of them. it's giving main character energy.

use System::Sub::AutoLoad;

my $hostname = hostname();

πŸ¦‹ Usage with forward declaration

Allows to avoid using parentheses. System::Sub import stays lazy. so chill, it's not doing work until it has to 😌

use System::Sub::AutoLoad qw(hostname);

my $hostname = hostname;

🌈 Usage with forward declaration command options

Options definitions will be checked lazily at the first call to the AUTOLOAD for that sub. yes bestie, lazily. we love a procrastination icon.

use System::Sub::AutoLoad hostname => [ 0 => '/bin/hostname' ];

my $hostname = hostname;

πŸ‘‘ DESCRIPTION πŸ‘‘

Any unknown sub in your code will be transformed into a System::Sub at its first call. This is lazy <http://en.wikipedia.org/wiki/Lazy_evaluation> import for System::Sub. πŸ”₯

To avoid using parentheses after the sub name, you usually have to predeclare the sub with either a forward declaration (a sub without body such as sub foo;) or with the subs module. But with Sytem::Sub::AutoLoad you can simply list the subs names on the use line and that will be done for you. no extra steps, no drama, periodt. πŸ’…

You can also pass System::Sub options to the sub, but they will be lazily analysed: this is the full System::Sub power, but with lazy import. the way that it gives you everything and still does nothing until you ask?? iconic. ⭐

🧚 Implementation details

This module exports an AUTOLOAD sub that will import the sub with System::Sub at its first call. that's the whole magic trick, bestie, that's the tea πŸ“


πŸ’œ AUTHOR πŸ’œ

Olivier MenguΓ©, dolmen@cpan.org. shoutout to the legend πŸ’–


Copyright Β© 2012 Olivier MenguΓ©.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself. so go off, redistribute responsibly 🫢


fr fr, that's the whole page β€” nothing skipped, nothing made up, all the details kept exactly as they came. iykyk. πŸ’€βœ¨

signing off from perl v5.36.0, dated 2022-12-06 β€” mwah, stay lazy (in the good way) πŸŽ€πŸŒΈ

πŸ“¦ where this page comes from