Acme-Scripticide

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Perl extension Acme::Scripticide.

0.0.1  Sun Nov 13 10:28:35 2005
	- original version; created by h2xs 1.22 with options
		-AXc -n Acme::Scripticide
0.0.2  Sun Nov 13 17:12:55 2005
        - forgot a POD person

0.0.3  Sun Nov 13 17:22:29 2005
        -fixed POD and README version

0.0.4  Sun Nov 13 20:02:51 2005
	- sheesh more POD people...

MANIFEST  view on Meta::CPAN

Changes
Makefile.PL
MANIFEST
README
Scripticide.pm
META.yml                                Module meta-data (added by MakeMaker)

META.yml  view on Meta::CPAN

#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
name:         Acme-Scripticide
version:      v0.0.4
version_from: Scripticide.pm
installdirs:  site
requires:
    version:                       0

distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.12

Makefile.PL  view on Meta::CPAN

use ExtUtils::MakeMaker;

WriteMakefile(
    NAME              => 'Acme::Scripticide',
    VERSION_FROM      => 'Scripticide.pm', 
    PREREQ_PM         => { version => 0 },
    ($] >= 5.005 ?    
      (ABSTRACT_FROM  => 'Scripticide.pm',
       AUTHOR         => 'Daniel Muey, <http://drmuey.com/cpan_contact.pl>') : ()),
);

README  view on Meta::CPAN

Acme/Scripticide version 0.0.4
=====================

See Pod for documentation or 
 perldoc Acme::Scripticide

INSTALLATION

To install this module type the following:

   perl Makefile.PL
   make
   make install

or

  perl -MCPAN -e 'install Acme::Scripticide;'

COPYRIGHT AND LICENCE

Copyright (C) 2005 Daniel Muey

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

Scripticide.pm  view on Meta::CPAN

package Acme::Scripticide;

use strict;
use warnings;
use version;our $VERSION = qv('0.0.4');

use File::Spec;
use Carp;

sub import {
    $_[1]='' if !defined $_[1];
    *main::good_bye_cruel_world = *{Acme::Scripticide::good_bye_cruel_world} if $_[1] eq 'good_bye_cruel_world';
    good_bye_cruel_world($_[1], join(' ', @_[ 2 .. $#_ ])) if $_[1] ne 'good_bye_cruel_world';
}

sub good_bye_cruel_world {
    if(defined $_[0] && $_[0] =~ m/^\.\w+$/) {
        my $new = File::Spec->rel2abs($0);
        $new =~ s/\.\w+$//;
        open my $heart, '>', "$new$_[0]" or carp "'$new$_[0]' I have too much to live for, open: $!";
        print $heart $_[1];
        close $heart;

Scripticide.pm  view on Meta::CPAN

        unlink File::Spec->rel2abs($0) or carp "'$0' I have too much to live for, unlink: $!";
    }
}

1;

__END__

=head1 NAME

Acme::Scripticide - Perl extension to allow your script to kill itself

=head1 SYNOPSIS

auto call good_bye_cruel_world()

   use Acme::Scripticide; 
 
auto call good_bye_cruel_world('Good bye cruel world')

   use Acme::Scripticide qw(Good bye cruel world);

auto put "Good bye cruel world" in [$0 w/out \.\w+$].html, call good_bye_cruel_world()

   use Acme::Scripticide ('.html', qw(Good bye cruel world)); 

only do it when and where you want

   use Acme::Scripticide qw(good_bye_cruel_world);

   if(i_take_medication_and_therapy()) {
       print "Take that Tom Cruise, you wacky weirdo, tell Jackson howdy.";
   }
   else {
       good_bye_cruel_world();
   }
 
=head2 EXPORT

Scripticide.pm  view on Meta::CPAN

    good_bye_cruel_world($note)
   
This will make your script not exist once its done and put $note in [$0 w/out .\w+].ext

    good_bye_cruel_world('.ext', $note)

=head1 When this would actually be handy.

Beleive it or not this is handy if you have a one time job to execute:

    # $script uses Acme::Scripticide
    system $script if -e $script;

or say to create static files from a database:

    # in flowers.pl (copy this to whatever names you want and execute:)
    use Acme::Scripticide qw(good_bye_cruel_world);
    good_bye_cruel_world('.html', get_html($0));

now flowers.pl does not exist and flowers.html is there

You could have a directory full of those types of scripts and glob() them in and execute each one, once done you have a directory of corresponding static html files...

=head1 Disclaimer

Use at your own risk, this deletes your script so you've been warned :)



( run in 0.931 second using v1.01-cache-2.11-cpan-4505f990765 )