Skip to content

Instantly share code, notes, and snippets.

@bromne
Last active November 28, 2016 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bromne/c1b49009d71ab40ed86a1ac844651799 to your computer and use it in GitHub Desktop.
Save bromne/c1b49009d71ab40ed86a1ac844651799 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
# src/htdocs 下の PHP ファイルのパスを取得して表示します。
# ファイル名が php-files.txt に含まれているもののみ取得します。
# @files は「foo.php」のような PHP ファイル名のリスト,行区切り
open FILE, '<', 'php-files.txt';
chomp(my @files = <FILE>);
# *.php
chomp(my @paths = `find src/htdocs -name *.php`);
@php_files = ();
for my $path (@paths) {
for my $php (@files) {
if ($path =~ /^.*$php$/) {
unshift @php_files, $path;
last;
}
}
}
# ダメ
# my @php_files = grep {
# my $path = $_;
# for (@files) {
# if ($path =~ /^.*$_$/) {
# 1;
# last;
# }
# }
# 0;
# } @paths;
print join "\n", @php_files;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment