perl-code

Description

A block of perl code enclosed in curly brackets or an expression which interpolates to a perl expression. Variables defined in XSH are visible in perl code as well. Since, in the interactive mode, XSH redirects output to the terminal, you cannot simply use perl print function for output if you want to filter the result with a shell command. Instead use the predefined perl routine echo(...) which is equivalent to Perl's print $::OUT .... The $::OUT perl-variable stores the reference to the terminal file handle.

For more information about embedded Perl code in XSH, predefined functions etc. see Perl_shell.

xsh> $i="foo";
xsh> eval { echo "$i-bar\n"; }# prints foo-bar
xsh> eval 'echo "\$i-bar\n";'# exactly the same as above
xsh> eval 'echo "$i-bar\n";'# prints foo-bar too, but $i is
    # interpolated by XSH. Perl actually evaluates echo "foo-bar\n";