http://qs321.pair.com?node_id=1218259


in reply to Re^2: Make command line argument optional
in thread Make command line argument optional

I suspect you want

if (not defined $id) { print '$id is not defined';
Notice the change in quotes, inside double quotes $id will try to interpolate, and it is undefined