- or download this
my $newcolor = 'purple';
my $seen = 0;
...
print $outfile "$newcolor\n";
close $outfile or die "Couldn't close the output file.\n$!";
}
- or download this
my $newcolor = 'purple';
open my $infile, "<", 'colorfile.txt'
...
print $outfile "$newcolor\n" unless $seen;
close $outfile
or die "Can't close the output file.\n$!";
- or download this
use strict;
use warnings;
...
push @array, "$newcolor\n" unless grep { /$newcolor/ } @array;
untie @array;