Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Finding the largest word in a string help!

by moritz (Cardinal)
on Dec 12, 2011 at 16:11 UTC ( [id://943110]=note: print w/replies, xml ) Need Help??


in reply to Finding the largest word in a string help!

(my $break2 = $str2)=~ s/(length($str2)>30)/$1\n/mg;

You can't just use any code inside a regular expression and expect it to work.

I'd approach the problem like this:

sub break_word { my $str = shift; # break up $str into separate words, # and return the result ... } # search for all words longer than 30 characters: s/(\S{31,})/ break_word($1) /eg;

Log In?
Username:
Password:

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

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

    No recent polls found