Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
期待どおりに機能しないコードがあります。定義された関数は機能しません。
@jobs = qw[job1 undef job2]; if(defined($jobs[1])) { print "Job 1 is defined"; }
出力を取得します
Job 1 is defined
明らかに$jobs[1]ですundef。私は何が欠けていますか?
$jobs[1]
undef
を使用しているためqw、コードは次のようになります。
qw
@jobs = ("job1", "undef", "job2");
と同じではない$jobs[1]文字列 、したがって動作も同様です。"undef"undef
"undef"
2番目の仕事をしたい場合は、次のundefことができます。
@jobs = ("job1", undef, "job2");
AFAIKを使用してこれを行うことはできませんqw。