Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: truncating a line

by svsingh (Priest)
on Jul 01, 2003 at 15:26 UTC ( [id://270511]=note: print w/replies, xml ) Need Help??


in reply to truncating a line

I haven't seen anyone answer with this one yet, so I thought I'd throw it out there. Sorry if it's a repeat. I'm not as proficient with all the regex tricks as I'd like to be.
$line =~ /^(.{0,17})/; print "$1\n";

If that's a rehash, then please let me know. I think it's close to BrowserUK's answer, but they have an if that mine doesn't. Thanks.

Replies are listed 'Best First'.
Re: Re: truncating a line
by tilly (Archbishop) on Jul 01, 2003 at 16:18 UTC
    Removing an if is only worthwhile if you still have a correct solution.

    Yours does not add the requested "..." when it is needed. (And like the other RE solution will also mess up if there is a newline in there.)

      Argh. Thanks tilly. I was so jazzed that I knew how to approach the first half, I overlooked the second. Read the spec, read the spec, read the spec.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 19:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found