Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Cutting down a string

by lhoward (Vicar)
on Nov 10, 2001 at 02:28 UTC ( [id://124494]=note: print w/replies, xml ) Need Help??


in reply to Cutting down a string

$string=substr($string,0,20).'..' if length($string) > 22;

Replies are listed 'Best First'.
Or there's also . . .
by Fletch (Bishop) on Nov 10, 2001 at 03:22 UTC
    substr( $string, 20 ) = '..' if length($string) > 22;

    or even

    $string = sprintf( "%20s..", $string ) if length($string) > 22;

      Nice, but not quite right:
      $string = sprintf( "%.20s..", $string ) if length($string) > 22;
      --
      John.

Re: Re: Cutting down a string
by Anonymous Monk on Nov 10, 2001 at 02:37 UTC
    thank you very much

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-19 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found