I thought I would show you all the conclusion I came up
with thanks to your help. I used the solution to
getting my variables originally posted by Turo, not
my min/max as I had it. But here is the program in full.
#!c:\perl\bin
use warnings;
use strict;
my $lotNumber;
my $productName;
my $Info;
my $choice;
my $printLocal;
my $printEcho;
my $ftpobj;
my $ftp;
&MAIN;
sub MAIN {
print "Please make sure that you have all labels added into labellist.
+txt\nin the correct format.\n\nLot number then a tab and then Product
+ Name for each line\n\nEXAMPLE\:\nE1234567\t2RZ563DA\nE2345678\t2RZ12
+8CA\nE3456789\t2RS128BB\n\n\n";
print " 1\: East QPS\n 2\: East TC\n 3\: West Etest\n 4\: West TC\n 5\
+: Quit\n What is your choice? ";
$choice = <STDIN>;
chomp ($choice);
if ($choice==1)
{
$printLocal="10\.10\.10\.10";
$printEcho="East QPS Label Printer";
}
elsif ($choice==2)
{
$printLocal="10\.10\.10\.11";
$printEcho="East TC Label Printer";
}
elsif ($choice==3)
{
$printLocal="10\.10\.10\.12";
$printEcho="West TC Label Printer";
}
elsif ($choice==4)
{
$printLocal="10\.10\.10\.13";
$printEcho="West Etest Label Printer";
}
elsif ($choice==5)
{
system "CLS";
print "MultiPrint Has Shut Down.";
exit 0;
}
else
{
system "CLS";
print "You have chosen an invalid Number, Please try again\n\
+n";
&MAIN;
}
print "Backing up old test.txt... \n";
rename ("Labels.txt", "test.bac") || die "Cannot rename Labels.txt
+: $!";
open (LABELS, "labellist.txt") or die "I could not get at labellist.tx
+t as input";
open (OUTPUT, ">>Labels.txt") or die "I could not get at Labels.txt as
+ ouput";
my %info;
while (<LABELS>) {
my $printCode = "";
my ($lotNumber,$productName) = m/(\S+)\s+(\S+)/;
$info{$lotNumber} = $productName;
# print "$lotNumber\n";
# print "$productName\n";
print OUTPUT "\^XA\^LH30,30\n\^FO110,65\^A0,N,100\^FD$lotNumbe
+r\^FS\n\^FO150,160\^BY2,3.0\^B3N,N,125,N,N\^FD$lotNumber\^FS\n\^FO75,
+375\^A0,N,50,30\^FD$productName\^FS\n\^FO30,425\^BY2,2.0\^B3N,N,50,N,
+N\^FD$productName\^FS\n\^XZ\n";
}
close LABELS;
close OUTPUT;
}
print "You have chosen to print Labels.txt to the $printEcho ($printLo
+cal).\n\n Sending to printer now.\n\n";
use Net::FTP;
$ftpobj = Net::FTP -> new("$printLocal", Debug => 0)
or die "Cannot connect to some.host.name: $@";
$ftpobj -> login("user","")
or die "Cannot login ", $ftp->message;
$ftpobj -> put ("Labels.txt")
or die "put failed ", $ftp->message;
$ftpobj -> quit;
print `CLS`;
&MAIN;
This gives them a menu option that asks where they want it
to be printed, then once they chose it is all good.
It has been tested to work and print the labels
as wanted. Once again, THANK YOU ALL!
Of course all confidential info has been changed to
protect my company :)
-
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.