I have a code that gets a parameter from a form.
And it should look in the text file if there is any line match at the begging of the line with the param passed from the form, if it does, don't save to the file it should go to
another part of the program. If it does not match write new entry to the end of the file with
new name at the beginning of the file and
the rest of the line with values like
thenewvaluehere*1*1*1*1*1*1*1*1*1*1
Here is the code but it's not working, I need help!!!!
First hte sample test file:
TTMIS*1*1*sandbox*1*1*1*1*1*1*1 Joe Smith*1*1*sandbox*1*1*1*1*1*1*1 Company*1*1*sandbox*1*1*1*1*1*1*1 Travel*1*1*sandbox*1*1*1*1*1*1*1 Comerce*1*1*sandbox*1*1*1*1*1*1*1

Now the code:
my $ag = param("name");#a name comming from the form my $filename="template_data_test.txt"; my $template_data = "/cgi-bin\\content\\unsecure\\".$filename; open(DATA_IN, "$template_data") || print "Can't open output file1: $te +mplate_data\n"; while (<DATA_IN>) { $_ =~/^(.*?)\*(.*?)\*(.*?)\*(.*?)\*(.*?)\*(.*?)\*(.*?)\*(.*?)\ +*(.*?)\*(.*?)\*(.*?)$/; my $value1=$1; unless($value1 ne $ag) { s/$value1/$ag/g; # I might have a problem here cause it ch +anges every value of $value1 $save_list=$save_list.$_;}else{$save_list=$save_list.$ +_;} } open( DATA_OUT, ">>test2.txt" ) or die "$!\n"; print DATA_OUT "$save_list"; close DATA_IN; close DATA_OUT;

In reply to Text File Problem by Anonymous Monk

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.