> > > $str = "
> > > /var                      0.99    50%
> > > /usr                      0.58    71%
> > > /tmp                      0.49     1%
> > > "
> >
> >      my @rows = map [split], split /\n/, $str;
> >      for (@rows) { $_->[2] =~ tr/%//d }
> 
> Not quite! Because the string starts and ends with newslines
> this leaves @rows with five elements. Consequently the tr//
> dies when asked to operate on the undefined $_->[2].
> 
> I admit that I thought this was more than likely to have come
> from a file in the first place, but even so the trailing "\n"
> is more than likely.
>

Good point. However I must apologize for posting the wrong string. The
string as it is created does not have beginning and ending new lines, so
steve's code works. 


-- 
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