2012年6月27日水曜日

開発環境

『初めてのPerl 第5版』(Randal L. Schwartz, Tom Phoenix, brian d foy 共著、近藤 嘉雪 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-427-9) の13章(ディレクトリ操作), 13.14(練習問題)8を解いてみる。

8.

やり方の1つ。(「やり方は何通りもある」(TIMTOWTDI(There Is More Than One Way To Do It.)))

コード(TextWrangler)

#!/usr/bin/env perl
use strict;
use warnings;

my @files = glob "* .*";
for(@files){
  my $sym = readlink $_;
  print "$_ -> $sym\n" if $sym;
}

入出力結果(Terminal)

$ ./sample.pl
test_new -> test
kamimuras-MacBook-Pro:perl kamimura$ ls -l test*
-rw-r--r--  4 kamimura  staff  330  3 18 16:09 test
-rw-r--r--@ 1 kamimura  staff  330  3  9 14:46 test.bak
-rw-r--r--  1 kamimura  staff  333  6 10 15:46 test.out
-rw-r--r--  4 kamimura  staff  330  3 18 16:09 test_link
lrwxr-xr-x  1 kamimura  staff    4  4  1 15:15 test_new -> test

test_folder:
total 0
drwxr-xr-x  3 kamimura  staff  102  4 30 16:11 sample
$

0 コメント:

コメントを投稿