CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:



Jul 4, 2002, 1:11 AM

Post #1 of 2 (306 views)
substitution Can't Post


I have the following scenario. I have a string on which I have to perform the following: if the string length is > 16 then I have to insert break the string into 2 chunks, obviously the first string containing the 16 characters. Now on this I need furhther procession. If these sixteen characters contain an '_' (underscore) then rigth after the '_' i need to add the following to the string '$#xA0;' (non breaking space), otherwise enter the code a line break at the first non breaking space from the rigth hand side. Can anyone quickly scrabmle that code in perl ???

Thaumaturge / Moderator

Jul 4, 2002, 2:16 AM

Post #2 of 2 (303 views)
Re: [Saya] substitution [In reply to] Can't Post

Something like this I guess (assuming your text is in $string)

my ($first, $second); 

$first = $string;
$first = substr($string, 0, 16) if length($first) > 16;

unless ($first =~ s/_/_\$#xA0;/) {
$first =~ s/ /\n/;

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives