From 7c5998dcbeee2e57b057b1f6756191bbf7c2f55d Mon Sep 17 00:00:00 2001 From: Denis Efremov Date: Wed, 6 May 2020 22:13:18 +0300 Subject: [PATCH] scripts: add clean_perl_imports.sh Signed-off-by: Denis Efremov --- scripts/clean_perl_imports.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 scripts/clean_perl_imports.sh diff --git a/scripts/clean_perl_imports.sh b/scripts/clean_perl_imports.sh new file mode 100755 index 0000000..9067fc3 --- /dev/null +++ b/scripts/clean_perl_imports.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +for i in `find . -type f -name *.pm`; +do + use=$(grep -Poe '^use\h+[^(]+\(\K[^)]+' $i) + for u in $use + do + u=`echo $u | tr -d ':%$@'` + if [[ $u == 'import' || $u == 'RE' || $u == 'config' || $u == 'no_getopt_compat' || $u == 'permute' || $u == 'pass_through' || $u == 'gnu_compat' ]] + then + continue + fi + if ! grep -Pv '^use\b' $i | grep -qP "\b$u\b" + then + echo "No $u in $i" + fi + done +done