Could you be more specific about what doesn't work?  I'm assuming you don't
get any errors or warnings, right?
I tried this code on my system and it works fine.  Even if $options{a} is
undefined ($options{a} eq "") should return true and send you into the block
with the print statement.

Is there any way that $options{a} could be getting set to 0?  This would not
work because eq looks at 0 as a string, and since it's not equal to the
empty string the expression returns false.

Running with -w and "use strict" could also give you some clues.

-- Brad

> That doesn't seem to work.  I want if a variable doesn't equal anything,
> then do something.  Here's a piece:
> if ($options{a} eq "" && $options{a} eq "") {
>     print "
> Usage: log.pl [-d] -a -i [n]\n
>         -d       :  specify device.  If nothing, eth0 is used
>         -a*      :  specify alias number
>         -i*      :  specify ip number to assign to alias
>         -n       :  specify netmask.  If nothing, 255.255.255.0 is used
>         Options with a * are required!\n\n";
>     exit;
> }
>
> ----- Original Message -----
> From: "Mooney Christophe-CMOONEY1" <[EMAIL PROTECTED]>
> To: "Perl Beginners" <[EMAIL PROTECTED]>
> Sent: Tuesday, July 17, 2001 12:59 PM
> Subject: RE: if something equals nothing
>
>
> > Exactly like that, except using 'eq' instead of '=='.
> > A slightly easier way, though, would be to say
> >
> > if (!$something) { ... blah blah ... }
> >
> > Since $something will return false in a boolean context (if it is empty)
> >
> > -----Original Message-----
> > From: Tyler Longren [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, July 17, 2001 12:56 PM
> > To: Perl Beginners
> > Subject: if something equals nothing
> >
> >
> > How do I do:
> > if ($something == "") {
> >     # do something
> > }
> >
> > in perl?
> >
> > Thanks,
> > Tyler
> >
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to