Add the following packages libalgorithm-diff-perl libspiffy-perl libtext-diff-perl...
[pkg-perl] / deb-src / libfilter-perl / libfilter-perl-1.34 / lib / Filter / sh.pm
1 package Filter::sh;
2  
3 use Carp ;
4 use strict ;
5 use warnings ;
6 use vars qw($VERSION) ;
7 $VERSION = "1.01" ;
8
9 use Filter::Util::Exec ;
10
11 sub import 
12
13     my($self, @args) = @_ ;
14
15     croak ("Usage: use Filter::sh 'command'")
16         unless @args ;
17
18     #require "Filter/exec.pm" ;
19     #Filter::exec::import ($self, 'sh', '-c', "@args") ; 
20     if ($^O eq 'MSWin32') {
21         Filter::Util::Exec::filter_add ($self, 'cmd', '/c', "@args") ; 
22     }
23     else {
24         Filter::Util::Exec::filter_add ($self, 'sh', '-c', "@args") ; 
25     }
26 }
27
28 1 ;
29 __END__
30
31 =head1 NAME
32
33 Filter::sh - sh source filter
34
35 =head1 SYNOPSIS
36
37     use Filter::sh 'command' ;
38
39 =head1 DESCRIPTION
40
41 This filter pipes the current source file through the program which
42 corresponds to the C<command> parameter using the Bourne shell. 
43
44 As with all source filters its scope is limited to the current source
45 file only. Every file you want to be processed by the filter must have a
46
47     use Filter::sh 'command' ;
48
49 near the top.
50
51 Here is an example script which uses the filter:
52
53     use Filter::sh 'tr XYZ PQR' ;
54     $a = 1 ;
55     print "XYZ a = $a\n" ;
56
57 And here is what it will output:
58
59     PQR = 1
60
61 =head1 WARNING
62
63 You should be I<very> careful when using this filter. Because of the
64 way the filter is implemented it is possible to end up with deadlock.
65
66 Be especially careful when stacking multiple instances of the filter in
67 a single source file.
68
69 =head1 AUTHOR
70
71 Paul Marquess 
72
73 =head1 DATE
74
75 11th December 1995.
76
77 =cut
78