arrays

B

Bob Then

If I have an array of 127 elements some with number and most empty how can I
filter the empty ones out I tried using /^\d/ but it didn't work
 
J

Jürgen Exner

Bob said:
If I have an array of 127 elements some with number and most empty
how can I filter the empty ones out I tried using /^\d/ but it didn't
work

See "perldoc perlfunc". It has a section "Perl Functions by Category".
Does any of the functions listed for arrays or lists sound like it might do
what you are looking for?
Maybe a similar name as a popular Unix command (hint, hint)?

For details see "perldoc -f grep".

jue
 
R

rahul

Bob said:
If I have an array of 127 elements some with number and most empty how can I
filter the empty ones out I tried using /^\d/ but it didn't work

this may help if you mean 'undefined' array elements by 'empty'
@out = grep {defined} @in;

-rahul
 
T

Tad McClellan

rahul said:
this may help if you mean 'undefined' array elements by 'empty'
@out = grep {defined} @in;


And this may help if you meant "empty" when you said "empty":

@out = grep length, @in;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,170
Messages
2,570,925
Members
47,468
Latest member
Fannie44U3

Latest Threads

Top