Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

profanity here?

by PodMaster (Abbot)
on Jun 09, 2003 at 10:15 UTC ( #264285=snippet: print w/ replies, xml ) Need Help??

Description: Sometimes profanity creeps into my work code, and I'd really like not to publish it (especially on CPAN). That's why I whipped this snippet up.

Usage:

    $ perl profanity optional dirpaths . is searched by default

    $ perl profanity
    ./profanity : 42 : turds

This proggie will probably never make use of the Pod::Usage/Getopt::Long combo.
#!/usr/bin/perl

use File::Find();
use Regexp::Common qw /profanity/;

use strict;
use warnings;

@ARGV = '.' unless @ARGV;

File::Find::find(
    {
        wanted => \&wanted,
        no_chdir => 1,
    },
    @ARGV
);

exit(0);

sub wanted {
    isProfane( $_ ) if -r $_ and -T _;
}

sub isProfane {
    my( $file, $fh ) = @_;

    open $fh, '<', $file
        or die "couldn't read $file : $!";

    while( readline $fh ){
        for my $w( /$RE{profanity}{-keep}/g ){
            print "$file : $. : $w\n";
        }
    }

    close $fh;
}

# Soylent Cowflop is people, people!
# That's probably why turds make great manure.
# ~~~~~~~~~~~~~~~~~~~~^^^^^

Comment on profanity here?
Download Code
Re: profanity here?
by benn (Priest) on Jun 09, 2003 at 10:37 UTC
    That's ******* great - what a ******* good idea you clever ****** - it'd save my ******* *** being whipped every ******* time my ******* code goes out of the ******* door...

    :) Cheers, Ben.

Re: profanity here?
by Aristotle (Chancellor) on Jun 09, 2003 at 12:04 UTC
    If you want to have some fun, run this against the Linux sources. ;-)

    Makeshifts last the longest.

Re: profanity here?
by shotgunefx (Parson) on Jun 09, 2003 at 19:44 UTC
    PodMaster++
    My code used to be peppered like it had Tourettes. The more problematic the job, the worse it got. It was a real hard habit to break but worthwhile.

    I was always afraid of having a client tell me they got an error like "F****** c**t sh*t: $!" because I missed removing one.

    -Lee

    "To be civilized is to deny one's nature."
      F****** c**t sh*t: $!

      Ok, I've never been very good at cryptic crosswords words but I'm guessing "Firearm colt shot". You're not one of those Geeks with Guns are you?

        Pretty weird guess for a thread on profanity :P
        But to answer, nope, no longer own any firearms.

        -Lee

        "To be civilized is to deny one's nature."

Back to Snippets Section

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2015-07-06 04:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls