Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I Minify a Perl Script?

Tags:

perl

minify

I want to minify a perl script so that I can detect practically identical perl scripts that have only differences in line comments, blank lines, etc. I there a pre-built script to do this minification? If so, I would be able to checksum and highlight the identical files on my own.

like image 480
700 Software Avatar asked Jan 07 '13 16:01

700 Software


1 Answers

Not exactly minifying, but you can use B::Deparse to compile a Perl script, then decompile it back to Perl.

You can diff the results.

A simple command line example follows:

david@Workstation:comp # perl -MO=Deparse 1.pl > a.pl
1.pl syntax OK
david@Workstation:comp # perl -MO=Deparse 2.pl > b.pl
2.pl syntax OK
david@Workstation:comp # diff a.pl b.pl
david@Workstation:comp # diff 1.pl 2.pl
3c3,5
< say "Hello";
---
> 
> 
>   say "Hello";
david@Workstation:comp # 
like image 69
Quentin Avatar answered Nov 15 '22 06:11

Quentin