>> >> Thanks guys.  With some help I've come up with this:
>> >>
>> >> $string = 'abc def ghi jkl mno pqr stu vwx yz';
>> >> if(length($string) = 34) {$var1 = $string.":";}
>> >
>> > '=' is assignment, '==' is test for numerical equality.
>> Change the above
>> > line to:
>> >    if( length($string) == 34 ) { $var1 = $string . ':' }
>> >
>> >> if(length($string) > 34) {
>> >>   $string =~ s/\s//g;
>> >
>> > The above line deletes all of the spaces in $string. Is
>> that what you want
>> > to do?
>>
>> All fixed up except for this.  How can I remove only the spaces at the
>> end of $var1 and $var2 if they exist?
>>
>> - Grant
>>
>>
>> >>   ($var1, $var2) = $string =~ /(.){35}(.){26}/;
>> >
>        This pulls 35 characters and splits words, yet what you asked for was 
> the last word separated. Correct?

I'm trying to pull 35 or fewer characters to the nearest space
basically.  This is what I have now:

if(length($string) <= 34) {$var1 = $string.":";}
if(length($string) > 34) {
  ($var1, $var2) = ($string =~ /(.{35})(.{26})/);
  $var1 =~ s/\s+$//;
  $var2 =~ s/\s+$//;
  $var2 .= ":";
}

Does that look OK?  Is the 3rd line off?

- Grant

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to