カレントディレクトリ名をPerlモジュールのCwd::getcwdで生成
PerlモジュールのCwdを使用して、getcwd関数でカレントディレクトリ名を出力しました。
#!/opt/local/bin/perl
use strict;
use warnings;
use utf8;
use Cwd qw(getcwd);
print "Content-type: text/plan; charset=utf-8\n\n";
print getcwd(".");
exit;
/Users/UserName/Documents/workspace/cgi-bin
サンプルコードと出力結果です。プログラムのファイルが置かれているカレントディレクトリ名がgetcwd
関数で出力されました。