This file contains hidden or 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
| use strict; | |
| use warnings; | |
| use Carp qw/croak/; | |
| # 単一のtxt ファイルに結果を出力する場合は、ターミナルで perf filename > {txt} のように出力先を指定すると良い | |
| # リダイレクト出力 | |
| my $file = shift; | |
| # ファイル読み込み | |
| # open 関数の 第一引数に 未定義のスカラ変数を渡す。 open が成功したら fileh_andler が取得できる |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| use Carp qw/croak/; | |
| # 以下のプラグマを利用 | |
| use Net::FTP; | |
| use File::Spec; | |
| use File::Copy qw/move/; |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| use Carp qw/croak/; | |
| # ftp によるファイル転送 | |
| # 1, ホスト名 or ipアドレスを指定してftpサーバに接続 | |
| # 2, ipass でログイン | |
| # 3, ftpコマンドでファイルをdl | |
| # 4, 接続終了 |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| use File::Copy q/copy/; | |
| use Carp q/croak/; | |
| # 以下のプラグマを利用する | |
| use utf8; | |
| use Encode q/encode/; | |
| use Encode::UTF8Mac; # cpan でmodule をinstallしておく必要がある |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| # ファイル演算子 通常はif文の中で使う | |
| # -e ファイルが存在するか。directory や simbolic link も含まれる。 | |
| # -d ディレクトリが存在するか | |
| # -f 通常ファイルが存在するか。テキストファイルやbinファイル、データを格納しているファイル。 | |
| # -s ファイルサイズの確認。単位はバイト | |
| # -M 最終更新から経過した日数の取得 | |
| # -A 最終アクセスから経過した日数の取得 |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| use File::Basename qw/basename dirname fileparse/; | |
| use File::Spec qw/catfile/; | |
| use Carp 'croak'; | |
| use FindBin; | |
| use lib "$FindBin::Bin/lib"; | |
| # 絶対パスから末尾のファイル名を取得 |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| # move copy | |
| use File::Copy qw/move copy/; | |
| use Carp qw/croak/; | |
| if ($#ARGV < 0) { | |
| croak qq/No argments : $!/; |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| # use utf8; | |
| # 無名配列生成 --- () を [] に置き換える | |
| my $arr_ref = [1,2,3]; | |
| print @$arr_ref, "\n"; | |
| # 要素にアクセスする | |
| print $$arr_ref[0], "\n"; |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| # use utf8; | |
| # スカラ値を生成 | |
| my $str = 'hello'; | |
| my @arr = (1, 2); | |
| my %hs = ("key1" => '1', "key2" => '2'); | |
| # reference を作成 (参照). \ を prefix の前につける。 |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| # 文字列で日本語を扱うなら utf8 プラグマを利用する | |
| use utf8; | |
| # 呼び出し元の視点から、エラーが呼ばれた行を記述できる | |
| use Carp 'croak'; | |
| # 使用方法を出力するためのmodule | |
| # module を追加する時は、可能な限り使用する関数を明示する |
NewerOlder