Just my thoughts on your post:
- use strict;
- use warnings;
- use Carp; and then call croak() instead of die(). Makes it easier to debug as soon as the code moves into a sub.
- one letter variable names are not a good idea, except in things like iterator counters, e.g. for(my $i = 0; $i < 10; $i++)
- $a and $b are reserved variable names, used by sort(). Do not use them for anything else.
- Unless your variables end in a line break, the print statements wont show up immediately on the command line, because buffered IO.
- When i do file operations, i usually chomp() every line, then add linebreaks explicitly to the output when required. Makes it easier to understand the code.
- Not sure why you are opening $ofh51 for writing. You don't write to it.
- Both the example text file and the example output should be in their own code tags for easier reading as well as downloading.
- Personally, i also prefer singular/plural naming of variables. So, for example it would be @results. When accessing an element of that, it would be $results[1], because its "one of many". On the other hand, an iterator would be singular, something like foreach my $result (@results). But that's just me...
perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'