| 1 | #!/usr/bin/env perl | ||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use App::Reg; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | ▶ | use Getopt::Long; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use Pod::Usage; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 4 | ▶ | use Encode; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 4 | ▶ | pod2usage 2 unless GetOptions | ||||||||
|
Branch: 1 branch
| |||||||||||
| 10 | 'help' => \my $help, | ||||||||||
| 11 | 'version' => \my $version, | ||||||||||
| 12 | 'global' => \my $global, | ||||||||||
| 13 | 'no-color' => \my $no_color, | ||||||||||
| 14 | 'ascii' => \my $ascii, | ||||||||||
| 15 | ; | ||||||||||
| 16 | |||||||||||
| 17 | 3 | ▶ | pod2usage 1 if $help; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | |||||||||||
| 19 | 3 | ▶ | if ($version) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 1 | print "$0 version $App::Reg::VERSION\nrunning under Perl $^V\n"; | |||||||||
| 21 | 1 | exit 1; | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 2 | ▶ | pod2usage 2 if @ARGV < 2; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | |||||||||||
| 26 | 2 | ▶ | @ARGV = map { decode 'UTF-8', $_ } @ARGV unless $ascii; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | |||||||||||
| 28 | 2 | my ($str, $regex) = @ARGV; | |||||||||
| 29 | |||||||||||
| 30 | 2 | reg $str, $regex, global => $global, color => !$no_color; | |||||||||
| 31 | |||||||||||
| 32 | =head1 NAME | ||||||||||
| 33 | |||||||||||
| 34 | reg - re 'debug' wrapper | ||||||||||
| 35 | |||||||||||
| 36 | =head1 SYNOPSIS | ||||||||||
| 37 | |||||||||||
| 38 | reg [options] [string] [regex] | ||||||||||
| 39 | |||||||||||
| 40 | Options: | ||||||||||
| 41 | -ascii use ASCII encoding for matching | ||||||||||
| 42 | -global multiple matches | ||||||||||
| 43 | -help brief help message | ||||||||||
| 44 | -no-color disables ansi sequences | ||||||||||
| 45 | -version show version of reg | ||||||||||
| 46 | |||||||||||
| 47 | =head1 OPTIONS | ||||||||||
| 48 | |||||||||||
| 49 | =over 4 | ||||||||||
| 50 | |||||||||||
| 51 | =item B<-ascii> | ||||||||||
| 52 | |||||||||||
| 53 | Uses ASCII encoding for matching. In particular it means that the data | ||||||||||
| 54 | given to this utility is threated as binary data and C<\d> only matches | ||||||||||
| 55 | C<[0-9]>. | ||||||||||
| 56 | |||||||||||
| 57 | =item B<-global> | ||||||||||
| 58 | |||||||||||
| 59 | Assume multiple matches, just like if C</g> modifier in list context | ||||||||||
| 60 | was used on RegExp. | ||||||||||
| 61 | |||||||||||
| 62 | =item B<-help> | ||||||||||
| 63 | |||||||||||
| 64 | Print a brief help message and exits. | ||||||||||
| 65 | |||||||||||
| 66 | =item B<-no-color> | ||||||||||
| 67 | |||||||||||
| 68 | Disables ANSI sequences and enforces the text-only representation of | ||||||||||
| 69 | RegEx debugger. Useful when pasting the output of RegEx debugger. | ||||||||||
| 70 | |||||||||||
| 71 | =item B<-version> | ||||||||||
| 72 | |||||||||||
| 73 | Shows current reg version. | ||||||||||
| 74 | |||||||||||
| 75 | =back | ||||||||||
| 76 | |||||||||||
| 77 | =head1 DESCRIPTION | ||||||||||
| 78 | |||||||||||
| 79 | B<This program> tries to match regex to string and shows Perl regular | ||||||||||
| 80 | expression debugger output. | ||||||||||
| 81 | |||||||||||
| 82 | =head1 AUTHOR | ||||||||||
| 83 | |||||||||||
| 84 | Konrad Borowski <glitchmr@myopera.com> | ||||||||||
| 85 | |||||||||||
| 86 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 87 | |||||||||||
| 88 | This software is copyright (c) 2012 by Konrad Borowski. | ||||||||||
| 89 | |||||||||||
| 90 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 91 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 92 | |||||||||||