Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: To test empty array in perl

by Sandy (Deacon)
on Apr 26, 2010 at 15:36 UTC ( #836939=note: print w/ replies, xml ) Need Help??


in reply to To test empty array in perl

Hi

I am a little uncertain as to what you mean when you say that the array is empty, because your pseudo code says

all the elements of @array contains &nbsp
This is not the same as an empty array. An empty array has no elements.

So, if you want to test if any of your array elements have somthing other than blank characters, you would need something different.

if (! @array) { # there are NO elements, do what you need to do } elsif (grep ! /^\s*$/, @array) { # there are elements in your array, and at least one # of them contains a string that has something other # than spaces } else { # there are elements in your array, but they are either # empty strings, or strings with spaces }


Comment on Re: To test empty array in perl
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://836939]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2014-07-22 22:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (130 votes), past polls