blib/lib/Filter/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 blib/lib/Filter/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.02';
8  
9 =head1 NAME
10  
11 Filter::Heredoc::App - The module behind the filter-heredoc command
12  
13 =head1 VERSION
14  
15 Version 0.02
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 sub run_filter_heredoc {
48  
49 0 ▶ my $linestate;
Subroutine run_filter_heredoc: not called CC=56 SCAR=80.7
Pod documented
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 sub _print_help {
363  
364 0 ▶ print <<"END_USAGE";
Subroutine _print_help: not called CC=1 SCAR=6.9
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 sub _print_version {
407  
408 0 ▶ print <<"END_VERSION";
Subroutine _print_version: not called CC=1 SCAR=6.9
409
410 $SCRIPT, version $VERSION
411 Copyright 2011, Bertil Kronlund
412
413 This program is free software; you can redistribute it and/or modify it
414 under the terms of either: the GNU General Public License as published
415 by the Free Software Foundation; or the Artistic License.
416  
417 See http://dev.perl.org/licenses/ for more information.
418
419 THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
420 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
421 WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
422  
423 END_VERSION
424  
425 0 exit(0);
426  
427 }
428  
429 ### INTERNAL UTILITY ###
430 # Usage : _print_rules()
431 # Purpose : print the available syntax rules
432 # Returns : No, dies with exit code 0
433 # Throws : No
434  
435 sub _print_rules {
436 0 ▶ my $EMPTY_STR = q{};
Subroutine _print_rules: not called CC=4 SCAR=30.0
437 0 my $value = shift;
438 0 my %syntax;
439  
440 0 ▶ if ( !defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $value) 0 0 0
441  
442 # Request rule capabilities
443 0 %syntax = hd_syntax();
444  
445 0 print "Available options to use with --syntax option: ";
446 0 foreach ( keys %syntax ) {
447 0 print "'$_' ";
448 0 ▶ if ( $syntax{$_} ne $EMPTY_STR ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($syntax{$_} ne $EMPTY_STR) 0 0 0
449 0 print '(active) ';
450 }
451 }
452  
453 0 print "\n";
454 0 exit(0);
455 }
456  
457 }
458  
459 ### INTERNAL UTILITY ###
460 # Usage : _set_syntax_rules()
461 # Purpose : Sets the syntax rule during this run.
462 # Returns : Normally returns to caller or dies
463 # with exit code 1 on user error.
464 # Throws : No
465  
466 sub _set_syntax_rules {
467 0 ▶ my $EMPTY_STR = q{};
Subroutine _set_syntax_rules: not called CC=5 SCAR=34.0
468 0 my $NONE = q{none};
469 0 my $rule = shift;
470 0 my %syntax;
471  
472 0 ▶ if ( $rule =~ m/^-/xsm ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rule =~ /^-/msx) { } 0 0 0
473 0 print "Invalid --syntax argument option: '$rule'\n";
474 0 exit(1);
475 }
476 else {
477  
478 # Try to set given rule
479 0 $rule = lc($rule); # Ignore case
480 0 %syntax = hd_syntax($rule);
481  
482 # if rule is word 'none' (i.e flush all rules) we are done
483 0 ▶ if ( $rule ne $NONE ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rule ne $NONE) 0 0 0
484  
485 # Was this a non-existent key?
486 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
487 0 print "Invalid syntax rule option: '$rule'. ",
488 "Try option --rules to view all available.\n";
489 0 exit(1);
490 }
491  
492 # Was the change applied
493 elsif ( $syntax{$rule} eq $EMPTY_STR ) {
494 0 print "Sorry, could not add new rule: '$rule'. ",
495 "Try option --rules to view all available.\n";
496 0 exit(1);
497 }
498 }
499  
500 }
501 0 return;
502 }
503  
504 ### INTERNAL UTILITY ###
505 # Usage : _set_match_delimiters ( $delimiters )
506 # Purpose : Populate the global delimiters array with
507 # the delimiters to match. (option --match)
508 # Returns : Normally returns to caller or dies
509 # with exit code 1 on user error.
510 # Throws : No
511  
512 sub _set_match_delimiters {
513 0 ▶ my $EMPTY_STR = q{};
Subroutine _set_match_delimiters: not called CC=3 SCAR=24.8
514 0 my $value = shift;
515  
516 0 ▶ if ( $value eq $EMPTY_STR ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($value eq $EMPTY_STR) { } 0 0 0
elsif ($value =~ /^-/msx) { } 0 0 0
517 0 print "No matching delimiter specified!\n";
518 0 exit(1);
519 }
520 elsif ( $value =~ m/^-/xsm ) {
521 0 print "Invalid --match argument option: '$value'\n";
522 0 exit(1);
523 }
524  
525 # $value contains a comma separated string of delimiters
526 0 chomp $value;
527  
528 # Assign our global array with the delimiters
529 0 @gl_delimiterarray = split( ',', $value );
530  
531 0 return;
532  
533 }
534  
535 ### INTERNAL UTILITY ###
536 # Usage : _print_to_stderr_exit()
537 # Purpose : Print user errors and die.
538 # Returns : No, dies with exit code 1
539 # Throws : No
540  
541 sub _print_to_stderr_exit {
542  
543 0 ▶ my $href_errmsg = shift;
Subroutine _print_to_stderr_exit: not called CC=1 SCAR=6.9
544 0 print STDERR "$$href_errmsg \n";
545 0 exit(1);
546  
547 }
548  
549 ### INTERNAL UTILITY ###
550 # Usage : _is_lone_cli_dash()
551 # Purpose : Test if @ARGV contains the lone dash ('-').
552 # Returns : True (1) if found, otherwise $EMPTY_STR
553 # Throws : No
554  
555 sub _is_lone_cli_dash {
556  
557 0 ▶ my @cmdlinearray = @ARGV;
Subroutine _is_lone_cli_dash: not called CC=5 SCAR=34.0
558 0 my $EMPTY_STR = q{};
559  
560 0 my $regex = qr/(\s*-\s*)/; # try to match '-'
561  
562 0 foreach ( 0 .. $#cmdlinearray ) {
563  
564 0 ▶ if ( $cmdlinearray[$_] =~ $regex ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmdlinearray[$_] =~ /$regex/) 0 0 0
565  
566 # Nothing before and after
567 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
568  
569 # Found the lone dash
570 0 return 1;
571 }
572 }
573 }
574  
575 0 return $EMPTY_STR;
576 }
577  
578 ### INTERNAL UTILITY ###
579 # Usage : _print_all_delimiters( $line, IS_FILEINFO, IS_UNIQUE )
580 # Purpose : Print the delimiters only. Handles options
581 # --list and --list-unique. The 2nd argument
582 # '$is_with_fileinfo' only apply to --list.
583 # Returns : N/A. Normally returns to caller.
584 # Errors : Dies with exit code 2, internal errors in hd_getstate().
585 # Throws : No
586  
587 sub _print_all_delimiters {
588  
589 0 ▶ my ( $line, $is_with_fileinfo, $is_unique_list ) = @_;
Subroutine _print_all_delimiters: not called CC=8 SCAR=42.8
590 0 my $EMPTY_STR = q{};
591 0 my %state;
592  
593 # Read out the default state label symbols
594 0 my %label = hd_labels();
595  
596 ############## If exception exit(2) ########
597 0 eval { %state = hd_getstate($line); };
598 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
599 0 my $logcreated = _write_error_file( $@, _get_error_fname() );
600 0 ▶ if ($logcreated) {
Branch: 1 branch
BranchTrueFalseTotal
if ($logcreated) 0 0 0
601 0 print STDERR "Fatal internal errors, see file:",
602 _get_error_fname(), "\n";
603 }
604 0 exit(2);
605 }
606 ############################################
607  
608 0 ▶ if ( $state{blockdelimiter} ne $EMPTY_STR ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state{"blockdelimiter"} ne $EMPTY_STR) 0 0 0
609  
610 # The delimiter is the terminator on the egress line ('E')
611 0 ▶ if ( $state{statemarker} eq $label{egress} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state{"statemarker"} eq $label{"egress"}) 0 0 0
612  
613 # Option --list-unique
614 0 ▶ if ($is_unique_list) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_unique_list) { } 0 0 0
615  
616 # Add all, will become unique in _print_unique_delimiters()
617 0 push @gl_to_be_unique_delimiters, $state{blockdelimiter};
618 }
619  
620 # Option --list
621 else {
622  
623 # File information not available is pipe or redirect
624 0 ▶ if ( $ARGV =~ m/^-/xsm ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ARGV =~ /^-/msx) 0 0 0
625 0 $is_with_fileinfo = $EMPTY_STR;
626 }
627  
628 # Print the delimiter itself (stored in 'blockdelimiter')
629 0 ▶ if ($is_with_fileinfo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_with_fileinfo) { } 0 0 0
630 0 print "($ARGV:$.)$state{blockdelimiter} \n";
631 }
632 else {
633 0 print "$state{blockdelimiter} \n";
634 }
635 }
636  
637 } # end the last delimiter (at egress)
638  
639 } # end delimiter found in block
640  
641 0 return;
642 }
643  
644 ### INTERNAL UTILITY ###
645 # Usage : _debug_every_line( $line, IS_FILEINFO, IS_ADDLABEL )
646 # Purpose : Print every line for debugging purpose.
647 # Handles option --debug
648 # Returns : N/A. Normally returns to caller.
649 # Errors : Dies with exit code 2, internal errors in hd_getstate().
650 # Throws : No
651  
652 sub _debug_every_line {
653  
654 0 ▶ my ( $line, $is_with_fileinfo, $is_add_label ) = @_;
Subroutine _debug_every_line: not called CC=12 SCAR=50.5
655 0 my $EMPTY_STR = q{};
656 0 my %state;
657  
658 ############## If exception exit(2) ########
659 0 eval { %state = hd_getstate($line); };
660 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
661 0 my $logcreated = _write_error_file( $@, _get_error_fname() );
662 0 ▶ if ($logcreated) {
Branch: 1 branch
BranchTrueFalseTotal
if ($logcreated) 0 0 0
663 0 print STDERR "Fatal internal errors, see file:",
664 _get_error_fname(), "\n";
665 }
666 0 exit(2);
667 }
668 ############################################
669  
670 # File information not available is pipe or redirect
671 0 ▶ if ( $ARGV =~ m/^-/xsm ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ARGV =~ /^-/msx) 0 0 0
672 0 $is_with_fileinfo = $EMPTY_STR;
673 }
674  
675 SWITCH: {
676 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
677 0 print "($ARGV:$.)$state{statemarker}]$line";
678 0 last SWITCH;
679 };
680 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
681 0 print "($ARGV:$.)$line";
682 0 last SWITCH;
683 };
684 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
685 0 print "$state{statemarker}]$line";
686 0 last SWITCH;
687 };
688 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
689 0 print "$line";
690 0 last SWITCH;
691 };
692  
693 }; # switch and combine all variants
694  
695 0 return;
696 }
697  
698 ####################################################
699 # Usage: _print_heredoc();
700 # Purpose: Print (and match lines if set) here document content
701 # Returns: N/A
702 # Parameters: line to analyze, and Getopt boolens
703 # Throws: Yes
704  
705 sub _print_heredoc {
706  
707 0 ▶ my ( $line, $is_with_fileinfo, $is_add_code ) = @_;
Subroutine _print_heredoc: not called CC=24 SCAR=64.0
708 0 my $EMPTY_STR = q{};
709  
710 # Read out the default markers symbols
711 0 my %label = hd_labels();
712 0 my %state;
713  
714 ############## If exception exit(2) ########
715 0 eval { %state = hd_getstate($line); };
716 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
717 0 my $logcreated = _write_error_file( $@, _get_error_fname() );
718 0 ▶ if ($logcreated) {
Branch: 1 branch
BranchTrueFalseTotal
if ($logcreated) 0 0 0
719 0 print STDERR "Fatal internal errors, see file:",
720 _get_error_fname(), "\n";
721 }
722 0 exit(2);
723 }
724 ############################################
725  
726 0 ▶ if ( $state{statemarker} eq $label{heredoc} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state{"statemarker"} eq $label{"heredoc"}) 0 0 0
727  
728 # File information not available is pipe or redirect
729 0 ▶ if ( $ARGV =~ m/^-/xsm ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ARGV =~ /^-/msx) 0 0 0
730 0 $is_with_fileinfo = $EMPTY_STR;
731 }
732  
733 # Print only here document matching the set delimiters
734 0 ▶ if (@gl_delimiterarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (@Filter::Heredoc::App::gl_delimiterarray) { } 0 0 0
735  
736 0 foreach my $lineitem (@gl_delimiterarray) {
737  
738 0 ▶ if ( $state{blockdelimiter} eq $lineitem ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state{"blockdelimiter"} eq $lineitem) 0 0 0
739  
740 0 $gl_is_successful_match = 1; # True
741  
742 SWITCH: {
743 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
744 0 print "($ARGV:$.)$state{statemarker}]$line";
745 0 last SWITCH;
746 };
747 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
748 0 print "($ARGV:$.)$line";
749 0 last SWITCH;
750 };
751 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
752 0 print "$state{statemarker}]$line";
753 0 last SWITCH;
754 };
755 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
756 0 print "$line";
757 0 last SWITCH;
758 };
759  
760 }; # switch and combine all variants
761  
762 } # if match blockdelimiter and item
763  
764 } # end foreach
765  
766 }
767  
768 # Print every line (option --match not used)
769 else {
770  
771 SWITCH: {
772 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
773 0 print "($ARGV:$.)$state{statemarker}]$line";
774 0 last SWITCH;
775 };
776 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
777 0 print "($ARGV:$.)$line";
778 0 last SWITCH;
779 };
780 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
781 0 print "$state{statemarker}]$line";
782 0 last SWITCH;
783 };
784 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
785 0 print "$line";
786 0 last SWITCH;
787 };
788 }; # switch and combine all variants
789 }
790  
791 } # end here document
792  
793 0 return;
794 }
795  
796 ### INTERNAL UTILITY ###
797 # Usage : _is_cli_with_other_than_option()
798 # Purpose : Test if @ARGV contains any other arguments than
799 # than the lonely dash '-'
800 # Returns : True (1) if found, otherwise $EMPTY_STR
801 # Throws : No
802  
803 sub _is_cli_with_other_than_option {
804  
805 0 ▶ my $EMPTY_STR = q{};
Subroutine _is_cli_with_other_than_option: not called CC=3 SCAR=24.8
806 0 my @cmdlinearray = @ARGV;
807  
808 LOOP:
809 0 foreach ( 0 .. $#cmdlinearray ) {
810  
811 0 ▶ if ( $cmdlinearray[$_] =~ m/(-[a-zA-Z])+/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmdlinearray[$_] =~ /(-[a-zA-Z])+/) { } 0 0 0
812 0 next LOOP;
813 }
814 else {
815 0 return 1; # True, found something trailing the '-'
816 }
817 }
818  
819 0 return $EMPTY_STR; # False, only '-' (or empty @ARGV)
820 }
821  
822 ### INTERNAL UTILITY ###
823 # Usage : _print_unique_delimiters()
824 # Purpose : Print only the unique delimiters.
825 # Returns : Normally returns to caller.
826 # Throws : No
827  
828 sub _print_unique_delimiters {
829 0 ▶ my $EMPTY_STR = q{};
Subroutine _print_unique_delimiters: not called CC=3 SCAR=24.8
830 0 my $file = shift;
831 0 my %seen;
832  
833 # Test for option --quiet (i.e. $file is set to $EMPTY_STR)
834 0 ▶ if ( $file ne $EMPTY_STR ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file ne $EMPTY_STR) 0 0 0
835 0 print "($file)";
836 }
837  
838 # Make unique delimiter list from global array of found delimiters
839 0 my @unique = grep { !$seen{$_}++ } @gl_to_be_unique_delimiters;
840  
841 # print the unique list
842 0 foreach my $item (@unique) {
843 0 print "$item ";
844 }
845  
846 0 @gl_to_be_unique_delimiters = ();
847  
848 0 return;
849 }
850  
851 ### INTERNAL UTILITY ###
852 # Usage : _write_error_file( $@, $err_filename )
853 # Purpose : Writes the error message to file in user home directory.
854 # Returns : True if file open ok, false otherwise.
855 # Throws : No
856  
857 sub _write_error_file {
858 0 ▶ my ( $err_str, $log_fname ) = @_;
Subroutine _write_error_file: not called CC=2 SCAR=17.9
859 0 my $EMPTY_STR = q{};
860 0 my $log_fh;
861  
862 0 ▶ open $log_fh, '>>', $log_fname
Branch: 1 branch
BranchTrueFalseTotal
open $log_fh, ">>", $log_fname or return $EMPTY_STR 0 0 0
863 or return $EMPTY_STR;
864  
865 0 print $log_fh "$err_str\n";
866 0 close($log_fh);
867 0 return 1;
868 }
869  
870 ### INTERNAL UTILITY ###
871 # Usage : _get_error_fname()
872 # Purpose : Creates a filename for writing in user home
873 # directory with ISO8601 formated date-time stamp.
874 # Returns : The name of the error file.
875 # Throws : No
876  
877 sub _get_error_fname {
878 0 ▶ my $err_fname = sprintf '%s-%s.error', "$ENV{HOME}/$SCRIPT",
Subroutine _get_error_fname: not called CC=1 SCAR=6.9
879 POSIX::strftime( q!%Y-%m-%d-%H.%M.%SZ!, gmtime );
880 0 return $err_fname;
881 }
882  
883 =head1 SYNOPSIS
884  
885 use 5.010;
886 use Filter::Heredoc::App qw( run_filter_heredoc );
887 run_filter_heredoc();
888
889 =head1 DESCRIPTION
890  
891 This module implements the logic and functions to search and filter
892 here documents in scripts. Support for shell script is more mature than
893 other near compatible languages like Perl. Don't rely on current
894 version code for Perl since it's still in an early development.
895  
896 =head1 SUBROUTINES
897  
898 I<Filter::Heredoc::App> exports following subroutine only on request.
899  
900 run_filter_heredoc # runs the filter-heredoc application code
901
902 =head2 B<run_filter_heredoc>
903  
904 run_filter_heredoc();
905
906 This function is called by I<filter-heredoc> and implements the
907 logic and functions to search and filter here documents from the
908 command line.
909  
910 =head1 ERRORS
911  
912 On user errors dies with exit(1). Exceptions for C<hd_getstate> are
913 trapped and after writing an error file, dies with exit code 2.
914
915 =head1 BUGS AND LIMITATIONS
916  
917 I<Filter::Heredoc::App> understands here documents syntax in *nix
918 shells scripts. Running other script languages will result in an
919 unpredictable output. This is not regarded as a bug.
920  
921 Please report any bugs or feature requests to
922 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Filter-Heredoc> or at
923 C<< <bug-filter-heredoc at rt.cpan.org> >>.
924  
925 =head1 AUTHOR
926  
927 Bertil Kronlund, C<< <bkron at cpan.org> >>
928  
929 =head1 SEE ALSO
930  
931 L<Filter::Heredoc>, L<filter-heredoc>
932  
933 =head1 LICENSE AND COPYRIGHT
934  
935 Copyright 2011-12, Bertil Kronlund
936  
937 This program is free software; you can redistribute it and/or modify it
938 under the terms of either: the GNU General Public License as published
939 by the Free Software Foundation; or the Artistic License.
940  
941 See http://dev.perl.org/licenses/ for more information.
942  
943 =cut
944  
945 1 1; # End of Filter::Heredoc::App
↑ Summary blib/lib/Filter/Heredoc.pm »