--- Matthew Harrison <[EMAIL PROTECTED]> wrote: > i need to say something like > if $username = "" then ... > > where "" is literally nothing. i want to match it ONLY if the variable is > totally empty. > > this is my first experience with regex so what should this be? > > -- > Matthew Harrison
Brett had a good response ( ! $username ) and I though I could add a couple of comments. When using a conditional, ("if", "unless", "while", etc.), be aware that you should not use an assignment operator (the "="). Instead, you should generally use "==" or "!=" for numbers and "eq" or "ne" for strings (if you turn on warnings, Perl is usually good about letting you know what's going on). So, for your above example, if you wanted to check to see if the username is "Ovid", you could do this: if ( $username eq "Ovid" ) { ... } However, there's a little trick you can use that can help you avoid some of these bugs. Reverse the operands. Then, if you accidentally use the assignment operator "=": if ( "Ovid" = $username ) { ... } This won't even compile because you can't assign a variable ($username) to a string literal ("Ovid"). If you have the operands in the traditional order and don't turn on warnings, Perl will silently assign "Ovid" to $username, evaluate the entire expression as true, and execute the contents of the inner block. This is usually want you *don't* want. Cheers, Curtis "Ovid" Poe ===== "Ovid" on http://www.perlmonks.org/ Someone asked me how to count to 10 in Perl: push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//; shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A __________________________________________________ Do You Yahoo!? Yahoo! Sports - live college hoops coverage http://sports.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]