The script is forever because the one inner while loop continues to be 
true. It checks if the $str still exists in the string and it will because 
of how the replace is being done, which is places the matching text back in.

The original script had the \b in front and behind the 'word' but yours 
does not. The script is currently matching ## and then placing it back in. 
You'll need to update the replacement part of the script to get this to 
work for your situation.

From:
$n1 =~ s/(${str})/$1${iter}/;

To:
$n1 =~ s/(${str})/${iter}/;

That should be all you need to fix it, but I haven't tested.

-Kendall


On Monday, May 20, 2013 1:49:55 AM UTC-4, LuKreme wrote:
>
> On 03 Sep 2012, at 09:56 , Kendall Conrad <ange...@gmail.com <javascript:>> 
> wrote: 
>
> [Yes, I know this is old] 
>
> > #!/usr/bin/perl 
> > my $str = '\bthe\b'; 
>
> my $str = '##'; 
>
> > my $iter = 0; 
> > while (<>) { 
> >         if ($_ =~ m/${str}/){ 
> >                 my $n1 = $_; 
> >                 while ($n1 =~ m/(${str})/) { 
> >                         $iter++; 
> >                         $n1 =~ s/(${str})/$1${iter}/; 
> >                 } 
> >                 print $n1; 
> >         } 
> >         else { 
> >                 print "$_"; 
> >         } 
> > } 
> > 
>
> I made a slight change to this script because I wanted to replace the 
> following: 
>
> ## "Space Pilot 3000"        In color 
> ## "The Series Has Landed"        In Hypno-Vision 
> ## "I, Roommate"        As seen on TV[1] 
> ## "Love's Labours Lost in Space"        Presented in BC [Brain Control] 
> Where Available 
> ## "Fear of a Bot Planet"        Featuring gratuitous alien nudity 
> ## "A Fishful of Dollars"        Loading... 
> ## "My Three Suns"        Presented in double vision (where drunk) 
> ## "A Big Piece of Garbage"        Mr. Bender's Wardrobe By Robotany 500 
> ## "Hell Is Other Robots"        Condemned by the Space Pope[1] 
> ## "A Flight to Remember"        Filmed On Location 
> ## "Mars University"        Transmitido en Martian en SAP 
> ## "When Aliens Attack"        Proudly Made on Earth 
> ## "Fry and the Slurm Factory"        Live from Omicron Persei 8 
>
> With sequential numbers. I put it into a text factory, selected the block 
> of text, and… all I get is a "BBEdit Progress window" forever. When I click 
> "Stop", this doesn't stop BBEdit. I end up having to force-quit BBEdit. 
>
> % /usr/bin/perl --version 
>
> This is perl 5, version 12, subversion 4 (v5.12.4) built for 
> darwin-thread-multi-2level 
> (with 2 registered patches, see perl -V for more detail) 
>
>
>
> -- 
> I loved you when our love was blessed I love you now there's nothing 
> left But sorrow and a sense of overtime 
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.


Reply via email to