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