That is different, but it isn't too hard...first, you need to use CGI.pm, then you get a list of the files, open them and write them out to another file. Here is an example...your webform will need one input named 'outfile' for the file you want to save to. You will also need a series of inputs named 'fileX' where 'X' is a number, one for each input file.
WARNING!!! This example doesn't use taint in order to make it more readable. In a real script you should always use taint.
use CGI;
my $q = new CGI; # Get a CGI object
open (OUT, ">$q->param('outfile')") || die $!; # Open our output file
my @files = grep{/^file\d+$/} $q->param(); # Grab a list of params
for my $filename (@files){
open (IN, $q->param($filename)) || die $!; # Open each input file
print OUT <IN>; # Print the input file to the output file
close (IN); # Make sure you close the input file
}
close (OUT);
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.