Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: substr question

by jwkrahn (Monsignor)
on Jun 18, 2010 at 18:45 UTC ( #845434=note: print w/replies, xml ) Need Help??


in reply to Re: substr question
in thread substr question

Probably better as:

my $s2; for ( split /(\s+)/, $s ) { last if length( $s2 . $_ ) > 100; $s2 .= $_; } print $s2;

Replies are listed 'Best First'.
Re^3: substr question
by toolic (Bishop) on Jun 18, 2010 at 18:55 UTC
    In fact, your code is worse for 2 reasons:
    • The output string $s2 no longer has any whitespace between words: Hello,Iamaperl/mysql...
    • Generates a warning: Use of uninitialized value $s2...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://845434]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2018-05-23 10:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?