-
-
Save hiroshi-manabe/65ceeb308d7008676de451dde07fc958 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# src/htdocs 下の PHP ファイルのパスを取得して表示します。 | |
# ファイル名が php-files.txt に含まれているもののみ取得します。 | |
# @files は「foo.php」のような PHP ファイル名のリスト,行区切り | |
open FILE, '<', 'php-files.txt'; | |
chomp(@files = <FILE>); | |
@file_dict{@files} = (); # ハッシュスライスを使って、%file_dict のキーとして @files の中身を入れる | |
# *.php | |
# パイプを使ってみる | |
open FIND, q{find src/htdocs -name '*.php' |}; # '*.php' はシングルクォートで囲わないとシェルで展開されてしまう | |
chomp(@paths = <FIND>); | |
close FIND; | |
my @php_files = grep { | |
m{([^/]+)$}; # パス区切り以降をマッチさせる | |
exists $file_dict{$1}; | |
} @paths; | |
print join "\n", @php_files; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment