hi fella monks, i'm really a newbie in perl, and here's another problem. i'm developing a web-based program wherein i could delete and add files via web. now if i delete a file the script should modify another script, it should change the number of files in the current directory. for example: this is the script that should be modified:
open(FILE, $file) or die $!; @lines = <FILE>; close FILE; for ($i = 0; $i <= $#lines; $i++) { if ($lines[$i] =~ /<% INCLUDE exclusives(\d+)\.tmpl %>/) { $num = $1; $num = $num == 1 ? 3 : 1; $lines[$i] =~ s/<% INCLUDE exclusives(\d+)\.tmpl %>/<% INCLUDE ex +clusives$num\.tmpl %>/; } else { next; } open(FILE, ">$file") or die $!; print FILE @lines; close FILE;
as you can see the line:
$num = $num == 1 ? 3 : 1;
knows the number of files which in this case 3 files. now if i delete a file it should replace 3 to just 2. the same if i add a file 3 will turn into 4.... how will i be able to replace the value (3) whenever i delete or add a file via web. thanks in advance.

In reply to replacing values via web by damian

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.