Question on Cutting and Paste things in a File <<<<<<<< 
Author Message
 Question on Cutting and Paste things in a File <<<<<<<<

Hi,
        I want to write a script or something, that will scan for line
with "<br>", then scan UP for "<BR>" and replace the 2nd "<BR>" UPWARDS
with the "<b>" line.
                -------------before-----------
Parking $3.<BR>
<BR>
<BR>
<a name="trail">
Offers a variety of outdoor recreational activities
fishing (limited area), canoeing, and camping along the riverside.<BR>
<b>Housatonic Meadows State Park</b><BR>
                        -----AFTER--------
Parking $3.<BR>
<BR>
<b>Housatonic Meadows State Park</b><BR>
<a name="trail">
Offers a variety of outdoor recreational activities
fishing (limited area), canoeing, and camping along the riverside.<BR>

-----------------------------------------------

thankx For Any Help
Bikesh



Sat, 15 Nov 1997 03:00:00 GMT  
 Question on Cutting and Paste things in a File <<<<<<<<
It is not clear from your example what all the rules are, but the following
code works for your data:

$i = 0;          # and line counter

OUTER: while($hold_line[$i] = <DATA>)
{
   $i++, next if $hold_line[$i] !~ /^<b>/;
   for($j = $#hold_line - 1, $k = 0; $j; $j--)
   {
      if($hold_line[$j] =~ /<BR>/)
      {
         $k = 1, next if $k == 0;
         $hold_line[$j] = $hold_line[$#hold_line];
         $hold_line[$#hold_line] = "\n";
         last OUTER;
      }
   }

Quote:
}


{
   print;

Quote:
}

__END__
Parking $3.<BR>
<BR>
<BR>
<a name="trail">
Offers a variety of outdoor recreational activities
fishing (limited area), canoeing, and camping along the riverside.<BR>
<b>Housatonic Meadows State Park</b><BR>


Fri, 21 Nov 1997 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ^<<<<<<<<<<<~~ with \n

2. ^<<<<<<<<<<< ~~ format question

3. How can I make @<<<<<<<<< variable ?

4. How can grep the 8th of Field <<<<<<<<

5. Using $: and ^<<<<~~~ in formatting

6. <<<<<< HELP >>>>>>>>

7. format @<<<

8. 4.036 Bug using $: and ^<<<~~ fields

9. >>>> A Singaporean Girl looking for more penpals!!<<<<<

10. append to beginging of file instead of open FILE <<file.txt

11. Perl debugger prompt question <<##>>

12. newbie question regarding s/<old string>/<new string>/g

 

 
Powered by phpBB® Forum Software