xsay: add support for sselp and xclip; output error message
[grml-scripts.git] / usr_bin / unbleach.pl
1 #!/usr/bin/perl
2 # Filename:      unbleach.pl
3 # Purpose:       for really dirty perl programs
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 # Latest change: Feb 26 2005 [mika]
8 ################################################################################
9
10 # This script will replace all the unsighted unprintable characters bleached out of your source file by a:
11 #   use Acme::Bleach;
12 # directive with elegant (perhaps) ASCII perl code. 
13
14 use strict;
15 my $washing = pop or carp("Usage: unbleach.pl [file]\n");
16 open white,"<$washing" or carp("Can't get $washing");
17 local $/; $_=<white>;
18 s/(.*)^\s*use\s+Acme::Bleach\s*;\n(?: \t){8}/$1/
19 or carp("$washing is not bleached!");
20 open line,">$washing" or carp("Can't dry $washing");
21 print line out($_);
22 sub out {s/\n//g;tr/ \t/01/;pack "b*",$_;}
23 sub carp {print shift and exit}
24
25 =head1 NAME
26
27 unbleach.pl - For I<really> unclean programs
28
29 =head1 SYNOPSIS
30
31 unbleach.pl [file]
32
33 =head1 DESCRIPTION
34
35 This script will replace all the unsighted unprintable
36 characters bleached out of your source file by a:
37
38     use Acme::Bleach;
39
40 directive with elegant (perhaps) ASCII perl code.
41
42 It also removes the use bleach line when it rewrites
43 the source code. The code continues to work exactly
44 as it did before, but now looks like normal!
45
46 =head1 DIAGNOSTICS
47
48 =item C<Can't get '%s'>
49
50 unbleach.pl could not read the source file.
51
52 =item C<'%s' is not bleached!>
53
54 unbleach.pl will only process files that have been
55 previously bleached and have the expected format.
56
57 =item C<Can't dry '%s'>
58
59 unbleach.pl could not open the source file to modify it.
60
61 =head1 SEE ALSO
62
63 http://www.cpan.org/authors/id/DCONWAY/Acme-Bleach-1.12.tar.gz
64 http://www.perlmonks.com
65
66 =head1 AUTHOR
67
68 not Damian Conway (as if you couldn't guess)
69
70 =head1 COPYRIGHT
71
72 Copyright (c) 2001, tachyon. All Rights Reserved.
73 This script is free software. It may be used, redistributed
74 and/or modified under the terms of the Perl Artistic License
75 (see http://www.perl.com/perl/misc/Artistic.html)