I am a web developer. The agency I work for uses Dreamweaver for its templating/library item features. The library items really come in handy for updating a nav bar or some piece of content thats the same on every page. We work with static HTML most of the time. So to change a menu item, we use a dreamweaver library item, we update that item once, we press update, and it changes it across every html page in the project.
But I would like to make a perl script I can run from the command line instead of opening up a GUI, it would simply be faster.
So for example, lets say I have a menu coded like this:
<!--MENUITEMS-->
<li><a href="products.html">Products</a></li>
<li><a href="about_us.html">About Us</a></li>
<li><a href="commercial.html">Commercial</a></li>
<li><a href="contact.html">Contact</a></li>
<!--MENUEND-->
I will store the li items code in their own file: nav.lbi:
<li><a href="products.html">Products</a></li>
<li><a href="about_us.html">About Us</a></li>
<li><a href="commercial.html">Commercial</a></li>
<li><a href="contact.html">Contact</a></li>
The perl script needs to replace in each file it scans all the text between <!--MENUITEMS-->
and <!--MENUEND--> with the contents of nav.lbi.
I was going to first try this in SED, but SED is tailored for line by line stuff. I have had success using SED to insert an entire text file somewhere in another file, but this is a bit different. With Perl I know I should be able to replace all the text between every occurance of <!---MENUITEMS--> and <!--MENUEND--> with the contents of nav.lbi, even though it spans multiple lines.
If I need to add the <!--MENUITEMS--> and <!--MENUEND--> tags to the actually nav.lbi file, since its doing a search and replace, if that would make it easier, that is fine too. This is just so I can update the navigation bar across multiple html files without needing to touch Dreamweaver.
One last thing to note is there is multiple occurances of <!--MENUITEMS--> and the closing <!--MENUEND--> because the navigation in the header is often identical to the navigation in the footer, so I need to update the file recursively.