home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / sh.pm.bak < prev    next >
Encoding:
Text File  |  2002-06-14  |  1.5 KB  |  79 lines

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