Code Comments
Programming Forum and web based access to our favorite programming groups.Hi, I want to count how many blank lines are at the end of a Tk::Text. Then I want to adjust that to N blank lines (1, actually). I'm trying to use ... $my_text->search() ...but the search wraps around to the beginning of the widget. Thanks
Post Follow-up to this messageOn Mar 26, 1:30 pm, RonH <harti...@gmail.com> wrote: > Hi, > > I want to count how many blank lines are at the end of a Tk::Text. > Then I want to adjust that to N blank lines (1, actually). > > I'm trying to use ... > > $my_text->search() > > ...but the search wraps around to the beginning of the widget. > > Thanks Why search if you know where they are? -textvariable => \$text $text =~ s/\n*$/\n/;
Post Follow-up to this messageOn Mar 26, 5:48 pm, smallpond <smallp...@juno.com> wrote: > On Mar 26, 1:30 pm, RonH <harti...@gmail.com> wrote: > > > > > > > > Why search if you know where they are? > > -textvariable => \$text > > $text =~ s/\n*$/\n/; Hi smallpond, Thanks. I didn't think of this approach so it is helpful. I will try it. A couple of things I see are: 1) I do want to count lines with whitespace as blank lines and 2) I want to add a blank line if none is present. So maybe... text =~ s/(\s*\n)*/\n/; Ron
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.