This file is indexed.

/usr/share/perl5/Text/DelimMatch.pm is in libdelimmatch-perl 1.06a-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
package Text::DelimMatch;

use strict;
use vars qw($VERSION @ISA @EXPORT $case_sensitive);

require 5.000;
require Exporter;
require AutoLoader;

@ISA = qw(Exporter AutoLoader);
@EXPORT = qw();
$VERSION = '1.06';

sub new { 
    my $type  = shift;
    my $start = shift;
    my $end   = shift || $start;
    my $esc   = shift;
    my $dblesc= shift;
    my $class = ref($type) || $type;
    my $self  = bless {}, $class;
    local $_  = "no -w warning in evals now";

    eval "/$start/" if defined($start);
    eval "/$end/" if !$@ && defined($end);

    $self->{'STARTREGEXP'} = $start;  # a regexp
    $self->{'ENDREGEXP'}   = $end;    # a regexp
    $self->{'QUOTE'}	   = {};      # a hash of regexp, start => end
    $self->{'ESCAPE'}	   = "";      # a regexp set of chars
    $self->{'DBLESCAPE'}   = "";      # a regexp set of chars

    $self->{'ERROR'}	   = $@;  # false if OK
    $self->{'DEBUG'}	   = 0;	  # boolean
    $self->{'CASESENSE'}   = 0;	  # boolean
    $self->{'FORCESLOW'}   = 0;	  # boolean
    $self->{'KEEP'}	   = 1;	  # boolean
    $self->{'RETURNDELIM'} = 1;   # boolean

    $self->{'BUFFER'}	   = "";
    $self->{'PRE'}	   = "";
    $self->{'MATCH'}	   = "";
    $self->{'POST'}	   = "";

    $self->escape($esc) if $esc;
    $self->double_escape($dblesc) if $dblesc;
    $self->quote(@_) if @_;

    return $self;
}

sub delim {
    my $self   = shift;
    my $start  = shift;
    my $end    = shift || $start;
    my $curs   = $self->{'STARTREGEXP'};
    my $cure   = $self->{'ENDREGEXP'};
    local $_   = "no -w warning in evals now";

    eval "/$start/" if defined($start);
    eval "/$end/" if !$@ && defined($end);

    $self->{'ERROR'}	   = $@;  # false if OK
    $self->{'STARTREGEXP'} = $start;
    $self->{'ENDREGEXP'}   = $end;

    if ($self->{'DEBUG'}) {
	print "DELIM : $start, $end";
	print ": ", $self->{'ERROR'} if $self->{'ERROR'};
	print "\n";
    }

    return ($curs, $cure);
}

sub quote {
    my $self   = shift;
    my (%oldq) = %{$self->{'QUOTE'}};
    local $_   = "no -w warning in evals now";
    my ($key, $val);

    $key = shift @_;

    if (!defined($key)) {
	$self->{'QUOTE'} = {};
    } else {
	while ($key) {
	    $val = shift @_ || $key;

	    eval "/$key/" if defined($key);
	    eval "/$val/" if !$@ && defined($val);
	    $self->{'ERROR'} = $@ if $@;

	    if ($self->{'DEBUG'}) {
		print "QUOTE : $key = $val";
		print ": ", $self->{'ERROR'} if $self->{'ERROR'};
		print "\n";
	    }

	    $self->{'QUOTE'}->{$key} = $val;
	    $key = shift @_;
	}
    }

    return %oldq;
}

sub escape {
    my $self   = shift;
    my $esc    = shift;
    my $curesc = $self->{'ESCAPE'};
    local $_   = "no -w warning in evals now";

    $esc = '[' . quotemeta($esc) . ']' if defined($esc) && ($esc ne "");

    if (defined($esc) && ($esc ne "")) {
	eval "/$esc/";
	$self->{'ERROR'} = $@ if $@;
    }

    $self->{'ESCAPE'} = $esc;

    if ($self->{'DEBUG'}) {
	print "ESCAPE: $esc";
	print ": ", $self->{'ERROR'} if $self->{'ERROR'};
	print "\n";
    }

    return $curesc;
}

sub double_escape {
    my $self   = shift;
    my $esc    = shift;
    my $curesc = $self->{'DBLESCAPE'};
    local $_   = "no -w warning in evals now";

    $esc = '[' . quotemeta($esc) . ']' if defined($esc) && ($esc ne "");

    if (defined($esc) && ($esc ne "")) {
	eval "/$esc/";
	$self->{'ERROR'} = $@ if $@;
    }

    $self->{'DBLESCAPE'} = $esc;

    if ($self->{'DEBUG'}) {
	print "DBLESC: $esc";
	print ": ", $self->{'ERROR'} if $self->{'ERROR'};
	print "\n";
    }

    return $curesc;
}

sub case_sensitive {
    my $self	 = shift;
    my $setsense = shift;
    my $cursense = $self->{'CASESENSE'};

    $self->{'CASESENSE'} = $setsense || !defined($setsense);

    print "CASE	 : ", $self->{'CASESENSE'}, "\n"
	if $self->{'DEBUG'};

    return $cursense;
}

sub slow {
    my $self	 = shift;
    my $setslow	 = shift;
    my $curslow	 = $self->{'FORCESLOW'};

    $self->{'FORCESLOW'} = $setslow || !defined($setslow);

    print "GOSLOW: ", $self->{'FORCESLOW'}, "\n"
	if $self->{'DEBUG'};

    return $curslow;
}

sub keep {
    my $self	 = shift;
    my $setkeep	 = shift;
    my $curkeep	 = $self->{'KEEP'};

    $self->{'KEEP'} = $setkeep || !defined($setkeep);

    print "KEEP	 : ", $self->{'KEEP'}, "\n"
	if $self->{'DEBUG'};

    return $curkeep;
}

sub returndelim {
    my $self	 = shift;
    my $setrd	 = shift;
    my $currd	 = $self->{'RETURNDELIM'};

    $self->{'RETURNDELIM'} = $setrd || !defined($setrd);

    print "RETURNDELIM : ", $self->{'RETURNDELIM'}, "\n"
	if $self->{'DEBUG'};

    return $currd;
}

sub debug {
    my $self	 = shift;
    my $setdebug = shift;
    my $curdebug = $self->{'DEBUG'};

    $self->{'DEBUG'} = $setdebug || !defined($setdebug);

    print "DEBUG : ", $self->{'DEBUG'}, "\n"
	if $self->{'DEBUG'};

    return $curdebug;
}

sub error {
    my $self	 = shift;
    my $seterr	 = shift;
    my $curerr	 = $self->{'ERROR'};

    $self->{'ERROR'} = $seterr if defined($seterr);
    return $curerr;
}

sub pre_matched {
    my $self	 = shift;
    $self->{'ERROR'} = "pre_matched requires keep" if !$self->{'KEEP'};
    return $self->{'PRE'};
}

sub matched {
    my $self	 = shift;
    $self->{'ERROR'} = "matched requires keep" if !$self->{'KEEP'};
    return $self->{'MATCH'};
}

sub post_matched {
    my $self	 = shift;
    $self->{'ERROR'} = "post_matched requires keep" if !$self->{'KEEP'};
    return $self->{'POST'};
}

sub dump {
    my $self	 = shift;
    my ($key, $val);

    print "Dump of Text::DelimMatch:\n";

    print "\n\tERROR : ", $self->{'ERROR'}, "\n"
	if $self->{'ERROR'};

    print "\tStart : ", $self->{'STARTREGEXP'}, "\n";
    print "\tEnd   : ", $self->{'ENDREGEXP'}, "\n";
    print "\tEscape: ", $self->{'ESCAPE'}, "\n";
    print "\tDblEsc: ", $self->{'DBLESCAPE'}, "\n";
    print "\tDebug : ", $self->{'DEBUG'}, "\n";
    print "\tCase  : ", $self->{'CASESENSE'}, "\n";
    print "\tSlow  : ", $self->{'FORCESLOW'}, "\n";
    print "\tKeep  : ", $self->{'KEEP'}, "\n";
    print "\tQuote :\n";
    while (($key, $val) = each %{$self->{'QUOTE'}}) {
	print "\t\t$key ... $val\n";
    }
    print "\tBuffer: ", $self->{'BUFFER'}, "\n";
    print "\tPrefix: ", $self->{'PRE'}, "\n";
    print "\tMatch : ", $self->{'MATCH'}, "\n";
    print "\tPost  : ", $self->{'POST'}, "\n\n";
}

sub match {
    my $self   = shift;
    my $string = shift;
    my $state  = 0;
    my $start  = $self->{'STARTREGEXP'};
    my $end    = $self->{'ENDREGEXP'};
    my %quote  = %{$self->{'QUOTE'}};
    my $escape = $self->{'ESCAPE'};
    my $dblesc = $self->{'DBLESCAPE'};
    my $debug  = $self->{'DEBUG'};
    my ($startq, $endq, $specialq) = ("", "", "");
    my ($done) = 0;
    my ($depth) = 0;
    my (@states) = ();
    my ($accum) = "";
    my ($regexp, $match, $pre, $matched, $post);
    my ($scratch);
    local $_   = "no -w warning in evals now";

    return if $self->{'ERROR'};

    if (defined($string)) {
	$self->{'BUFFER'} = $string;
    } else {
	# use post of previous match, if there was a match previously
	$self->{'BUFFER'} = $self->{'POST'} if $self->{'MATCH'} 
    }

    $self->{'PRE'}    = "";
    $self->{'MATCH'}  = "";
    $self->{'POST'}   = "";

    if (!%quote && !$escape && !$dblesc && !$self->{'FORCESLOW'}) {
	print "FAST: $start, $end\n" if $debug;
	return $self->_fast0() if $start eq $end;
	return $self->_fast1();
    }

    # build the regexp that matches the next important thing

    if (%quote) {
	$startq = join (")|(", keys %quote);
	$startq = "($startq)";
    }

    if ($escape || $dblesc) {
	if ($escape && $dblesc) {
	    $specialq = "($escape)|($dblesc)";
	} elsif ($escape) {
	    $specialq = "($escape)";
	} else {
	    $specialq = "($dblesc)";
	}
    }

    $_ = $self->{'BUFFER'};
    $self->{'BUFFER'} = "";
    while ($state != 3) {
	if ($state == 0) {	     # before start tag
	    $regexp = "($start)";
	    $regexp .= "|$startq" if $startq;
	    $regexp .= "|($escape)" if $escape;
	} elsif ($state == 1) {	     # in start tag
	    $regexp = "($start)|($end)";
	    $regexp .= "|$startq" if $startq;
	    $regexp .= "|($escape)" if $escape;
	} elsif ($state == 2) {	     # in quote
	    $regexp = $endq;
	    $regexp .= "|$specialq" if $specialq;
	} else {
	    $self->{'ERROR'} = "BAD STATE!  THIS CAN'T HAPPEN!";
	    return;
	}

	print "STATE: $state: $regexp\n" if $debug;

	($pre, $matched, $post) = $self->_match($regexp, $_);

	print "\tSTR : $_\n" if $debug;
	print "\tPRE : $pre\n" if $debug;
	print "\tMTCH: $matched\n" if $debug;
	print "\tPOST: $post\n" if $debug;

	last if !$matched;

	# First things first, if we've encountered an escaped
	# character, move along
	if ($escape && $self->_match ($escape, $matched)) {
	    $accum .= $pre . $matched;
	    $accum .= substr($post, 0, 1);
	    $_ = substr ($post, 1);
	    next;
	}

	if ($state == 0) {	     # looking for start or startq
	    if ($self->_match($start, $matched)) { # matched start
		$state = 1;
		$depth++;
		print "START: $depth\n" if $debug;

		$self->{'PRE'} = $accum . $pre;
		$accum = $matched;
		$_ = $post;
	    } else {		     # (must have) matched startq
		push (@states, $state);
		$state = 2;
		$accum .= $pre . $matched;
		foreach $scratch (keys %quote) {
		    if ($self->_match ($scratch, $matched)) {
			$endq = $quote{$scratch};
			last;
		    }
		}
		$_ = $post;
	    }
	} elsif ($state == 1) {
	    if ($self->_match($end, $matched)) { # matched end
		$state = 1;
		$depth--;

		print "END : $depth\n" if $debug;
		$accum .= $pre . $matched;
		if ($depth == 0) {
		    $state = 3;
		    $self->{'MATCH'} = $accum;
		    $self->{'POST'} = $post;
		    $_ = "";
		} else {
		    $_ = $post;
		}
	    } elsif ($self->_match($start, $matched)) { # matched start
		$state = 1;
		$depth++;
		print "START: $depth\n" if $debug;

		$accum .= $pre . $matched;
		$_ = $post;
	    } else {		     # (must have) matched startq
		push (@states, $state);
		$state = 2;
		$accum .= $pre . $matched;
		foreach $scratch (keys %quote) {
		    if ($self->_match ($scratch, $matched)) {
			$endq = $quote{$scratch};
			last;
		    }
		}
		$_ = $post;
	    }
	} elsif ($state == 2) {
	    # case 1, matched dblesc and is a doubled char
	    if ($dblesc 
		&& $self->_match ($dblesc, $matched)
		&& ($matched eq substr($post, 0, 1))) { # skip forward
		$accum .= $pre . $matched;
		$accum .= substr($post, 0, 1);
		$_ = substr($post, 1);
		next;
	    } # otherwise check for other things then revisit
		
	    if ($self->_match ($endq, $matched)) { # matched endq
		$state = pop (@states);
		$accum .= $pre . $matched;
		$_ = $post;
	    } else { # (must have) matched a undoubled dblesc
		     # usually this ends a quoted string
		     # (and we'd never get here)
		     # but since it didn't, just skip along
		$accum .= $pre . $matched;
		$_ = $post;
	    }
	} else {
	    $self->{'ERROR'} = "BAD STATE!  THIS CAN'T HAPPEN!";
	    return;
	}
    }

    if ($state == 3) {
	$pre   = $self->{'PRE'};
	$match = $self->{'MATCH'};
	$post  = $self->{'POST'};

	$match = $self->strip_delim($match) if !$self->{'RETURNDELIM'};
    } else {
	$self->{'PRE'}	 = "";
	$self->{'MATCH'} = "";
	$self->{'POST'}	 = "";
	undef $pre;
	undef $match;
	undef $post;
    }
	
    if (!$self->{'KEEP'}) {
	$self->{'PRE'}	 = "";
	$self->{'MATCH'} = "";
	$self->{'POST'}	 = "";
    }

    return wantarray ? ($pre, $match, $post) : $match;
}

sub _fast0 {
    my $self   = shift;
    my $delim  = $self->{'STARTREGEXP'};
    local $_   = $self->{'BUFFER'};
    my ($pre, $match, $post);

    if ($self->{'CASESENSE'}) {
	$match = /^(.*?)($delim.*?$delim)(.*)$/s;
	($pre, $match, $post) = ($1, $2, $3);
    } else {
	$match = /^(.*?)($delim.*?$delim)(.*)$/si;
	($pre, $match, $post) = ($1, $2, $3);
    }

    if ($match) {
	$match = $self->strip_delim($match) if !$self->{'RETURNDELIM'};

	if ($self->{'KEEP'}) {
	    $self->{'PRE'}   = $pre;
	    $self->{'MATCH'} = $match;
	    $self->{'POST'}  = $post;
	}

	return wantarray ? ($pre, $match, $post) : $match;
    } else {
	return wantarray ? (undef, undef, undef) : undef;
    }
}

sub _fast1 {
    my $self   = shift;
    my $string = $self->{'BUFFER'};
    my $start  = $self->{'STARTREGEXP'};
    my $end    = $self->{'ENDREGEXP'};
    my $regexp = "($start)|($end)";
    my $count  = 0;
    my ($match, $realpre, $pre, $post, $matched);

    ($realpre, $match, $post) = $self->_match($start, $string);

    if (defined($match)) {
	$matched = $match;
	$string	 = $post;
	$count++;

	($pre, $match, $post) = $self->_match($regexp, $string);

	while (defined($match)) {
	    $matched .= $pre . $match;

	    if ($self->_match($end, $match)) {
		$count--;
	    } else {
		$count++;
	    }

	    $string = $post;
	    last if $count == 0;

	    ($pre, $match, $post) = $self->_match($regexp, $string);
	}

	if ($count == 0) {
	    $matched = $self->strip_delim($matched) if !$self->{'RETURNDELIM'};

	    if ($self->{'KEEP'}) {
		$self->{'PRE'}	 = $realpre;
		$self->{'MATCH'} = $matched;
		$self->{'POST'}	 = $post;
	    }
	    
	    return wantarray ? ($realpre, $matched, $post) : $matched;
	}
    }

    return wantarray ? (undef, undef, undef) : undef;
}

sub strip_delim {
    my $self   = shift;
    my $string = shift;
    my $start  = $self->{'STARTREGEXP'};
    my $end    = $self->{'ENDREGEXP'};
    my $ok     = 1;
    local $_   = "no -w warning in evals now";

    return if $self->{'ERROR'};

    $string = $self->{'MATCH'} if !defined($string);

    if ($string =~ /^$start/s) {
	my($rest) = $';
	if ($rest =~ /^(.*)$end$/s) {
	    return $1;
	} else {
	    $self->{'ERROR'} = "FAILED TO MATCH END DELIMITER";
	}
    } else {
	$self->{'ERROR'} = "FAILED TO MATCH START DELIMITER";
    }

    return;
}

sub _match {
    my $self   = shift;
    my $regexp = shift;
    local $_   = shift;
    my $match  = 0;
    my ($pre, $matched, $post);

    if ($self->{'CASESENSE'}) {
	$match = /$regexp/s;
	($pre, $matched, $post) = ($`, $&, $');
    } else {
	$match = /$regexp/si;
	($pre, $matched, $post) = ($`, $&, $');
    }

    if ($match) {
	wantarray ? ($pre, $matched, $post) : $matched;
    } else {
	wantarray ? (undef, undef, undef) : undef;
    }
}

sub nested_match {
    my ($search, $start, $end, $three) = @_;
    my $mc = new Text::DelimMatch $start, $end;
    my ($p, $m, $s) = $mc->match($search);

    if (defined($three)) {
	return wantarray ? ($p, $m, $s) : $m;
    } else {
	return wantarray ? ("$p$m", $s) : $m;
    }
}

sub skip_nested_match {
    my ($search, $start, $end, $three) = @_;
    my $mc = new Text::DelimMatch $start, $end;
    my ($p, $m, $s) = $mc->match($search);

    if (defined($three)) {
	return wantarray ? ($p, $m, $s) : $s;
    } else {
	return wantarray ? ("$p$m", $s) : $s;
    }
}

1;
__END__

=head1 NAME

Text::DelimMatch - Perl extension to find regexp delimited strings with proper nesting

=head1 SYNOPSIS

  use Text::DelimMatch;

  $mc = new Text::DelimMatch, $startdelim, $enddelim;

  $mc->quote('"');
  $mc->escape("\\");
  $mc->double_escape('"');
  $mc->case_sensitive(1);

  ($prefix, $match, $remainder) = $mc->match($string);
  ($prefix, $nextmatch, $remainder) = $mc->match();

  $middle = $mc->strip_delim($match); # returns $match w/o start and end delim

=head1 DESCRIPTION

These routines allow you to match delimited substrings in a
buffer.  The delimiters can be specified with any regular
expression and the start and end delimiters need not be the
same.  If the delimited text is properly nested, entire nested
groups are returned.

In addition, you may specify quoting and escaping characters that
contribute to the recognition of start and end delimiters.

For example, if you specify the start and end delimiters as '\(' and
'\)', respectively, and the double quote character as a quoting character,
and the backslash as an escaping character, then the delimited substring
in this buffer is "(ma(t)c\)h)":

  'prefix text "(quoted text)" \(escaped \" text) (ma(t)c\)h) postfix text'

In order to support this rather complex interface, the matching context
is encapsulated in an object.  The object, Text::DelimMatch,
has the following public methods:

=over 4

=item new $start, $end, $escape, $dblesc, $qs1, $qe1, ... $qsn, $qen

Creates a new object.  All of the arguments are optional, and can be
set with other methods, but they must be passed in the specified order:
start delimiter, end delimiter, escape characters, double escape characters,
and a set of quote characters.

=item match $string

In an array context, returns ($pre, $match, $post) where $pre is the
text preceding the first match, $match is the matched text (including
the delimiters), and $post is the rest of the text in the buffer.
In a scalar context, returns $match.

If $string is not provided on subsequent calls, the $post from the 
previous match is used, unless keep is false.  If keep is false, the
match always fails.

=item strip_delim $string

Returns $string with the start and end delimiters removed.

=item delim $start, $end

Set the start and end delimiters.  Only one set of delimiters can be
in use at any one time.

Returns the delimters in use before this call.

=item quote $startq, $endq

Specifies the start and end quote characters.  Multiple quote
character pairs are supported, so this function is additive.  To
clear the current settings, pass no arguments, e.g.,
$mc->quote().

If only $start is passed, $end is assumed to be the same.

In matching, quotes occur in pairs.  In other words, if (",")
and (',') are both specified as quote pairs and a string
beginning with " is found, it is ended only by another ", not by '.

Returns the quote hash in use before this call.

=item escape $esc

Specifies a set of escaping characters.  This can only be a string
of characters.  $esc can be a regexp set or a simple string.  If it
is a simple string, it will be translated into the regexp set 
"[ quotemeta($esc) ]".

Returns the escape characters in use before this call.

=item double_escape $esc

Specifies a set of double-escaping characters, i.e., characters that
are considered escaped if they occur in pairs.  For example, in some
languages,

  'Don''t you see?'

defines a string containing a single apostrophe.

$esc can only be a string of characters.  $esc can be a regexp
set or a simple string.  If it is a simple string, it will be
translated into the regexp set "[ quotemeta($esc) ]".

Returns the double-escaping characters in use before this call.

=item case_sensitive $bool

Sets case sensitivity to $bool or true if $bool is not specified.

Returns the case sensitivity in use before this call.

=item keep $bool

Sets keep to $bool or true if $bool is not specified.

Keep, which is true by default, specifies whether or not the 
matching context object keeps a local copy of the buffer used in
matching.  Keeping a local copy allows repeated matching on the same
buffer, but might be a bad idea if the buffer is a terabyte long. ;-)

Returns the keep setting in use before this call.

=item returndelim $bool

Sets returndelim to $bool or true if $bool is not specified.

Returndelim, which is true by default, specifies whether or not the 
start and end delimiters are returned with the matching string.

Returns the returndelim setting in use before this call.

=item error $seterr

Returns the last error that occured.  If $seterr is passed, the error is
set to that value.  Some common kinds of bad input are detected and an
error condition is raised.  If an error condition is raised, all matching
fails until the error is cleared.

The most common error is a bad regular expression, for example specifing
the start delimiter as "(" instead of "\\(".  Remember, these are regexps!

=item pre_matched

Returns the prefix text from the last match if keep is true.  Sets
an error and returns an empty string if keep is false.

=item matched

Returns the matched text from the last match if keep is true.  Sets
an error and returns an empty string if keep is false.

=item post_matched

Returns the postfix text from the last match if keep is true.  Sets
an error and returns an empty string if keep is false.

=item debug $bool

Sets debug to $bool or true if $bool is not specified.

If debug is true, informative and progress messages are printed
to STDOUT by some methods.

Returns the debugging setting in use before this call.

=item dump

For debugging, prints all of the instance variables for a particular
object.

=item slow $bool

For debugging.  Some classes of delimited strings can be located
with much faster algorithms than can be used in the most general
case.  If slow is true, the slower, general algorithm is always
used.

=back

For simplicity, and backward compatibility with the previous
(limited release) incarnation of this module, the following 
functions are also available directly:

=over 4

=item nested_match ($string, $start, $end, $three)

If $three is true, returns ($pre, $match, $post) in an array context
otherwise returns ("$pre$match", $post).  In a scalar context, returns
"$pre$match".


=item skip_nested_match ($string, $start, $end, $three)

If $three is true, returns ($pre, $match, $post) in an array context
otherwise returns ("$pre$match", $post).  In a scalar context, returns
$post.

=back

=head1 EXAMPLES

  $mc = new Text::DelimMatch '"';
  $mc->('pre "match" post') == '"match"';

  $mc->delim("\\(", "\\)");
  $mc->('pre (match) post')   == ('pre ', '(match)', ' post');
  $mc->('pre (ma(t)ch) post') == ('pre ', '(ma(t)ch)', ' post');
 
  $mc->quote('"');
  $mc->escape("\\");
  $mc->('pre (ma")"tch) post') == ('pre ', '(ma")"tch)', ' post');
  $mc->('pre (ma(t)c\)h\") post') == ('pre ', '(ma(t)c\)h\")', ' post');

See also test.pl in the distribution.

=head1 AUTHOR

Norman Walsh, ndw@nwalsh.com

=head1 COPYRIGHT

Copyright (C) 1997-2002 Norman Walsh.
All rights reserved.  This program is free software; you can 
redistribute it and/or modify it under the same terms as Perl itself.

=head1 WARRANTY

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
PURPOSE.

=head1 SEE ALSO

perl(1).

=cut