How do you type and then (execute/run) Perl statements directly in the Perl shell/interpreter?
First, I'm on Windows... and I have Strawberry Perl (v5.32.1) built for MSWin32-x64-multi-thread installed.
So, if I type at the command line, just :
perl
... it appears to enter into a Perl "shell/interpreter", but if I enter some Perl statements :
my $greeting = "Hello World :-)\n";
print($greeting);
... how do I make it then "execute/run" those two statements?
If I Ctrlc, then it just says: Terminating on signal SIGINT(2)
If it matters, the reason I'd like to do this is so that I can just test Perl language as I'm learning about Perl.
Entering Ctrl + Z (final Enter still needed) corresponds to Ctrl + D on *nix and means End of file. You can also enter __END__
.
You can get a REPL using the debugger:
$ perl -d -e 1
Loading DB routines from perl5db.pl version 1.49
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(-e:1): 1
DB<1> x "blah" x 5
0 'blahblahblahblahblah'
Use x expression
or p expression
to evaluate an expression and display the result in different ways.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With