I am trying to get perl to read in a bunch of info from the user and format it, to print it out on screen like this:
+--------------------------------------------------------------+
| Check No. $chkno |
| $first $last |
| $addr[0] |
| $addr[1] |
| $phone $date |
| |
| Pay to the |
| Order of: $payee $amount |
| |
| For: $memo Stamped Signature |
| |
+--------------------------------------------------------------+
I keep running into errors and I am not sure what's wrong. The address is supposed to be stored in an @array[0] and @array1 (first for house number and street, second for city, state, zip).
Take a look at my code and see if you can help me out.
#!/usr/bin/env perl
use warnings;
use strict;
print "Please enter the check number: ";
chomp (my $chkno = <STDIN>);
print "Please enter your first and last name: ";
chomp (my $first = <STDIN>);
chomp (my $last = <STDIN>);
print "Please enter your house number (or PO box) and street name: ";
chomp (my $one =<STDIN>);
print "Please enter your city, state, and zipcode: ";
chomp (my $two = <STDIN>);
my @addr = {$one, $two};
print "Please enter your phone number: ";
chomp (my $phone = (<STDIN>));
print "Please enter the date: ";
chomp (my $date = <STDIN>);
print "Please enter the payee's name: ";
chomp (my $payee = <STDIN>);
print "Please enter the amount to be paid: ";
chomp (my $amount = <STDIN>);
print "Please enter a memo for the check: ";
chomp (my $memo = <STDIN>);
format CHECK =
+--------------------------------------------------------------+
| Check No. @##### |
$chkno,
| @<<<<<<<<< @||||||||||||||| |
$first, $last,
| @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
$addr[0],
| @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
$addr[1],
| @<<<<<<<<<< @|||||||||||||||||| |
$phone, $date,
| |
| Pay to the |
| Order of: @|||||||||||||||||||||||||||| @#####.## |
$payee, $amount,
| |
| For: @<<<<<<<<<<<<<<< Stamped Signature |
$memo
| |
+--------------------------------------------------------------+
.
write (CHECK);
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.