Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Parse data from a line to get 2 variables

by zerogeek (Monk)
on May 13, 2006 at 05:54 UTC ( #549183=note: print w/replies, xml ) Need Help??


in reply to Re: Parse data from a line to get 2 variables
in thread Parse data from a line to get 2 variables

My initial thought was to use 'split' as suggested in an earlier reply. However, reading your solution certainly seems to be a better approach.
I hadn't thought of using the min/max match. Good call!
  • Comment on Re^2: Parse data from a line to get 2 variables

Replies are listed 'Best First'.
Re^3: Parse data from a line to get 2 variables
by Sunnmann (Acolyte) on May 13, 2006 at 17:03 UTC
    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 :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://549183]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2022-08-17 16:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?