Windowsでglobを使う
投稿:2019-02-25
#!/usr/bin/env perl -w use utf8; use strict; use warnings; use Encode::Locale; use feature "say"; binmode STDIN, ":encoding(console_in)"; binmode STDOUT, ":encoding(console_out)"; $| = 1; say "ファイル名をグロブ"; my @file = <*.txt>; say "ファイル名の文字コードでデコード"; for (@file) { $_ = Encode::decode locale_fs => $_; } say "ファイル名順でソート"; @file = sort @file; say "一覧を表示"; for (@file) { say; } say "1行で書くと"; say for sort map {$_ = Encode::decode locale_fs => $_} <*.txt>;
ファイル名をグロブ ファイル名の文字コードでデコード ファイル名順でソート 一覧を表示 sample_13_1.txt sample_13_2.txt sample_13_3.txt sample_14.txt sample_15.txt sample_17.txt sample_18x.txt sample_25_473.txt sample_25_473_2.txt sample_25_473_3.txt sample_25_473_4.txt sample_25_473_5.txt sample_25_481_1.txt sample_27_1.txt sample_28.txt sample_28_2.txt sample_29.txt sample_29_1.txt sample_29_2.txt sample_36_idle.txt sample_36_idle_now.txt sample_38.txt sample_49.txt sample_51.txt sample_65.txt sample_69_in.txt sample_69_out.txt たこルカは俺の嫁.txt 1行で書くと sample_13_1.txt sample_13_2.txt sample_13_3.txt sample_14.txt sample_15.txt sample_17.txt sample_18x.txt sample_25_473.txt sample_25_473_2.txt sample_25_473_3.txt sample_25_473_4.txt sample_25_473_5.txt sample_25_481_1.txt sample_27_1.txt sample_28.txt sample_28_2.txt sample_29.txt sample_29_1.txt sample_29_2.txt sample_36_idle.txt sample_36_idle_now.txt sample_38.txt sample_49.txt sample_51.txt sample_65.txt sample_69_in.txt sample_69_out.txt たこルカは俺の嫁.txt