Hello I changed my program . And added the features you suggested. I know a better way must exist . Can any one help.
$openx = open(BAKFIL, "<data.txt"); open(BAKFIL2, ">data.bak.txt"); if ( ! $openx ) { print "Content-type:text/html\n\n"; print "File Does not exist. Program will now abort"; close( BAKFIL ); close( BAKFIL2 ); unlink( "data.bak.txt"); exit ; } else { while(<BAKFIL>) { print BAKFIL2 $_; } close( BAKFIL ); close( BAKFIL2 ); } my $filesize = -s "data.txt"; open(XFIL,"data.txt") || die $!; @main = <XFIL>; close(XFIL); open(XFIL,">data.txt") || die $!; foreach $main_line (@main) { print XFIL $main_line; if ($main_line =~ /The marker line/) { print XFIL "Hello\n"; } } close(XFIL); my $filesizemain = -s "data.txt"; if ($filesizemain < $filesize) { open(BAKFIL2, "<data.bak.txt") || die $!; open(BAKFIL, ">data1313.txt") || die $!; while(<BAKFIL2>) { print BAKFIL $_; } close( BAKFIL2 ); close( BAKFIL );

In reply to Re^2: regular expression by toniax
in thread regular expression by toniax

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.