Ways of Seeing... code

Posted by Pall Thayer | Tue Mar 1st 2011 12:56 p.m.

How to use:
Let's say you have a perl code called 'my_script.pl'
perl printer.pl my_script.pl
This generates a new file named my_script_printered.pl Run it with:
perl my_script_printered.pl
Will also work with php scripts, i.e. my_script.php
perl printer.pl my_script.php
php -f my_script_printered.php
#!/usr/bin/perl
$file = @ARGV[0];
open FILE, $file;
$file =~ s/\./_printered\./;
open NEWFILE, '>'.$file;
while(<FILE>){
       print NEWFILE $_;
       print NEWFILE 'print \''.$_.'\';';
}
close(NEWFILE);
close(FILE);
  • Pall Thayer | Wed Mar 2nd 2011 12:20 p.m.
    The script isn't displaying correctly... the 'while' line is supposed to be the word 'while' followed by the less-than character, FILE, greater than character in parentheses, followed by an opening curly bracket.
Your Reply