Getopt-Long-DescriptivePod
view release on metacpan or search on metacpan
lib/Getopt/Long/DescriptivePod.pm view on Meta::CPAN
my $block_ref = shift;
for my $key ( keys %{$block_ref} ) {
VALUE: for my $value ( $block_ref->{$key} ) { # alias only
defined $value
or next VALUE;
$value =~ s{ \r\n | [\n\r] }{\n}xmsg; # compatible \n
$value =~ s{ \A \n* (.*?) \n* \z }{$1}xms; # trim
$value = [
( $key eq 'after' ? q{} : () ),
( split m{ \n }xms, $value ),
( $key eq 'before' ? q{} : () ),
];
}
}
return;
}
sub _read_file {
my $param_ref = shift;
lib/Getopt/Long/DescriptivePod.pm view on Meta::CPAN
my $current_content = _read_file( \%param_of );
if ( ! $current_content ) {
_on_verbose( \%param_of, 'Empty file detected' );
return;
}
my ($newline) = $current_content =~ m{ ( \r\n | [\n\r] ) }xms;
$current_content =~ s{ \r\n | [\n\r] }{\n}xmsg;
my ($newlines_at_eof) = $current_content =~ m{ ( \n+ ) \z }xms;
$newlines_at_eof = length +( $newlines_at_eof || q{} );
$current_content =~ s{ \n+ \z }{}xms;
my @content = split m{ \n }xms, $current_content;
# replace Pod
my $is_found;
my $index = 0;
LINE: while ( $index < @content ) {
my $line = $content[$index];
if ( $is_found ) {
if ( $line =~ m{ \A = \w }xms ) { # stop deleting on next tag
$is_found = ();
last LINE;
{
open my $file, '< :raw', $file_name
or die "Cannnot open file $file_name";
local $/ = ();
my $text = <$file>;
# repair last line without \n
ok(
! ( $text =~ s{([^\x0D\x0A]) \z}{$1\x0D\x0A}xms ),
"$file_name has newline at EOF",
);
@lines = split m{\x0A}, $text;
}
my $find_line_numbers = sub {
my ($test_description, $test_reason, $regex, $regex_negation) = @_;
my $line_number = 0;
my @line_numbers = map {
++$line_number;
($regex_negation xor $_ =~ $regex)
? $line_number
: ();
( run in 1.352 second using v1.01-cache-2.11-cpan-71847e10f99 )