Class-Classgen-classgen
view release on metacpan or search on metacpan
Comments.pm view on Meta::CPAN
# This package assists in handling comments from the control file
# of classgen
#
# Michael Schlueter 5.3.2000 3.00
# 3.03:
# No changes in here 02.10.2000
# 3.02:
# No changes in here 06.07.2000
# 3.01:
# removed an error from just_var. this error suppressed most of
# the information in the header: section. 19.5.2000
package Class::Classgen::Comments;
$VERSION=3.03;
use strict;
sub find { # to find the comments in a line
my ($line) = @_;
$line=~m/(^[^#]*)(.*)/;
return ( $1, $2 ); # $1 source text, $2 comments
}
sub repair_header { # to put in missing ';' in the header section
my (@code) = @_; # the code edited into the header section
my @code2;
shift @code; # remove fragment
foreach (@code) {
# next if( $_=~m/:/); # this is an identifier for the sect.
unless ( $_=~m/;/ ) { # then find insertion point
if($_=~m/#/){ # case where comment is present
$_=m/(^.*)(\s*)#(.*)/;
push @code2, ($1 . $2 . ";#$3\n");
}else{ # case without comment
chomp;
push @code2, ($_ . ";\n");
}
} else { # case with ; and eventually comment
push @code2, $_; # use original code
}
}
return @code2;
}
sub just_comments { # to extract just the comments themselves
my ($line) = @_; # some line of code
$line =~ m/.*(#.*)/;
if($1){ return $1; } else { return ''; };
}
sub just_var { # to extract just the variable itself
my ($var) = @_; # the variable plus eventualy comments
$var =~ m/([\$\%\@]\w+)/;
# if($1){ return $1; } else { return ''; }; # 3.00 error !
if($1){ return $1; } else { return $var; }; # 3.01
}
1;
__END__
=head1 NAME
Comments.pm - To keep some nasty errors from users of classgen.
=head1 VERSION
3.03
=head1 SYNOPSIS
Used within classgen.
=head1 DESCRIPTION
Comments.pm checks for missing ';' in the header section. Missing ';' will allow to run classgen smoothly but lateron perl will complain about this error. Those anoying problems should be kept from the user.
It turned out to be useful to add some elucidating comments after variables in the variables-section. This increases self-documentation of the source code and better documents intentions. Variables are simply listed in the variables section. But user...
=head1 ENVIRONMENT
( run in 0.646 second using v1.01-cache-2.11-cpan-364913b4093 )