Just one suggestion about your code. When I see something duplicated like this:
print "==============\n\n"; print "| COMMODITY: |\n\n"; print "==============\n\n"; my $cmmdty = <STDIN>; $cmmdty = <STDIN> until defined $cmmdty; chomp $cmmdty; cls(); print "====================\n\n"; print "| LOADED OR EMPTY: |\n\n"; print "====================\n\n"; my $lore = <STDIN>; $lore = <STDIN> until defined $lore; chomp $lore; cls();
it immediately makes me want to encapsulate the duplicated code into a subroutine, so as to follow the doctrine of DRY.

Here's one way you could rewrite it:

sub prompt_for_value { my ($label) = @_; my $len = length($label); my $line = "=" x ($len + 5); # Display the prompt, eg. # # print "==============\n\n"; # print "| COMMODITY: |\n\n"; # print "==============\n\n"; print "$line\n\n"; print "| $label: |\n\n"; print "$line\n\n"; my $value = ""; while (1) { chomp(my $value = <STDIN>); if ($value) { cls(); # Is this subroutine defined? return $value; } } } my $cmmdty = prompt_for_value("COMMODITY"); my $lore = prompt_for_value("LOADED OR EMPTY");
If you do this, you've got a subroutine "prompt_for_value()" which you can use for other input. If there's a bug in your subroutine, or you want to make an improvement in it (like changing "\n\n" to a single newline, for instance), you only have to make the change once within the subroutine and all callers of the subroutine will now do the same thing.

Note that the prompt takes the length of the label into account, so the containing box is the right size.

This kind of code reuse will really help your programming skills.

say  substr+lc crypt(qw $i3 SI$),4,5

In reply to Re: Auto Fill by golux
in thread Auto Fill by PilotinControl

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.