Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: suggested module/tools to automatically "tighten" my perl

by Khen1950fx (Canon)
on Jun 22, 2012 at 04:06 UTC ( [id://977758]=note: print w/replies, xml ) Need Help??


in reply to suggested module/tools to automatically "tighten" my perl

Here's what I use to strip comments. Note: it also erases the shebang line.
#!/usr/bin/perl use strict; use warnings; my $file = shift @ARGV; open STDOUT, '>', '/root/Desktop/squish.log'; use PPI; use Perl::Squish; my $Document = PPI::Document->new($file); $Document->prune( sub { my $Braces = $_[1]; $Braces->isa('PPI::Structure::List') or return ''; $Braces->children == 0 or return ''; my $Method = $Braces->sprevious_sibling or return ''; $Method->isa('PPI::Token::Word') or return ''; $Method->content !~ /:/ or return ''; my $Operator = $Method->sprevious_sibling or return ''; $Operator->isa('PPI::Token::Operator') or return ''; $Operator->content eq '->' or return ''; return 1; } ); my $Normal = $Document->normalized(2); print $Document;

Replies are listed 'Best First'.
Re^2: suggested module/tools to automatically "tighten" my perl
by Anonymous Monk on Jun 22, 2012 at 06:07 UTC

    Here's what I use to strip comments. Note: it also erases the shebang line

    A copy/paste from Perl::Squish, clever

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://977758]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (7)
As of 2024-03-29 12:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found