Let's assume you have split out the 4 elements as variables $id1, $id2, $sequence, $label. The next thing you need to create is the signature that represents a "unique" value, by combining $id2 and $sequence: simplest is if you can join them with some character known not to appear in either value - from the example above I will guess that the pipe character '|' is safe to use:
my $signature = join '|', $id2, $sequence;
Now you can use this signature as the key in a hash. For simplicity, I'll use this to store the entire structure:
my %hash; # somewhere before you start to loop over the data
...
# within the loop over your data
my $signature = join '|', $id2, $sequence;
my $structure = {
id1 => $id1,
id2 => $id2,
sequence => $sequence,
label => $label,
};
$hash{$signature} = $structure; # save it
In the case of duplicate signatures this overwrites, so ends up saving a structure for the last example of any given signature, but there are other strategies possible.
You can then emit the data by looping over the hash something like:
for my $signature (keys %hash) {
my $structure = $hash{$signature};
printf "%s|%s\n%s\n%s\n",
$structure->{id1},
$structure->{id2},
$structure->{sequence},
$structure->{label};
}