--- "John W. Krahn" <[EMAIL PROTECTED]> wrote:

> chen li wrote:
> > 
> > --- "John W. Krahn" <[EMAIL PROTECTED]> wrote:
> > 
> >>chen li wrote:
> >>
> >>>Sorry to bother again. I get an AoA containing
> >>empty
> >>>elements like these:
> >>>
> >>>my @data=(
> >>>           [1,1,1],
> >>>           [2,2,2],
> >>>           [],
> >>>           [3,3,3],
> >>>           []
> >>>        );
> >>>
> >>>How can I remove the empty element in this AoA?
> >>Can I
> >>>use grep function to do it?
> >>Yes:
> >>
> >>@data = grep @$_, @data;
> > 
> > Thank you very much for the help. But this line
> code
> > doesn't work for this format:
> > 
> > my @data=(
> >           ['1','1','1'],
> >           ['2','2','2'],
> >           [''],
> >           ['3','3','3'],
> >            ['']
> >         );
> 
> @data = grep @$_, map [ grep length, @$_ ], @data;
> 
> 
> 
> John


Thank you very much John. But could you explain a
little more about the line codes? It is difficult for
me to understand how they work even I read the perldoc
perllol. It looks to me @$_ is deferencing  anonymous
array but is that all?


@data = grep @$_, @data;

@data = grep @$_, map [ grep length, @$_ ], @data;



Li




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to