Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Check if one of the array elements is not empty

by markkawika (Monk)
on Nov 11, 2009 at 01:12 UTC ( [id://806380]=note: print w/replies, xml ) Need Help??


in reply to Check if one of the array elements is not empty

Well if you're defining "not an empty string" to mean "a string containing something other than whitespace", then this is the simplest way:

if (grep /\S/, @array) { print "OK\n"; }

You can modify the regular expression to match whatever you want to match.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-09-07 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.