use strict; BEGIN { open(STDERR, ">stderr2.log") or die "Failed to open log file"; } my $slot_file = $ARGV[0]; my $OUFTILE = $ARGV[1]; open my $SLOT_INFILE, q{<}, $slot_file; my %hash; while (my $line = <$SLOT_INFILE>) { my @Elements = split /;/, $line; $hash{$Elements[0]} = $Elements[1]; } my @Keys = keys %hash; my $key; foreach $key(@Keys){ print $OUTFILE "$key;$hash{$key}\n"; } close STDERR;