I am writing a perl script. I want to filter out lines that do not match a given regex. The problem is that I can not do that.
I have the following lines:
"com/puppycrawl/tools/checkstyle/Checker" -> "com/puppycrawl/tools/checkstyle/api/SeverityLevelCounter"
"com/puppycrawl/tools/checkstyle/Checker" -> "com/puppycrawl/tools/checkstyle/api/FilterSet"
"com/puppycrawl/tools/checkstyle/Checker" -> "java/util/Locale"
"com/puppycrawl/tools/checkstyle/Checker" -> "com/puppycrawl/tools/checkstyle/api/CheckstyleException"
"com/puppycrawl/tools/checkstyle/Checker" -> "com/puppycrawl/tools/checkstyle/PackageObjectFactory"
"com/puppycrawl/tools/checkstyle/Checker" -> "com/puppycrawl/tools/checkstyle/DefaultContext"
"com/puppycrawl/tools/checkstyle/Checker" -> "com/puppycrawl/tools/checkstyle/api/AutomaticBean"
"com/puppycrawl/tools/checkstyle/Checker" -> "com/puppycrawl/tools/checkstyle/api/FileSetCheck"
"com/puppycrawl/tools/checkstyle/Checker" -> "com/puppycrawl/tools/checkstyle/api/Filter"
"com/puppycrawl/tools/checkstyle/Checker" -> "com/puppycrawl/tools/checkstyle/api/AuditListener"
"com/puppycrawl/tools/checkstyle/Checker" -> "java/lang/StringBuilder"
"com/puppycrawl/tools/checkstyle/Checker" -> "java/lang/Exception"
"com/puppycrawl/tools/checkstyle/Checker" -> "java/io/File"
And I want to remove all those that do not start with com/puppycrawl/tools/checkstyle/ after the ->
So far my script looks like:
#! /usr/bin/perl -s
use File::Find;
our ($roll);
$dir = shift or die("Folder missing\n");
$prefix = shift;
$command = "javap -v";
$extension = "class";
$temp_file = "temp.tmp";
find(\&wanted, $dir);
sub wanted
{
if ($_ =~ /\.$extension$/)
{
push (@class_files, $File::Find::name);
}
}
print "digraph G\n{\n";
print "node [shape=box]\n";
foreach $class (@class_files) {
$class=~ s/(.*)\..*/$1/;
$_result= `$command $class | grep " = class"`;
$_result=~ s/.*\/\/ */\"$class\" -> /g;
$_line.=$_result;
}
$_line=~ s/"$dir\//"/g;
$_line=~ s/\[[A-Z]?//g;
$_line=~ s/\;//g;
$_line=~ s/->\s*(.*)/-> \"$1\"/g;
Something like this maybe?