Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to minimize syntax

Status
Not open for further replies.

r2d22y

Technical User
Nov 30, 2004
46
SE
Hello

Lets say I have 10 variables thatI want to check if they are null ( "" )

instead of writing:

if( $var1 eq "" && $var2 eq "" && $var2 eq "" && .... $var10 eq ""){ Do something }

can I do this in a more "minimalistic" way like

if([$var1..$var10] eq ""){ Do something}

Regards/D_S
 
Unless you have access to these variable via some form of data structure (array or array of references or hash or something) then every solution looks messy.
You could look at eval or soft references but I would steer clear of those too. Just as messy and much more risky.
I have to ask though that if you have var1 thru var10 then why are they not in an array or hash? It sounds to me like that's what you need.

If you post more code or give us more of a context then I/we may be able to help further.


Trojan.
 
I agree. Sounds like you should be using an array, rather than 10 scalars.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top