Quantcast
Channel: Applied Electronics Journal
Viewing all articles
Browse latest Browse all 21

Preprocess text with embedded perl code

$
0
0

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);


Filed under: Bookmarks Tagged: embedded, Perl, pipe, Preprocessor

Viewing all articles
Browse latest Browse all 21

Trending Articles