Heredoc/App.pm

filter: Statementstmt 11.2% 36 / 319 Branchbran 0.0% 0 / 164 Conditioncond 0.0% 0 / 66 MC/DCmcdc 0.0% 0 / 43 Subroutinesub 40.0% 10 / 25 Podpod 100% 1 / 1 totaltotal 7.6% 47 / 618 CC 115 SCAR 72.5
CC
115
Cov
7%
run_filter_heredoc
3192.0
_print_heredoc
600.0
_debug_every_line
156.0
CRAP 1410.9
↑ Summary Heredoc.pm »
1 package Filter::Heredoc::App;
2  
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.05';
8  
9 =head1 NAME
10  
11 Filter::Heredoc::App - The module behind the filter-heredoc command
12  
13 =head1 VERSION
14  
15 Version 0.05
16  
17 =cut
18  
19 1 ▶use base qw( Exporter );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 our @EXPORT_OK = qw ( run_filter_heredoc );
21  
22 1 ▶use Filter::Heredoc qw( hd_getstate hd_init hd_labels );
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Filter::Heredoc::Rule qw( hd_syntax );
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use File::Basename qw( basename );
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use POSIX qw( strftime );
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 1 our $SCRIPT = basename($0);
30  
31 1 our @gl_delimiterarray = (); # delimiters to match
32 1 our @gl_to_be_unique_delimiters = (); # (to be) unique delimiters
33 1 our $gl_is_successful_match = 0; # successful match flag
34  
35 ### Export_ok subroutines starts here ###
36  
37 ### INTERFACE SUBROUTINE ###
38 # Usage : run_filter_heredoc()
39 # Purpose : This module implements the logic and functions to
40 # search and filter here documents in scripts.
41 # This is the code behind the filter-heredoc command.
42 # Return : Normally returns to caller or dies with exit code 0.
43 # Errors : Dies with exit code 1 on user errors. Dies with exit
44 # code 2 on internal errors in hd_getstate().
45 # Throws : No.
46  
47 0 ▶sub run_filter_heredoc {
Subroutine run_filter_heredoc: not called CC=56 SCAR=80.7
Pod documented
48  
49 0 my $linestate;
50 my %state;
51 0 my $EMPTY_STR = q{};
52 0 my $PROMPT = q{> };
53 0 my $POD = q{pod};
54 0 ▶ my $is_interactive = ( ( -t STDIN ) && ( -t STDOUT ) );
Condition0%0/3
-t STDIN && -t STDOUT
!ll&&!rl&&r
000
MC/DC0%0/2
-t STDIN && -t STDOUT
-t STDIN -t STDOUT
Truth table0%0/3
A && B
A= -t STDINB= -t STDOUT
ABresult
0X0
100
111
55 0 my $is_use_prompt = $EMPTY_STR;
56 0 my $is_with_fileinfo = $EMPTY_STR;
57  
58 0 my %user_warning = (
59 firstexclusive =>
60 q{Options --help(-h), --version(-v) or --rules(-r) can't be specfied at the same time.},
61 exclusive =>
62 q{Options --list(-l), --list-unique(-u), --debug(-d) or '-' can't be specfied at the same time.},
63 delimiters =>
64 q{Options --list(-l), --list-unique(-u) or --match(-m) can't be specfied at the same time.},
65 filename =>
66 q{Missing any file arguments. Type --help for information.},
67 notextfile =>
68 q{Please try again, and limit the files to readable text files.},
69 );
70  
71 # Flush all state arays and activate syntax rule 'pod' as default
72 0 hd_init();
73 0 hd_syntax($POD);
74  
75 # Configure long options handling
76 0 Getopt::Long::Configure("no_auto_abbrev")
77 ; # must spell out full long option
78 0 Getopt::Long::Configure("bundling"); # bundle the short options
79 0 Getopt::Long::Configure("no_ignore_case"); # use correct case
80  
81 ##############################################################
82 # Do some internal checks before @ARGV is shifted by Getopt
83 ##############################################################
84  
85 # Have we the mandatory filename argument on the command line. In
86 # a pipe or redirect, @ARGV is empty, therefore '$is_interactive'.
87 0 ▶ if ( ($is_interactive) && ( $#ARGV == -1 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_interactive and $#ARGV == -1) 0 0 0
Condition0%0/3
$is_interactive and $#ARGV == -1
!ll&&!rl&&r
000
MC/DC0%0/2
$is_interactive and $#ARGV == -1
$is_interactive $#ARGV == -1
Truth table0%0/3
A and B
A= $is_interactiveB= $#ARGV == -1
ABresult
0X0
100
111
88 0 _print_to_stderr_exit( \$user_warning{filename} );
89 }
90  
91 # Test and prepare possible for line-by-line interactive mode.
92 0 $is_use_prompt = _is_lone_cli_dash(@ARGV);
93  
94 ##############################################################
95 # Getopt to decode our command line arguments
96 ##############################################################
97  
98 0 my ($is_help, $is_version, $is_quiet, $is_rules,
99 $is_debug, $is_list, $is_unique
100 ) = ( 0, 0, 0, 0, 0, 0, 0 );
101 0 my ( $syntax, $match ) = ( $EMPTY_STR, $EMPTY_STR );
102  
103 0 my $options_okay = GetOptions(
104 "h|help" => \$is_help,
105 "v|version" => \$is_version,
106 "q|quiet" => \$is_quiet,
107 "d|debug" => \$is_debug,
108 "i|interactive" => \$is_use_prompt,
109 "r|rules" => \$is_rules,
110 "l|list" => \$is_list,
111 "u|list-unique" => \$is_unique,
112 "s|syntax=s" => \$syntax,
113 "m|match=s" => \$match,
114 );
115  
116 ##############################################################
117 # Getopt done.
118 ##############################################################
119  
120 0 ▶ _help() if !$options_okay;
Branch: 1 branch
BranchTrueFalseTotal
unless $options_okay 0 0 0
121  
122 ########################################
123 # Exclusive do-and-exit-options: --version, --help, and --rules
124 0 my $useroptions = 0;
125 0 foreach ( $is_help, $is_version, $is_rules ) {
126 0 ▶ $useroptions++ if $_;
Branch: 1 branch
BranchTrueFalseTotal
if $_ 0 0 0
127 }
128 _print_to_stderr_exit( \$user_warning{firstexclusive} )
129 0 ▶ if ( $useroptions > 1 );
Branch: 1 branch
BranchTrueFalseTotal
if $useroptions > 1 0 0 0
130  
131 ########################################
132 # Execute the do-and-exit options first
133 0 ▶ if ($is_help) {
Branch: 3 branches
BranchTrueFalseTotal
if ($is_help) { } 0 0 0
elsif ($is_version) { } 0 0 0
elsif ($is_rules) { } 0 0 0
134 0 _print_help();
135 }
136 elsif ($is_version) {
137 0 _print_version();
138 }
139 elsif ($is_rules) {
140 0 _print_rules();
141 }
142  
143 ########################################
144 # Populate the global array of target delimiters to match
145 0 ▶ if ($match) {
Branch: 1 branch
BranchTrueFalseTotal
if ($match) 0 0 0
146 0 _set_match_delimiters($match);
147 }
148 ########################################
149 # Exclusive options tests
150 # Test --list, --list-unique, --debug and '-'
151 0 $useroptions = 0;
152 0 foreach ( $is_list, $is_debug, $is_use_prompt, $is_unique ) {
153 0 ▶ $useroptions++ if $_;
Branch: 1 branch
BranchTrueFalseTotal
if $_ 0 0 0
154 }
155 0 ▶ _print_to_stderr_exit( \$user_warning{exclusive} ) if ( $useroptions > 1 );
Branch: 1 branch
BranchTrueFalseTotal
if $useroptions > 1 0 0 0
156  
157 # --list or --list-unique (prints all delimiters)
158 # and --match (use specific delimiter) is mutually exclusive.
159 0 ▶ if ( $is_list || $is_unique ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_list or $is_unique) 0 0 0
Condition0%0/3
$is_list or $is_unique
l!l&&r!l&&!r
000
MC/DC0%0/2
$is_list or $is_unique
$is_list $is_unique
Truth table0%0/3
A or B
A= $is_listB= $is_unique
ABresult
1X1
011
000
160  
161 # Array contains elements, e.g. '--match=eof,eot' is given
162 0 ▶ if ( ( $#gl_delimiterarray >= 0 ) && ($match) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#Filter::Heredoc::App::gl_delimiterarray >= 0 and $match) 0 0 0
Condition0%0/3
$#Filter::Heredoc::App::gl_delimiterarray >= 0 and $match
!ll&&!rl&&r
000
MC/DC0%0/2
$#Filter::Heredoc::App::gl_delimiterarray >= 0 and $match
$#Filter::Heredoc::App::gl_delimiterarray >= 0 $match
Truth table0%0/3
A and B
A= $#Filter::Heredoc::App::gl_delimiterarray >= 0B= $match
ABresult
0X0
100
111
163 0 _print_to_stderr_exit( \$user_warning{delimiters} );
164 }
165 }
166  
167 # Should we switch to interactive mode (here line-by-line input)
168 0 ▶ if ($is_use_prompt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_use_prompt) 0 0 0
169 0 ▶ if ( !$is_interactive ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $is_interactive) { } 0 0 0
170 0 _help();
171 }
172 else {
173 0 print "$SCRIPT: Line by line input - use Ctrl-D to quit\n";
174 0 print $PROMPT;
175 }
176 }
177  
178 # Again! Test that we have the mandatory filename arguments
179 # Getopt have mangled the @ARGV content after removing options.
180 0 ▶ if ( !$is_use_prompt ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_use_prompt) 0 0 0
181 _print_to_stderr_exit( \$user_warning{filename} )
182 0 ▶ if ( $is_interactive && ( $#ARGV == -1 ) );
Branch: 1 branch
BranchTrueFalseTotal
if $is_interactive and $#ARGV == -1 0 0 0
Condition0%0/3
$is_interactive and $#ARGV == -1
!ll&&!rl&&r
000
MC/DC0%0/2
$is_interactive and $#ARGV == -1
$is_interactive $#ARGV == -1
Truth table0%0/3
A and B
A= $is_interactiveB= $#ARGV == -1
ABresult
0X0
100
111
183 }
184  
185 ###########################################################
186 # Before we let <> loose, sanitize the file list in @ARGV.
187 # Only allow text files, and exit if not.
188 ###########################################################
189  
190 # Shell have already expanded '*' in @ARGV to file list
191 0 my @files = @ARGV;
192 0 my @text_files = ();
193  
194 0 ▶ if ( ( $#files != -1 ) && ( !_is_lone_cli_dash(@ARGV) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#files != -1 and not _is_lone_cli_dash(@ARGV)) 0 0 0
Condition0%0/3
$#files != -1 and not _is_lone_cli_dash(@ARGV)
!ll&&!rl&&r
000
MC/DC0%0/2
$#files != -1 and not _is_lone_cli_dash(@ARGV)
$#files != -1 not _is_lone_cli_dash(@ARGV)
Truth table0%0/3
A and not(B)
A= $#files != -1B= not _is_lone_cli_dash(@ARGV)
ABresult
0X0
100
111
195 0 my @no_good_files;
196 0 my $exit_now_flag = 0;
197  
198 0 foreach ( 0 .. $#files ) {
199  
200 0 ▶ if ( !-e $files[$_] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $files[$_]) 0 0 0
201 0 print STDERR
202 "$SCRIPT: cannot access '$files[$_]': Can not access file. Does it exist?\n";
203 0 exit(1);
204 }
205  
206 # exclude directories
207 0 ▶ if ( -d $files[$_] ) {
Branch: 2 branches
BranchTrueFalseTotal
if (-d $files[$_]) { } 0 0 0
elsif (-r -f -T $files[$_]) { } 0 0 0
208 0 next;
209 }
210  
211 # readable by effective user id, plain file, and text
212 elsif ( -r -f -T $files[$_] ) {
213 0 push @text_files, $files[$_];
214 }
215 else {
216 0 $exit_now_flag = 1;
217 0 push @no_good_files, $files[$_];
218 }
219  
220 }
221 0 ▶ if ($exit_now_flag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exit_now_flag) 0 0 0
222  
223 0 ▶ if (@text_files) {
Branch: 1 branch
BranchTrueFalseTotal
if (@text_files) 0 0 0
224 0 print STDERR "$SCRIPT: These may be acceptable text files:\n";
225 0 foreach my $item (@text_files) {
226 0 print STDERR "'$item', ";
227 }
228 0 print STDERR "\n";
229 }
230 0 print STDERR
231 "$SCRIPT: These are not plain text files or are not accessible (maybe links):\n";
232 0 foreach my $item (@no_good_files) {
233 0 print STDERR "'$item', ";
234 }
235 0 print STDERR "\n$SCRIPT: ";
236 0 my $allstderrprintdone = 1;
237  
238 _print_to_stderr_exit( \$user_warning{notextfile} )
239 0 ▶ if ($allstderrprintdone);
Branch: 1 branch
BranchTrueFalseTotal
if $allstderrprintdone 0 0 0
240  
241 } # end exit_now_flag_flag
242 }
243  
244 # Last time test that we have the mandatory filename arguments after
245 # that we mangled the file list @text_files content.
246 0 ▶ if ( !$is_use_prompt ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_use_prompt) 0 0 0
247 _print_to_stderr_exit( \$user_warning{filename} )
248 0 ▶ if ( $is_interactive && ( $#text_files == -1 ) );
Branch: 1 branch
BranchTrueFalseTotal
if $is_interactive and $#text_files == -1 0 0 0
Condition0%0/3
$is_interactive and $#text_files == -1
!ll&&!rl&&r
000
MC/DC0%0/2
$is_interactive and $#text_files == -1
$is_interactive $#text_files == -1
Truth table0%0/3
A and B
A= $is_interactiveB= $#text_files == -1
ABresult
0X0
100
111
249 }
250  
251 ###########################################################
252 # Set our syntax if given any
253 0 ▶ if ($syntax) {
Branch: 1 branch
BranchTrueFalseTotal
if ($syntax) 0 0 0
254 0 _set_syntax_rules($syntax);
255 }
256  
257 ###########################################################
258 # Main loop processing one line after line from STDIN
259 ###########################################################
260 0 ▶ while ( defined( my $line = <ARGV> ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline ARGV)) 0 0 0
261  
262 # print all here-doc delimiters (i.e. '--list' or '--list-unique')
263 0 ▶ if ( ( $is_list || $is_unique ) && ( !$is_use_prompt ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($is_list || $is_unique and not $is_use_prompt) { } 0 0 0
elsif (not $is_use_prompt) { } 0 0 0
Condition0%0/6
$is_list || $is_unique and not $is_use_prompt
!ll&&!rl&&r
000
$is_list or $is_unique
l!l&&r!l&&!r
000
MC/DC0%0/3
$is_list || $is_unique and not $is_use_prompt
$is_list $is_unique not $is_use_prompt
Truth table0%0/5
A or B and not(C)
A= $is_listB= $is_uniqueC= not $is_use_prompt
ABCresult
00X0
1X00
0100
1X11
0111
264  
265 0 ▶ if ( !$is_quiet ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_quiet) 0 0 0
266 0 $is_with_fileinfo = 1; # adds file information
267 }
268 0 _print_all_delimiters( $line, $is_with_fileinfo, $is_unique );
269  
270 }
271  
272 # end --list, --list-unique options (print all here-doc delimiters)
273  
274 elsif ( !$is_use_prompt ) {
275  
276 ### print here-doc content (default without any options)
277 0 my $is_add_label;
278 0 ▶ if ( !$is_quiet ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_quiet) 0 0 0
279 0 $is_with_fileinfo = 1; # file information when printing
280 }
281  
282 # print all lines for debug incl state code (i.e. --debug option)
283 0 ▶ if ($is_debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_debug) { } 0 0 0
284 0 $is_add_label = 1;
285 0 _debug_every_line( $line, $is_with_fileinfo, $is_add_label );
286 }
287  
288 # print only the embedded here document lines (default option)
289 else {
290 0 $is_add_label = $EMPTY_STR;
291 0 _print_heredoc( $line, $is_with_fileinfo, $is_add_label );
292 }
293 ### end print here-doc content
294  
295 }
296  
297 # Inter-active and no cmd line arguments.
298 0 ▶ if ($is_use_prompt) {
Branch: 2 branches
BranchTrueFalseTotal
if ($is_use_prompt) { } 0 0 0
elsif (eof) { } 0 0 0
299  
300 ############## If exception exit(2) ########
301 0 eval { %state = hd_getstate($line); };
302 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
303 0 my $logcreated = _write_error_file( $@, _get_error_fname() );
304 0 ▶ if ($logcreated) {
Branch: 1 branch
BranchTrueFalseTotal
if ($logcreated) 0 0 0
305 0 print STDERR "Fatal internal errors, see file:",
306 _get_error_fname(), "\n";
307 }
308 0 exit(2);
309 }
310 ############################################
311 0 print "$state{statemarker}]$line";
312  
313 0 print $PROMPT; # We can test the script with Test::Expect
314 }
315 elsif (eof) {
316  
317 # --list-unique
318 0 ▶ if ($is_unique) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_unique) 0 0 0
319 0 ▶ if ($is_quiet) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_quiet) { } 0 0 0
320 0 _print_unique_delimiters($EMPTY_STR);
321 }
322 else {
323 0 _print_unique_delimiters($ARGV); # current file name
324 }
325 0 print "\n"; # new line after each file
326 }
327  
328 # --match
329 0 ▶ if ($match) {
Branch: 1 branch
BranchTrueFalseTotal
if ($match) 0 0 0
330 0 ▶ if ( !$gl_is_successful_match ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Filter::Heredoc::App::gl_is_successful_match) 0 0 0
331 0 ▶ print "($ARGV)" unless ($is_quiet);
Branch: 1 branch
BranchTrueFalseTotal
unless $is_quiet 0 0 0
332 0 print
333 "Sorry, no here document content matched your delimiter(s): '$match'. Try --list.\n";
334 }
335  
336 0 $gl_is_successful_match = $EMPTY_STR; # False
337 }
338  
339  
340 0 close(ARGV);
341 0 hd_init()
342 ; # re-init state explicitely to flush state possible errors
343 }
344  
345 # end inter-active and no cmd line arguments
346  
347 }
348  
349 0 print "\n"; # print one LF before returning to caller script and exit.
350 0 return;
351  
352 }
353  
354 ### The Module private subroutines starts here ###
355  
356 ### INTERNAL UTILITY ###
357 # Usage : _print_help()
358 # Purpose : Print command line help
359 # Returns : No, dies with exit code 0
360 # Throws : No
361  
362 0 ▶sub _print_help {
Subroutine _print_help: not called CC=1 SCAR=6.9
363  
364 0 print <<"END_USAGE";
365
366 $SCRIPT: Filter embedded here-documents in scripts
367
368 Usage:
369  
370 $SCRIPT [options] file
371 $SCRIPT [options] < file
372 cat file | $SCRIPT [options] | program
373  
374 file: Source script file with embedded here-documents
375 program: Program to receive input from $SCRIPT output
376  
377 Options
378  
379 --list,-l : list all delimiters and exit.
380 --list-unique,-u : list only unique delimiters and exit.
381 --match=,-m <delimiter> : print only here-documents matching the delimiters.
382 --quiet,-q : supress file information.
383  
384 --rules,-r : list available rules and exit.
385 --syntax=,-s <rule> : add specified rule(s).
386
387 --help,-h : show this help and exit.
388 --version,-v : print $SCRIPT version information and exit.
389 --debug,-d : print all script lines, not only here-document lines.
390 --interactive,-i|- : enter text line-by-line (for state debugging).
391
392 Type 'perldoc $SCRIPT' for more information.
393
394 END_USAGE
395  
396 0 exit(0);
397  
398 }
399  
400 ### INTERNAL UTILITY ###
401 # Usage : _print_version()
402 # Purpose : Print version, copyright and disclaimer
403 # Returns : No, dies with exit code 0
404 # Throws : No
405  
406 0 ▶sub _print_version {
Subroutine _print_version: not called CC=1 SCAR=6.9
407  
408 0 print <<"END_VERSION";
409 $SCRIPT, version $VERSION
410 Copyright 2011-2018, Bertil Kronlund
411
412 This program is free software; you can redistribute it and/or modify it
413 under the terms of either: the GNU General Public License as published
414 by the Free Software Foundation; or the Artistic License.
415  
416 See http://dev.perl.org/licenses/ for more information.
417
418 THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
419 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
420 WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
421  
422 END_VERSION
423  
424 0 exit(0);
425  
426 }
427  
428 ### INTERNAL UTILITY ###
429 # Usage : _print_rules()
430 # Purpose : print the available syntax rules
431 # Returns : No, dies with exit code 0
432 # Throws : No
433  
434 0 ▶sub _print_rules {
Subroutine _print_rules: not called CC=4 SCAR=30.0
435 0 my $EMPTY_STR = q{};
436 0 my $value = shift;
437 0 my %syntax;
438  
439 0 ▶ if ( !defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $value) 0 0 0
440  
441 # Request rule capabilities
442 0 %syntax = hd_syntax();
443  
444 0 print "Available options to use with --syntax option: ";
445 0 foreach ( keys %syntax ) {
446 0 print "'$_' ";
447 0 ▶ if ( $syntax{$_} ne $EMPTY_STR ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($syntax{$_} ne $EMPTY_STR) 0 0 0
448 0 print '(active) ';
449 }
450 }
451  
452 0 print "\n";
453 0 exit(0);
454 }
455  
456 }
457  
458 ### INTERNAL UTILITY ###
459 # Usage : _set_syntax_rules()
460 # Purpose : Sets the syntax rule during this run.
461 # Returns : Normally returns to caller or dies
462 # with exit code 1 on user error.
463 # Throws : No
464  
465 0 ▶sub _set_syntax_rules {
Subroutine _set_syntax_rules: not called CC=5 SCAR=34.0
466 0 my $EMPTY_STR = q{};
467 0 my $NONE = q{none};
468 0 my $rule = shift;
469 0 my %syntax;
470  
471 0 ▶ if ( $rule =~ m/^-/xsm ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rule =~ /^-/msx) { } 0 0 0
472 0 print "Invalid --syntax argument option: '$rule'\n";
473 0 exit(1);
474 }
475 else {
476  
477 # Try to set given rule
478 0 $rule = lc($rule); # Ignore case
479 0 %syntax = hd_syntax($rule);
480  
481 # if rule is word 'none' (i.e flush all rules) we are done
482 0 ▶ if ( $rule ne $NONE ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rule ne $NONE) 0 0 0
483  
484 # Was this a non-existent key?
485 0 ▶ if ( !exists $syntax{$rule} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $syntax{$rule}) { } 0 0 0
elsif ($syntax{$rule} eq $EMPTY_STR) { } 0 0 0
486 0 print "Invalid syntax rule option: '$rule'. ",
487 "Try option --rules to view all available.\n";
488 0 exit(1);
489 }
490  
491 # Was the change applied
492 elsif ( $syntax{$rule} eq $EMPTY_STR ) {
493 0 print "Sorry, could not add new rule: '$rule'. ",
494 "Try option --rules to view all available.\n";
495 0 exit(1);
496 }
497 }
498  
499 }
500 0 return;
501 }
502  
503 ### INTERNAL UTILITY ###
504 # Usage : _set_match_delimiters ( $delimiters )
505 # Purpose : Populate the global delimiters array with
506 # the delimiters to match. (option --match)
507 # Returns : Normally returns to caller or dies
508 # with exit code 1 on user error.
509 # Throws : No
510  
511 0 ▶sub _set_match_delimiters {
Subroutine _set_match_delimiters: not called CC=3 SCAR=24.8
512 0 my $EMPTY_STR = q{};
513 0 my $value = shift;
514  
515 0 ▶ if ( $value eq $EMPTY_STR ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($value eq $EMPTY_STR) { } 0 0 0
elsif ($value =~ /^-/msx) { } 0 0 0
516 0 print "No matching delimiter specified!\n";
517 0 exit(1);
518 }
519 elsif ( $value =~ m/^-/xsm ) {
520 0 print "Invalid --match argument option: '$value'\n";
521 0 exit(1);
522 }
523  
524 # $value contains a comma separated string of delimiters
525 0 chomp $value;
526  
527 # Assign our global array with the delimiters
528 0 @gl_delimiterarray = split( ',', $value );
529  
530 0 return;
531  
532 }
533  
534 ### INTERNAL UTILITY ###
535 # Usage : _print_to_stderr_exit()
536 # Purpose : Print user errors and die.
537 # Returns : No, dies with exit code 1
538 # Throws : No
539  
540 0 ▶sub _print_to_stderr_exit {
Subroutine _print_to_stderr_exit: not called CC=1 SCAR=6.9
541  
542 0 my $href_errmsg = shift;
543 0 print STDERR "$$href_errmsg \n";
544 0 exit(1);
545  
546 }
547  
548 ### INTERNAL UTILITY ###
549 # Usage : _is_lone_cli_dash()
550 # Purpose : Test if @ARGV contains the lone dash ('-').
551 # Returns : True (1) if found, otherwise $EMPTY_STR
552 # Throws : No
553  
554 0 ▶sub _is_lone_cli_dash {
Subroutine _is_lone_cli_dash: not called CC=5 SCAR=34.0
555  
556 0 my @cmdlinearray = @ARGV;
557 0 my $EMPTY_STR = q{};
558  
559 0 my $regex = qr/(\s*-\s*)/; # try to match '-'
560  
561 0 foreach ( 0 .. $#cmdlinearray ) {
562  
563 0 ▶ if ( $cmdlinearray[$_] =~ $regex ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmdlinearray[$_] =~ /$regex/) 0 0 0
564  
565 # Nothing before and after
566 0 ▶ if ( ( $` eq $EMPTY_STR ) && ( $' eq $EMPTY_STR ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($` eq $EMPTY_STR and $' eq $EMPTY_STR) 0 0 0
Condition0%0/3
$` eq $EMPTY_STR and $' eq $EMPTY_STR
!ll&&!rl&&r
000
MC/DC0%0/2
$` eq $EMPTY_STR and $' eq $EMPTY_STR
$` eq $EMPTY_STR $' eq $EMPTY_STR
Truth table0%0/3
A and B
A= $` eq $EMPTY_STRB= $' eq $EMPTY_STR
ABresult
0X0
100
111
567  
568 # Found the lone dash
569 0 return 1;
570 }
571 }
572 }
573  
574 0 return $EMPTY_STR;
575 }
576  
577 ### INTERNAL UTILITY ###
578 # Usage : _print_all_delimiters( $line, IS_FILEINFO, IS_UNIQUE )
579 # Purpose : Print the delimiters only. Handles options
580 # --list and --list-unique. The 2nd argument
581 # '$is_with_fileinfo' only apply to --list.
582 # Returns : N/A. Normally returns to caller.
583 # Errors : Dies with exit code 2, internal errors in hd_getstate().
584 # Throws : No
585  
586 0 ▶sub _print_all_delimiters {
Subroutine _print_all_delimiters: not called CC=8 SCAR=42.8
587  
588 0 my ( $line, $is_with_fileinfo, $is_unique_list ) = @_;
589 0 my $EMPTY_STR = q{};
590 0 my %state;
591  
592 # Read out the default state label symbols
593 0 my %label = hd_labels();
594  
595 ############## If exception exit(2) ########
596 0 eval { %state = hd_getstate($line); };
597 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
598 0 my $logcreated = _write_error_file( $@, _get_error_fname() );
599 0 ▶ if ($logcreated) {
Branch: 1 branch
BranchTrueFalseTotal
if ($logcreated) 0 0 0
600 0 print STDERR "Fatal internal errors, see file:",
601 _get_error_fname(), "\n";
602 }
603 0 exit(2);
604 }
605 ############################################
606  
607 0 ▶ if ( $state{blockdelimiter} ne $EMPTY_STR ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state{"blockdelimiter"} ne $EMPTY_STR) 0 0 0
608  
609 # The delimiter is the terminator on the egress line ('E')
610 0 ▶ if ( $state{statemarker} eq $label{egress} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state{"statemarker"} eq $label{"egress"}) 0 0 0
611  
612 # Option --list-unique
613 0 ▶ if ($is_unique_list) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_unique_list) { } 0 0 0
614  
615 # Add all, will become unique in _print_unique_delimiters()
616 0 push @gl_to_be_unique_delimiters, $state{blockdelimiter};
617 }
618  
619 # Option --list
620 else {
621  
622 # File information not available is pipe or redirect
623 0 ▶ if ( $ARGV =~ m/^-/xsm ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ARGV =~ /^-/msx) 0 0 0
624 0 $is_with_fileinfo = $EMPTY_STR;
625 }
626  
627 # Print the delimiter itself (stored in 'blockdelimiter')
628 0 ▶ if ($is_with_fileinfo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_with_fileinfo) { } 0 0 0
629 0 print "($ARGV:$.)$state{blockdelimiter} \n";
630 }
631 else {
632 0 print "$state{blockdelimiter} \n";
633 }
634 }
635  
636 } # end the last delimiter (at egress)
637  
638 } # end delimiter found in block
639  
640 0 return;
641 }
642  
643 ### INTERNAL UTILITY ###
644 # Usage : _debug_every_line( $line, IS_FILEINFO, IS_ADDLABEL )
645 # Purpose : Print every line for debugging purpose.
646 # Handles option --debug
647 # Returns : N/A. Normally returns to caller.
648 # Errors : Dies with exit code 2, internal errors in hd_getstate().
649 # Throws : No
650  
651 0 ▶sub _debug_every_line {
Subroutine _debug_every_line: not called CC=12 SCAR=50.5
652  
653 0 my ( $line, $is_with_fileinfo, $is_add_label ) = @_;
654 0 my $EMPTY_STR = q{};
655 0 my %state;
656  
657 ############## If exception exit(2) ########
658 0 eval { %state = hd_getstate($line); };
659 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
660 0 my $logcreated = _write_error_file( $@, _get_error_fname() );
661 0 ▶ if ($logcreated) {
Branch: 1 branch
BranchTrueFalseTotal
if ($logcreated) 0 0 0
662 0 print STDERR "Fatal internal errors, see file:",
663 _get_error_fname(), "\n";
664 }
665 0 exit(2);
666 }
667 ############################################
668  
669 # File information not available is pipe or redirect
670 0 ▶ if ( $ARGV =~ m/^-/xsm ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ARGV =~ /^-/msx) 0 0 0
671 0 $is_with_fileinfo = $EMPTY_STR;
672 }
673  
674 SWITCH: {
675 0 ▶ ( $is_add_label && $is_with_fileinfo ) and do {
Branch: 1 branch
BranchTrueFalseTotal
$is_add_label and $is_with_fileinfo and do { print qq((${ARGV}:$.)$state{"statemarker"}]$line); last SWITCH } 0 0 0
Condition0%0/3
$is_add_label and $is_with_fileinfo
!ll&&!rl&&r
000
MC/DC0%0/2
$is_add_label and $is_with_fileinfo
$is_add_label $is_with_fileinfo
Truth table0%0/3
A and B
A= $is_add_labelB= $is_with_fileinfo
ABresult
0X0
100
111
676 0 print "($ARGV:$.)$state{statemarker}]$line";
677 0 last SWITCH;
678 };
679 0 ▶ ( !$is_add_label && $is_with_fileinfo ) and do {
Branch: 1 branch
BranchTrueFalseTotal
not $is_add_label and $is_with_fileinfo and do { print "(${ARGV}:$.)$line"; last SWITCH } 0 0 0
Condition0%0/3
not $is_add_label and $is_with_fileinfo
!ll&&!rl&&r
000
MC/DC0%0/2
not $is_add_label and $is_with_fileinfo
not $is_add_label $is_with_fileinfo
Truth table0%0/3
not(A) and B
A= not $is_add_labelB= $is_with_fileinfo
ABresult
0X0
100
111
680 0 print "($ARGV:$.)$line";
681 0 last SWITCH;
682 };
683 0 ▶ ( $is_add_label && !$is_with_fileinfo ) and do {
Branch: 1 branch
BranchTrueFalseTotal
$is_add_label and not $is_with_fileinfo and do { print qq($state{"statemarker"}]$line); last SWITCH } 0 0 0
Condition0%0/3
$is_add_label and not $is_with_fileinfo
!ll&&!rl&&r
000
MC/DC0%0/2
$is_add_label and not $is_with_fileinfo
$is_add_label not $is_with_fileinfo
Truth table0%0/3
A and not(B)
A= $is_add_labelB= not $is_with_fileinfo
ABresult
0X0
100
111
684 0 print "$state{statemarker}]$line";
685 0 last SWITCH;
686 };
687 0 ▶ ( !$is_add_label && !$is_with_fileinfo ) and do {
Branch: 1 branch
BranchTrueFalseTotal
$is_add_label or $is_with_fileinfo or do { print "$line"; last SWITCH } 0 0 0
Condition0%0/3
$is_add_label or $is_with_fileinfo
l!l&&r!l&&!r
000
MC/DC0%0/2
$is_add_label or $is_with_fileinfo
$is_add_label $is_with_fileinfo
Truth table0%0/3
A or B
A= $is_add_labelB= $is_with_fileinfo
ABresult
1X1
011
000
688 0 print "$line";
689 0 last SWITCH;
690 };
691  
692 }; # switch and combine all variants
693  
694 0 return;
695 }
696  
697 ####################################################
698 # Usage: _print_heredoc();
699 # Purpose: Print (and match lines if set) here document content
700 # Returns: N/A
701 # Parameters: line to analyze, and Getopt boolens
702 # Throws: Yes
703  
704 0 ▶sub _print_heredoc {
Subroutine _print_heredoc: not called CC=24 SCAR=64.0
705  
706 0 my ( $line, $is_with_fileinfo, $is_add_code ) = @_;
707 0 my $EMPTY_STR = q{};
708  
709 # Read out the default markers symbols
710 0 my %label = hd_labels();
711 0 my %state;
712  
713 ############## If exception exit(2) ########
714 0 eval { %state = hd_getstate($line); };
715 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
716 0 my $logcreated = _write_error_file( $@, _get_error_fname() );
717 0 ▶ if ($logcreated) {
Branch: 1 branch
BranchTrueFalseTotal
if ($logcreated) 0 0 0
718 0 print STDERR "Fatal internal errors, see file:",
719 _get_error_fname(), "\n";
720 }
721 0 exit(2);
722 }
723 ############################################
724  
725 0 ▶ if ( $state{statemarker} eq $label{heredoc} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state{"statemarker"} eq $label{"heredoc"}) 0 0 0
726  
727 # File information not available is pipe or redirect
728 0 ▶ if ( $ARGV =~ m/^-/xsm ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ARGV =~ /^-/msx) 0 0 0
729 0 $is_with_fileinfo = $EMPTY_STR;
730 }
731  
732 # Print only here document matching the set delimiters
733 0 ▶ if (@gl_delimiterarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@Filter::Heredoc::App::gl_delimiterarray) { } 0 0 0
734  
735 0 foreach my $lineitem (@gl_delimiterarray) {
736  
737 0 ▶ if ( $state{blockdelimiter} eq $lineitem ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state{"blockdelimiter"} eq $lineitem) 0 0 0
738  
739 0 $gl_is_successful_match = 1; # True
740  
741 SWITCH: {
742 0 ▶ ( $is_add_code && $is_with_fileinfo ) and do {
Branch: 1 branch
BranchTrueFalseTotal
$is_add_code and $is_with_fileinfo and do { print qq((${ARGV}:$.)$state{"statemarker"}]$line); last SWITCH } 0 0 0
Condition0%0/3
$is_add_code and $is_with_fileinfo
!ll&&!rl&&r
000
MC/DC0%0/2
$is_add_code and $is_with_fileinfo
$is_add_code $is_with_fileinfo
Truth table0%0/3
A and B
A= $is_add_codeB= $is_with_fileinfo
ABresult
0X0
100
111
743 0 print "($ARGV:$.)$state{statemarker}]$line";
744 0 last SWITCH;
745 };
746 0 ▶ ( !$is_add_code && $is_with_fileinfo ) and do {
Branch: 1 branch
BranchTrueFalseTotal
not $is_add_code and $is_with_fileinfo and do { print "(${ARGV}:$.)$line"; last SWITCH } 0 0 0
Condition0%0/3
not $is_add_code and $is_with_fileinfo
!ll&&!rl&&r
000
MC/DC0%0/2
not $is_add_code and $is_with_fileinfo
not $is_add_code $is_with_fileinfo
Truth table0%0/3
not(A) and B
A= not $is_add_codeB= $is_with_fileinfo
ABresult
0X0
100
111
747 0 print "($ARGV:$.)$line";
748 0 last SWITCH;
749 };
750 0 ▶ ( $is_add_code && !$is_with_fileinfo ) and do {
Branch: 1 branch
BranchTrueFalseTotal
$is_add_code and not $is_with_fileinfo and do { print qq($state{"statemarker"}]$line); last SWITCH } 0 0 0
Condition0%0/3
$is_add_code and not $is_with_fileinfo
!ll&&!rl&&r
000
MC/DC0%0/2
$is_add_code and not $is_with_fileinfo
$is_add_code not $is_with_fileinfo
Truth table0%0/3
A and not(B)
A= $is_add_codeB= not $is_with_fileinfo
ABresult
0X0
100
111
751 0 print "$state{statemarker}]$line";
752 0 last SWITCH;
753 };
754 0 ▶ ( !$is_add_code && !$is_with_fileinfo ) and do {
Branch: 1 branch
BranchTrueFalseTotal
$is_add_code or $is_with_fileinfo or do { print "$line"; last SWITCH } 0 0 0
Condition0%0/3
$is_add_code or $is_with_fileinfo
l!l&&r!l&&!r
000
MC/DC0%0/2
$is_add_code or $is_with_fileinfo
$is_add_code $is_with_fileinfo
Truth table0%0/3
A or B
A= $is_add_codeB= $is_with_fileinfo
ABresult
1X1
011
000
755 0 print "$line";
756 0 last SWITCH;
757 };
758  
759 }; # switch and combine all variants
760  
761 } # if match blockdelimiter and item
762  
763 } # end foreach
764  
765 }
766  
767 # Print every line (option --match not used)
768 else {
769  
770 SWITCH: {
771 0 ▶ ( $is_add_code && $is_with_fileinfo ) and do {
Branch: 1 branch
BranchTrueFalseTotal
$is_add_code and $is_with_fileinfo and do { print qq((${ARGV}:$.)$state{"statemarker"}]$line); last SWITCH } 0 0 0
Condition0%0/3
$is_add_code and $is_with_fileinfo
!ll&&!rl&&r
000
MC/DC0%0/2
$is_add_code and $is_with_fileinfo
$is_add_code $is_with_fileinfo
Truth table0%0/3
A and B
A= $is_add_codeB= $is_with_fileinfo
ABresult
0X0
100
111
772 0 print "($ARGV:$.)$state{statemarker}]$line";
773 0 last SWITCH;
774 };
775 0 ▶ ( !$is_add_code && $is_with_fileinfo ) and do {
Branch: 1 branch
BranchTrueFalseTotal
not $is_add_code and $is_with_fileinfo and do { print "(${ARGV}:$.)$line"; last SWITCH } 0 0 0
Condition0%0/3
not $is_add_code and $is_with_fileinfo
!ll&&!rl&&r
000
MC/DC0%0/2
not $is_add_code and $is_with_fileinfo
not $is_add_code $is_with_fileinfo
Truth table0%0/3
not(A) and B
A= not $is_add_codeB= $is_with_fileinfo
ABresult
0X0
100
111
776 0 print "($ARGV:$.)$line";
777 0 last SWITCH;
778 };
779 0 ▶ ( $is_add_code && !$is_with_fileinfo ) and do {
Branch: 1 branch
BranchTrueFalseTotal
$is_add_code and not $is_with_fileinfo and do { print qq($state{"statemarker"}]$line); last SWITCH } 0 0 0
Condition0%0/3
$is_add_code and not $is_with_fileinfo
!ll&&!rl&&r
000
MC/DC0%0/2
$is_add_code and not $is_with_fileinfo
$is_add_code not $is_with_fileinfo
Truth table0%0/3
A and not(B)
A= $is_add_codeB= not $is_with_fileinfo
ABresult
0X0
100
111
780 0 print "$state{statemarker}]$line";
781 0 last SWITCH;
782 };
783 0 ▶ ( !$is_add_code && !$is_with_fileinfo ) and do {
Branch: 1 branch
BranchTrueFalseTotal
$is_add_code or $is_with_fileinfo or do { print "$line"; last SWITCH } 0 0 0
Condition0%0/3
$is_add_code or $is_with_fileinfo
l!l&&r!l&&!r
000
MC/DC0%0/2
$is_add_code or $is_with_fileinfo
$is_add_code $is_with_fileinfo
Truth table0%0/3
A or B
A= $is_add_codeB= $is_with_fileinfo
ABresult
1X1
011
000
784 0 print "$line";
785 0 last SWITCH;
786 };
787 }; # switch and combine all variants
788 }
789  
790 } # end here document
791  
792 0 return;
793 }
794  
795 ### INTERNAL UTILITY ###
796 # Usage : _is_cli_with_other_than_option()
797 # Purpose : Test if @ARGV contains any other arguments than
798 # than the lonely dash '-'
799 # Returns : True (1) if found, otherwise $EMPTY_STR
800 # Throws : No
801  
802 0 ▶sub _is_cli_with_other_than_option {
Subroutine _is_cli_with_other_than_option: not called CC=3 SCAR=24.8
803  
804 0 my $EMPTY_STR = q{};
805 0 my @cmdlinearray = @ARGV;
806  
807 LOOP:
808 0 foreach ( 0 .. $#cmdlinearray ) {
809  
810 0 ▶ if ( $cmdlinearray[$_] =~ m/(-[a-zA-Z])+/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmdlinearray[$_] =~ /(-[a-zA-Z])+/) { } 0 0 0
811 0 next LOOP;
812 }
813 else {
814 0 return 1; # True, found something trailing the '-'
815 }
816 }
817  
818 0 return $EMPTY_STR; # False, only '-' (or empty @ARGV)
819 }
820  
821 ### INTERNAL UTILITY ###
822 # Usage : _print_unique_delimiters()
823 # Purpose : Print only the unique delimiters.
824 # Returns : Normally returns to caller.
825 # Throws : No
826  
827 0 ▶sub _print_unique_delimiters {
Subroutine _print_unique_delimiters: not called CC=3 SCAR=24.8
828 0 my $EMPTY_STR = q{};
829 0 my $file = shift;
830 0 my %seen;
831  
832 # Test for option --quiet (i.e. $file is set to $EMPTY_STR)
833 0 ▶ if ( $file ne $EMPTY_STR ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file ne $EMPTY_STR) 0 0 0
834 0 print "($file)";
835 }
836  
837 # Make unique delimiter list from global array of found delimiters
838 0 my @unique = grep { !$seen{$_}++ } @gl_to_be_unique_delimiters;
839  
840 # print the unique list
841 0 foreach my $item (@unique) {
842 0 print "$item ";
843 }
844  
845 0 @gl_to_be_unique_delimiters = ();
846  
847 0 return;
848 }
849  
850 ### INTERNAL UTILITY ###
851 # Usage : _write_error_file( $@, $err_filename )
852 # Purpose : Writes the error message to file in user home directory.
853 # Returns : True if file open ok, false otherwise.
854 # Throws : No
855  
856 0 ▶sub _write_error_file {
Subroutine _write_error_file: not called CC=2 SCAR=17.9
857 0 my ( $err_str, $log_fname ) = @_;
858 0 my $EMPTY_STR = q{};
859 0 my $log_fh;
860  
861 0 ▶ open $log_fh, '>>', $log_fname
Branch: 1 branch
BranchTrueFalseTotal
open $log_fh, ">>", $log_fname or return $EMPTY_STR 0 0 0
862 or return $EMPTY_STR;
863  
864 0 print $log_fh "$err_str\n";
865 0 close($log_fh);
866 0 return 1;
867 }
868  
869 ### INTERNAL UTILITY ###
870 # Usage : _get_error_fname()
871 # Purpose : Creates a filename for writing in user home
872 # directory with ISO8601 formated date-time stamp.
873 # Returns : The name of the error file.
874 # Throws : No
875  
876 0 ▶sub _get_error_fname {
Subroutine _get_error_fname: not called CC=1 SCAR=6.9
877 0 my $err_fname = sprintf '%s-%s.error', "$ENV{HOME}/$SCRIPT",
878 POSIX::strftime( q!%Y-%m-%d-%H.%M.%SZ!, gmtime );
879 0 return $err_fname;
880 }
881  
882 =head1 SYNOPSIS
883  
884 use 5.010;
885 use Filter::Heredoc::App qw( run_filter_heredoc );
886 run_filter_heredoc();
887
888 =head1 DESCRIPTION
889  
890 This module implements the logic and functions to search and filter
891 here documents in scripts. Support for shell script is more mature than
892 other near compatible languages like Perl. Don't rely on current
893 version code for Perl since it's still in an early development.
894  
895 =head1 SUBROUTINES
896  
897 I<Filter::Heredoc::App> exports following subroutine only on request.
898  
899 run_filter_heredoc # runs the filter-heredoc application code
900
901 =head2 B<run_filter_heredoc>
902  
903 run_filter_heredoc();
904
905 This function is called by I<filter-heredoc> and implements the
906 logic and functions to search and filter here documents from the
907 command line.
908  
909 =head1 ERRORS
910  
911 On user errors dies with exit(1). Exceptions for C<hd_getstate> are
912 trapped and after writing an error file, dies with exit code 2.
913
914 =head1 BUGS AND LIMITATIONS
915  
916 I<Filter::Heredoc::App> understands here documents syntax in *nix
917 shells scripts. Running other script languages will result in an
918 unpredictable output. This is not regarded as a bug.
919  
920 Please report any bugs or feature requests to
921 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Filter-Heredoc> or at
922 C<< <bug-filter-heredoc at rt.cpan.org> >>.
923  
924 =head1 AUTHOR
925  
926 Bertil Kronlund, C<< <bkron at cpan.org> >>
927  
928 =head1 SEE ALSO
929  
930 L<Filter::Heredoc>, L<filter-heredoc>
931  
932 =head1 LICENSE AND COPYRIGHT
933  
934 Copyright 2011-18, Bertil Kronlund
935  
936 This program is free software; you can redistribute it and/or modify it
937 under the terms of either: the GNU General Public License as published
938 by the Free Software Foundation; or the Artistic License.
939  
940 See http://dev.perl.org/licenses/ for more information.
941  
942 =cut
943  
944 1 1; # End of Filter::Heredoc::App
↑ Summary Heredoc.pm »