On 05/09/07, Tom Phoenix <[EMAIL PROTECTED]> wrote: > On 9/5/07, Mike Martin <[EMAIL PROTECTED]> wrote: > > > I am having a problem with looping a string. > > Have you tried stepping through your code in the debugger? > > > while ($count lt $str_length){ > > That looks like a place where you used a string comparison ('lt') but > maybe meant a numeric comparison ('<'). > > Your code structure will be easier to understand if you indent > consistently. Using 'use strict' and 'use warnings' will also help to > improve your code. > > Does that get you closer to making your algorithm work? Good luck with it! > > --Tom Phoenix > Stonehenge Perl Training >
thanks this is the solution (BTW I had use strict, diagnostics and warnings on) #!/usr/bin/perl -w use diagnostics; use strict; my $string="ffmpeg -v 2 -i \"/home/mike/vcr58uc.avi\" -itsoffset -0.1 -i \"/home/mike/vcr58uc.avi\" -target dvd -y -s 352x288 -qscale 5 -bf 2 -g 15 -acodec mp2 -ac 2 -ab 64kk -me_range 63 -aspect 4:3 -map 1:0 -map 0:1 \"/home/mike/vcr58ucen.vob\""; my $wrap='50'; my @wwl; my $count=0; my $string1=$string; my @string1=$string1; my $str_length=length($string1); print $str_length,"\n"; while ($count < $str_length){ # correct operator { my $len2; my $line1=substr($string1,$count,$wrap); if ((length($line1)+$count)<$str_length){ # extra condition to make sure it increments if (rindex($line1,' ') ne -1){ # when check for white space results in 0 value $len2=rindex($line1,' '); } else {$len2=$wrap} } else {$len2=$wrap} my $strin2=substr($string1,$count,$len2); push (@wwl,$strin2); $count=$count+$len2; # I wasn't incrementing count properly } } $string=join("\n",@wwl); print $string,"\n"; Its actually a word wrap function, because I couldn't get Text::Wrap or Gtk wrap to work right. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/