in reply to How Do I Use Getopt::Long without switches?

Do you mean that you want the program to use some sensible defaults if -p and -u are not given on the command-line? If that's the case, then the following snippet should help you on your way:

Getopt::Long::GetOptions( 'u=s' => \$user, 'p=s' => \$passwd, ); $user = 'me' unless defined $user; $passwd = 'sekret' unless defined $passwd;

If you can guarantee that neither $user nor $passwd can ever take the value 0, you can use the more compact expression:

$user ||= 'me'; $passwd ||= 'sekret';

... and when perl 5.10 is released (and we're in code freeze right now) the following will work, regardless of whether the value is 0 or not.

$user //= 'me'; $passwd //= 'sekret';

• another intruder with the mooring in the heart of the Perl