Just my thoughts on your post:

  1. use strict;
  2. use warnings;
  3. use Carp; and then call croak() instead of die(). Makes it easier to debug as soon as the code moves into a sub.
  4. one letter variable names are not a good idea, except in things like iterator counters, e.g. for(my $i = 0; $i < 10; $i++)
  5. $a and $b are reserved variable names, used by sort(). Do not use them for anything else.
  6. Unless your variables end in a line break, the print statements wont show up immediately on the command line, because buffered IO.
  7. 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.
  8. Not sure why you are opening $ofh51 for writing. You don't write to it.
  9. Both the example text file and the example output should be in their own code tags for easier reading as well as downloading.
  10. 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";'

In reply to Re: Not printing the values outside the while loop by cavac
in thread Not printing the values outside the while loop by suvendra123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.