Help for this page

Select Code to Download


  1. or download this
    my $newcolor = 'purple';
    my $seen = 0;
    ...
        print $outfile "$newcolor\n";
        close $outfile or die "Couldn't close the output file.\n$!";
    }
    
  2. 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$!";
    
  3. or download this
    use strict;
    use warnings;
    ...
    push @array, "$newcolor\n" unless grep { /$newcolor/ } @array;
    
    untie @array;