file manipulation
file 1
2010-11-21,2
2010-12-01,1
file 2
2010-11-22,12
2010-12-01,11
this is for GD graph and the file file should be like this
2010-11-21,2
2010-11-22,12
2010-12-01,1,11
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: file manipulation
--90e6ba5bb8d90338a0049c407d77
Content-Type: text/plain; charset=ISO-8859-1
maybe this script may help:
use strict;
use warnings;
my %data;
while ( defined ( my $line = readline ) ) {
chomp $line;
my ($date, $num) = split(/,/, $line);
push( [at] {$data{$date}}, $num);
}
foreach my $date (sort keys %data) {
print join(',', $date, [at] {$data{$date}}), "\n";
}
perl script.pl *.txt
On Mon, Feb 14, 2011 at 11:46, Muzammil <muzammil.cse [at] gmail.com> wrote:
> file 1
> 2010-11-21,2
> 2010-12-01,1
>
> file 2
> 2010-11-22,12
> 2010-12-01,11
>
> this is for GD graph and the file file should be like this
> 2010-11-21,2
> 2010-11-22,12
> 2010-12-01,1,11
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
> For additional commands, e-mail: beginners-help [at] perl.org
> http://learn.perl.org/
>
>
>
--
Marcos Rebelo
http://www.oleber.com/
Milan Perl Mongers leader https://sites.google.com/site/milanperlmongers/
Webmaster of http://perl5notebook.oleber.com
--90e6ba5bb8d90338a0049c407d77--