PERLSH(1)

πŸ’– PERLSH(1) β€” like, the perlsh manual but make it cute πŸ’–

okay bestie, gather round, because perlsh is about to become your new main character. it's a one-line perl evaluator with a line editing function and a variable name completion function, and honestly? it's giving genius.


✨ SYNOPSIS ✨

perlsh

that's it. that's the whole vibe. just type it and go 🫢


🌸 DESCRIPTION 🌸

so here's the tea: this program reads a line of input, evaluates it with the perl interpreter, and prints the result. no cap. and if the result is a list value, then every single value of that list gets printed line by line, one after another, like a little parade. πŸ’…

lowkey you can use this as a very strong calculator that has the whole entire perl function set at its disposal. it's not just a calculator, it's THE calculator. ate.

this is a sample program for the Term::ReadLine::Gnu module. when you input a line, the line editing function of the GNU Readline Library is available to you. the perl symbol name completion function is also available. iconic behavior, fr fr.

before invoking, this program reads ~/.perlshrc and evaluates the content of that file. so you can set up your whole little world before it even says hi. πŸŽ€

and when this program is terminated, the content of the history buffer is saved in a file called ~/.perlsh_history, and it gets read again at the next invoking. it remembers. it cares. πŸ˜­πŸ’œ


πŸ¦‹ VARIABLES πŸ¦‹

you can customize the behavior of perlsh by setting the following variables in ~/.perlshrc. so many knobs, so much power:

  • $PerlSh::PS1 β€” the primary prompt string. you can use the following backslash-escaped special characters in it:
\h: host name
\u: user name
\w: package name
\!: history number

the default value is "\w[\!]$ ".

  • $PerlSh::PS2 β€” the secondary prompt string. the default value is "> ".
  • $PerlSh::HISTFILE β€” the name of the file to which the command history is saved. the default value is "~/.perlsh_history".
  • $PerlSh::HISTSIZE β€” if it's not undef, this is the maximum number of commands to remember in the history. the default value is 256.
  • $PerlSh::STRICT β€” if true, it restricts unsafe constructs. see "use strict" in the perl man page for the details. the default value is 0.

πŸŽ€ FILES πŸŽ€

  • ~/.perlshrc β€” this file is eval-ed at initialization. and here's the cute part: if a subroutine afterinit is defined in this file, it will be eval-ed after initialization. a whole little post-init glow-up. ✨ here's a sample:
# -*- mode: perl -*-
# decimal to hexa
sub h { map { sprintf("0x%x", $_ ) } @_;}

sub tk {
    $t->tkRunning(1);
    use Tk;
    $mw = MainWindow->new();
}

# for debugging Term::ReadLine::Gnu
sub afterinit {
    *t = \$PerlSh::term;
    *a = \$PerlSh::attribs;
}
  • ~/.perlsh_history β€” the history file, bestie. it's where your whole command journey lives. 🫢
  • ~/.inputrc β€” an initialization file for the GNU Readline Library. refer to its manual for details, iykyk.

🌈 SEE ALSO 🌈


πŸ‘‘ AUTHOR πŸ‘‘

Hiroo Hayashi <hiroo.hayashi@computer.org> β€” the legend themselves. we stan. πŸ’–


and that's a wrap on perlsh! this whole page came from perl v5.42.0 and it's dated 2025-07-25, so if you're reading this you're living in the future and it's serving. go forth and evaluate some lines, bestie. no notes. periodt. πŸ’…βœ¨πŸŒΈ
πŸ“¦ where this page comes from