Better perl filtering

This commit is contained in:
2026-02-04 17:53:53 +09:00
parent ef397bd473
commit 91e4d94cbe

20
run.sh
View File

@@ -38,9 +38,23 @@ if [[ ! -f out/perl-libs.txt ]]; then
| tee "$OUTPUT_DIR/perl-libs.txt"
fi
cat "$OUTPUT_DIR/perl-libs.txt" | sort > "$OUTPUT_DIR/perl-libs-sorted.txt"
comm -2 -3 "$OUTPUT_DIR/perl-libs-sorted.txt" PERL_STANDARD_MODULES.txt > "$OUTPUT_DIR/perl-libs-filtered.txt"
# TODO: remove pragmas
cat "$OUTPUT_DIR/perl-libs.txt" | sort > "$OUTPUT_DIR/perl-libs-tmp1.txt"
# Remove import specifiers
sed -E \
-e 's|\s*(qw)?\s*\(.*\)||g' \
-e 's|\s*(qw)?\s*\/.*\/||g' \
"$OUTPUT_DIR/perl-libs-tmp1.txt" | sort > "$OUTPUT_DIR/perl-libs-tmp2.txt"
# Remove standard Perl modules
comm -2 -3 "$OUTPUT_DIR/perl-libs-tmp2.txt" <(cat PERL_STANDARD_MODULES.txt | sort) > "$OUTPUT_DIR/perl-libs-tmp3.txt"
# Remove pragmas
readarray -t PERL_PRAGMAS < PERL_PRAGMAS.txt
remove_pragmas_regex=$(printf '|^%s' "${PERL_PRAGMAS[@]}")
remove_pragmas_regex="${remove_pragmas_regex:1}" # remove leading '|
sed -E "/${remove_pragmas_regex}/d" "$OUTPUT_DIR/perl-libs-tmp3.txt" > "$OUTPUT_DIR/perl-libs-filtered.txt"
cat "$OUTPUT_DIR/perl-libs-filtered.txt" | uniq -c | sort -gr > "$OUTPUT_DIR/perl-libs-overview.txt"
if [[ ! -f "$OUTPUT_DIR/php-libs.txt" ]]; then