hello all, I am trying to automate a system that has become tedious for me. Basically I will do some simple string manipulations but I am fairly new to perl and I haven't played with it for some time. I will list a very basic example of what I would like to happen to give you an idea of how I wish for the process to work and maybe you can give me an idea of an easy way to do so.
#!/usr/bin/perl -w #tells PERL to display warnings for syntax #This section will contain the listing of variables #this is the string for the break command my $file_name = shift; #This is the file to read in my $break_name = shift; #This is the string we are looking for my $counter1=0; #This is a simple counter #This will open the main.html file to read in information open(INFILE, $file_name) or die "Can't open file\n"; while(<INFILE>){ #until we print a break until($counter1=1) { #if you see a break <br> if (/$break_name/) #if you locate a the first bre +ak { #enter onto a new line and place another break #CODE GOES HERE #increment counter to 1 so it doesn't continue + doing it $counter1++; }#end if }#end of until }#end of while loop
the file is basically editing a webpage that constantly updates logfiles for viewing. When a new month approaches I must login to this page and add a new
along with a few other changes that I will mention. There aren't any other breaks in the file so as long as it found the FIRST
, skipped down ONE line, printed a new
..then that would be fine. Second problem: This one is much more complicated but basically I will again read in a string except in this string I will need to update the string with the current date. The string will look something like the following:
<li><a href="SERVER072007/intranet.htm" target="_blank">Jul 2007</a>
Each month the MONTH and YEAR in both places of the string must be replaced. I didn't know of an easy way to locate that line, perhaps call a formated date function, or what. If you have any thoughts of an easy way to do this please give me your feedback thanks.

In reply to string automation by dhudnall

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.