Preprocess text with embedded perl code

Create my first project at Github:

This script can be downloaded from

https://github.com/agraja/text2perl/blob/master/text2perl.pl

#!/usr/bin/perl

# Tiny preprocessor:
# Example: Paste this example in a file
# Pass it as argument to this script
# some text /* for(1..5) { */
# this line will be printed 5 times
# /* } */
open(P,”|$^X”);
print P map {
if(/^\/\*(.*)/){
$1
}else{
s/([\\\’])/\\$1/g;
“print ‘$_’;”
}
}map{
s/\*\//\r/g;
split(/(\/\*[^\r]*\r)/)
}<>;
close(P);

Monitor Terminals Using script Command

Open a terminal and type as below

[raja@AGRAJA ~]$ mkfifo output
[raja@AGRAJA ~]$ script -f output

Open another terminal and type as below

[raja@AGRAJA ~]$ cat output

Now return to first terminal and execute any command.

Everything on the first terminal is updated on the second terminal also.

script.JPG