Note that there are some explanatory texts on larger screens.

plurals
  1. POPerl remove unwanted lines from a String
    text
    copied!<p>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.</p> <p>I have the following lines:</p> <pre><code>"com/puppycrawl/tools/checkstyle/Checker" -&gt; "com/puppycrawl/tools/checkstyle/api/SeverityLevelCounter" "com/puppycrawl/tools/checkstyle/Checker" -&gt; "com/puppycrawl/tools/checkstyle/api/FilterSet" "com/puppycrawl/tools/checkstyle/Checker" -&gt; "java/util/Locale" "com/puppycrawl/tools/checkstyle/Checker" -&gt; "com/puppycrawl/tools/checkstyle/api/CheckstyleException" "com/puppycrawl/tools/checkstyle/Checker" -&gt; "com/puppycrawl/tools/checkstyle/PackageObjectFactory" "com/puppycrawl/tools/checkstyle/Checker" -&gt; "com/puppycrawl/tools/checkstyle/DefaultContext" "com/puppycrawl/tools/checkstyle/Checker" -&gt; "com/puppycrawl/tools/checkstyle/api/AutomaticBean" "com/puppycrawl/tools/checkstyle/Checker" -&gt; "com/puppycrawl/tools/checkstyle/api/FileSetCheck" "com/puppycrawl/tools/checkstyle/Checker" -&gt; "com/puppycrawl/tools/checkstyle/api/Filter" "com/puppycrawl/tools/checkstyle/Checker" -&gt; "com/puppycrawl/tools/checkstyle/api/AuditListener" "com/puppycrawl/tools/checkstyle/Checker" -&gt; "java/lang/StringBuilder" "com/puppycrawl/tools/checkstyle/Checker" -&gt; "java/lang/Exception" "com/puppycrawl/tools/checkstyle/Checker" -&gt; "java/io/File" </code></pre> <p>And I want to remove all those that do not start with <code>com/puppycrawl/tools/checkstyle/</code> after the <code>-&gt;</code></p> <p>So far my script looks like:</p> <pre><code>#! /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(\&amp;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\" -&gt; /g; $_line.=$_result; } $_line=~ s/"$dir\//"/g; $_line=~ s/\[[A-Z]?//g; $_line=~ s/\;//g; $_line=~ s/-&gt;\s*(.*)/-&gt; \"$1\"/g; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload