Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2018-08-17 12:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (178 votes). Check out past polls.

    Notices?