File Coverage

blib/lib/School/Code/Compare/Charset/NoComments/Slashy.pm
Criterion Covered Total %
statement 23 23 100.0
branch 10 10 100.0
condition n/a
subroutine 4 4 100.0
pod 0 2 0.0
total 37 39 94.8


line stmt bran cond sub pod time code
1             package School::Code::Compare::Charset::NoComments::Slashy;
2             # ABSTRACT: trim comments
3             $School::Code::Compare::Charset::NoComments::Slashy::VERSION = '0.103'; # TRIAL
4 4     4   28 use strict;
  4         8  
  4         124  
5 4     4   30 use warnings;
  4         8  
  4         983  
6              
7             sub new {
8 6     6 0 12 my $class = shift;
9              
10 6         14 my $self = {
11             };
12 6         14 bless $self, $class;
13              
14 6         22 return $self;
15             }
16              
17             sub filter {
18 6     6 0 11 my $self = shift;
19 6         20 my $lines_ref = shift;
20              
21 6         19 my @no_comments;
22              
23 6         10 foreach my $row (@{$lines_ref}) {
  6         17  
24 207 100       419 next if ($row =~ m!^/!);
25 195 100       373 next if ($row =~ m!^\s*\*!);
26 192 100       360 $row = $1 if ($row =~ m!(.*)//.*!);
27 192 100       357 $row = $1 if ($row =~ m!(.*)/\*.*!);
28 192         1453 $row =~ s/\s*//g;
29 192 100       431 next if ($row eq '');
30              
31 136         288 push @no_comments, $row;
32             }
33              
34 6         19 return \@no_comments;
35             }
36              
37             1;
38              
39             __END__
40              
41             =pod
42              
43             =encoding UTF-8
44              
45             =head1 NAME
46              
47             School::Code::Compare::Charset::NoComments::Slashy - trim comments
48              
49             =head1 VERSION
50              
51             version 0.103
52              
53             =head1 AUTHOR
54              
55             Boris Däppen <bdaeppen.perl@gmail.com>
56              
57             =head1 COPYRIGHT AND LICENSE
58              
59             This software is copyright (c) 2020 by Boris Däppen.
60              
61             This is free software; you can redistribute it and/or modify it under
62             the same terms as the Perl 5 programming language system itself.
63              
64             =cut