alias iperl='rlwrap -A -S "iperl> " perl -MData::Printer -wnE '\''BEGIN { say "# Use `p @<arrayOrList>` or `p %<hashTable>` to print arrays/lists/hashtables; e.g.: `p %ENV`"; } say eval()//$@'\'
例如,你可以执行以下操作,通过哈希表%ENV打印所有环境变量:
$ iperl # start the REPL
iperl> p %ENV # print key-value pairs in hashtable %ENV
与Ján的答案一样,表达式的标量结果打印为自动;例如:
iperl> 22 / 7 # automatically print scalar result of expression: 3.14285714285714
Unix-like platforms: Download this script as perli to a folder in your system's path and make it executable with chmod +x.
Windows: Download the this script as perli.pl (note the .pl extension) to a folder in your system's path.
If you don't mind invoking Perli as perli.pl, you're all set.
Otherwise, create a batch file named perli.cmd in the same folder with the following content: @%~dpn.pl %*; this enables invocation as just perli.