G
George Mpouras
# the following trick to create and write dynamic files save me a lot of
code, thans perl !
my %file = ();
foreach my $user (qw/george john jim/) {
foreach my $color (qw/green blue white/) {
$file{$user}{$color} = [ my $fh, "$user.$color.txt" ];
open $file{$user}{$color}->[0] , '>' , $file{$user}{$color}->[1] or die
"oups $^E\n" } }
print {$file{john} {white}[0]} "i am in john white\n";
print {$file{george}{blue} [0]} "I am in george blue\n";
foreach my $user (qw/george john jim/) {
foreach my $color (qw/green blue white/) {
close $file{$user}{$color}->[0] or die "oups $^E\n" } }
code, thans perl !
my %file = ();
foreach my $user (qw/george john jim/) {
foreach my $color (qw/green blue white/) {
$file{$user}{$color} = [ my $fh, "$user.$color.txt" ];
open $file{$user}{$color}->[0] , '>' , $file{$user}{$color}->[1] or die
"oups $^E\n" } }
print {$file{john} {white}[0]} "i am in john white\n";
print {$file{george}{blue} [0]} "I am in george blue\n";
foreach my $user (qw/george john jim/) {
foreach my $color (qw/green blue white/) {
close $file{$user}{$color}->[0] or die "oups $^E\n" } }