Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Cutting down a string

by lhoward (Vicar)
on Nov 10, 2001 at 02:28 UTC ( #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 (Chancellor) 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
Node Status?
node history
Node Type: note [id://124494]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2019-08-22 04:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?