Hi Monks, I am stuck in building a CGI program, which read/write to a file. I am able to do the tasks separately. Here is how I am writing to the file.
# now write to the file open(OUT, ">/u001/data/slatrk/data/comments.dat"); foreach my $p (param()) { print OUT param($p) . "\n"; } print OUT "\n"; close(OUT);
And this is how I am reading from the file.(Code snippet)
# Extraction Process sub first_process { $data_dir="/u001/data/slatrk/data"; open(F1,"<$data_dir/comment_job.config") || die "Cannot open file1 +:$!\n"; open(F2,"<$data_dir/comments.dat") || die "Cannot open file2:$!\n" +; while(<F1>){ chomp; chomp(my $f2=<F2>); push (@comment, $_ . "|" . $f2 . "\n"); } } push(@rows,$q->th(['APPLICATION', 'COMMENT'])); &first_process; foreach (@comment) { #array starts here ($jobname, $comment)= split /\|/; push(@rows,$q->td([$jobname, '<textarea>'.$comment.'</textarea +>'])); }#array ends here print qq {<div id='container'>}; print $q->table( {-cellpadding => 3}, Tr(\@rows) );
Now I want to combine the two methods and I can write the data to the data using param. It should be in a loop so that i don't have to give textarea names separately. Can someone help me in this regard.

In reply to read/write data in using CGI by sauravrout

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.