| 1 | #!/usr/local/bin/perl | ||||||||||||||||||||||||||||||||
| 2 | # -*- cperl -*- | ||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use HTML::FromText; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | # PODNAME: text2html | ||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: convert plain text to HTML | ||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 1 | my %options, @files; | |||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 1 | my $options_done = 0; | |||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | while ( $_ = shift @ARGV ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | if ( /^--\w/ && ! $options_done ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
/^--\w/ and not $options_done
MC/DC50%1/2
/^--\w/ and not $options_done
/^--\w/
not $options_done
Truth table66%2/3
A and not(B)
A= /^--\w/B= not $options_done
| |||||||||||||||||||||||||||||||||
| 12 | 1 | s/^--//; | |||||||||||||||||||||||||||||||
| 13 | 1 | my ($option, $val) = split /=/, $_, 2; | |||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | $val = 1 unless defined $val; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 15 | 1 | $options{$option} = $val; | |||||||||||||||||||||||||||||||
| 16 | } elsif ( /^--$/ ) { | ||||||||||||||||||||||||||||||||
| 17 | 0 | $options_done = 1; | |||||||||||||||||||||||||||||||
| 18 | } else { | ||||||||||||||||||||||||||||||||
| 19 | 1 | push @files, $_; | |||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | 1 | @ARGV = @files; | |||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | my $html = text2html | ||||||||||||||||||||||||||||||||
| 26 | 1 | do {undef $/; <>}, | |||||||||||||||||||||||||||||||
| 27 | %options; | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | $html .= "\n" unless $html =~ /\n$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 1 | print $html; | |||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | 1 | exit 0; | |||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | __END__ | ||||||||||||||||||||||||||||||||