On Wed, 20 Nov 2002 21:01:45 +0100
"A. Pagaltzis" <[EMAIL PROTECTED]> wrote:

> * Jonathan E. Paton <[EMAIL PROTECTED]> [2002-11-20 20:51]:
> > if (@array > $bound) {
> >     $array[$bound-1] = ", etc"; # Set element at boundary 
> >     $#array = $bound-1;         # Shorten array to boundary
> > }
> > 
> > print join ", ", @array;
> 
> Again, that's the same as:
> 
> join ', ', @array[0 .. $bound], @array > $bound ? 'etc' : ();

both are wrong. how can you be sure the resulting string will be
no more than 90 chars (X chars) in length?

for example the first element in the array is 128K :)

> 
> > Now, this I *might* use in production code.  Of course, the
> > obvious mistake is that space between the last element and
> > the ", etc" part - but easily solved by using .= to append
> > to the appropriate element.
> 
> No, it will look like "..blah, , etc" and that's easily
> remedied by using just "etc" since the join adds its own
> ", " anyway.
> 
> -- 
> Regards,
> Aristotle
> 


-- 
Vladi Belperchinov-Shabanski <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
Personal home page at http://www.biscom.net/~cade
DataMax Ltd. http://www.datamax.bg
Too many hopes and dreams won't see the light...

Attachment: msg02764/pgp00000.pgp
Description: PGP signature

Reply via email to