home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / perl / 5.8.8 / re.pm < prev    next >
Encoding:
Perl POD Document  |  2007-03-05  |  1.3 KB  |  63 lines

  1. package re;
  2.  
  3. our $VERSION = 0.05;
  4.  
  5. # N.B. File::Basename contains a literal for 'taint' as a fallback.  If
  6. # taint is changed here, File::Basename must be updated as well.
  7. my %bitmask = (
  8. taint        => 0x00100000, # HINT_RE_TAINT
  9. eval        => 0x00200000, # HINT_RE_EVAL
  10. );
  11.  
  12. sub setcolor {
  13.  eval {                # Ignore errors
  14.   require Term::Cap;
  15.  
  16.   my $terminal = Tgetent Term::Cap ({OSPEED => 9600}); # Avoid warning.
  17.   my $props = $ENV{PERL_RE_TC} || 'md,me,so,se,us,ue';
  18.   my @props = split /,/, $props;
  19.   my $colors = join "\t", map {$terminal->Tputs($_,1)} @props;
  20.  
  21.   $colors =~ s/\0//g;
  22.   $ENV{PERL_RE_COLORS} = $colors;
  23.  };
  24. }
  25.  
  26. sub bits {
  27.     my $on = shift;
  28.     my $bits = 0;
  29.     unless (@_) {
  30.     require Carp;
  31.     Carp::carp("Useless use of \"re\" pragma");
  32.     }
  33.     foreach my $s (@_){
  34.       if ($s eq 'debug' or $s eq 'debugcolor') {
  35.        setcolor() if $s eq 'debugcolor';
  36.       require XSLoader;
  37.       XSLoader::load('re');
  38.       install() if $on;
  39.       uninstall() unless $on;
  40.       next;
  41.       }
  42.       if (exists $bitmask{$s}) {
  43.       $bits |= $bitmask{$s};
  44.       } else {
  45.       require Carp;
  46.       Carp::carp("Unknown \"re\" subpragma '$s' (known ones are: @{[join(', ', map {qq('$_')} 'debug', 'debugcolor', sort keys %bitmask)]})");
  47.       }
  48.     }
  49.     $bits;
  50. }
  51.  
  52. sub import {
  53.     shift;
  54.     $^H |= bits(1, @_);
  55. }
  56.  
  57. sub unimport {
  58.     shift;
  59.     $^H &= ~ bits(0, @_);
  60. }
  61.  
  62. 1;
  63.