Here is what I have so far. A script that creates two files:
andadm.count and blmadm.count. At the end of the script I want to merge
these two files in to one file.
#!/usr/bin/perl -w
#use Net::SMTP;
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI;
print "Content-Type: text/html; charset=ISO-8859-1\n\n";
my $field1="andadm,blmadm,coladm,echadm,elkadm";
my @array1 = split(/,/, $field1);
my $j = 0;
my $andcount = 0;
my $blmcount = 0;
#my count = 0;
my $FileName = "andadm.count";
my $FileName1 = "blmadm.count";
foreach (@array1) {
if ($_ eq "andadm"){
open(COUNT, "<$FileName") || die "Cannot open $FileName: $!\n";
$andcount=<COUNT>;
$andcount++;
close(COUNT);
open(COUNT,">$FileName");
print COUNT $andcount;
close(COUNT);
}
elsif ($_ eq "blmadm"){
open(COUNT, "<$FileName1") || die "Cannot open $FileName1: $!\n";
$blmcount=<COUNT>;
$blmcount++;
close(COUNT);
open(COUNT,">$FileName1\n");
print COUNT $blmcount;
close(COUNT);
}
$j++;
}
Thanks
Akbar Ehsan
Internet Services Coordinator
Central Office
Ivy Tech Community College
9301 E. 59th St.
Indianapolis, IN 46216
Phone: 1 317 921-4872
-----Original Message-----
From: Greg Jetter [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 01, 2007 10:08 PM
To: [email protected]
Subject: Re: Merging Files in Perl
On Thursday February 1 2007 5:22 pm, Akbar Ehsan wrote:
> Hello Everyone,
>
> Is there something in Perl, a procedure, a method, a command,
anything,
> that would enable me to merge several tiny text files into one big
text
> files. I was searching on perldoc.org unsuccessfully.
>
> Thanks.
>
> Akbar Ehsan
> Internet Services Coordinator
> Ivy Tech Community College
> 9301 E. 59th St.
> Indianapolis, IN 46216
Sure , just open them one at a time read them in and write them back out
to
the destination file one at a time , thousands of way of doing that ,
show us
what you got so far and we can help ya along.
Greg
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/