RE: print if variable matches key
- From: "Wagner, David --- Senior Programmer Analyst --- WGO"
- Date: Wed, 28 Feb 2007 12:31:27 -0800
-----Original Message-----I am jusmping into the middle, so not real certain on what the
From: Brian Volk [mailto:bvolk@xxxxxxxxx]
Sent: Wednesday, February 28, 2007 12:24
To: Brian Volk; beginners@xxxxxxxx
Subject: RE: print if variable matches key
-----Original Message-----separated file
From: Brian Volk [mailto:BVolk@xxxxxxxxxxxxxx]
Sent: Wednesday, February 28, 2007 1:34 PM
To: beginners@xxxxxxxx
Subject: print if variable matches key
Hello,
I'm trying to print a tab delimited file based on a colon
matching a key in %hash. I've attempted a few differentthings w/ the
colon separated file (splitting it into to variables,making it %hash2)
but I'm not having any luck.form, into the
I'm trying to match up a text file, created from an email
correct tabbed column. The %hash contains all the fieldspossible that
could come over in the emailed form... the email (text file) only[Brian Volk] Sorry to respond to my own post... but I think
contains fields that were completed.
I'm getting
closer... The file is printing okay...I just need to know how
to print a tab
if the $emailField is not in <EMAIL> ...I guess that is the
tricky part. :-)
I should probably sort to keep the same field order...
[Brian Volk]
my $email = "c:/brian/AX/vendor/email_file_new_less.txt";
open(EMAIL, $email) or die "Can't open the $email: $!\n";
while(<EMAIL>){
chomp $_;
my($emailField, $emailValue) = split(/\:/,$_);
if (exists $hash{$emailField}) {
print NEW "$emailValue \t";
} else {
print NEW "blank \t";
}
}
Any pointers would be greatly appreciated.
Thanks!
Brian
output looks like, but the problem comes from what a\t does under the
current shell setup you are using. If you print $emailValue and it is 20
characters plus \t will not look the same if you print 5 characters plus
a \t. You could use printf and then size appropriately and \t will do
what you want.
If you have any problems or questions, please let me know.
Thanks.
Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449 FAX
http://fedex.com/us
**********************************************************************
This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited.
**********************************************************************
.
- Follow-Ups:
- RE: print if variable matches key
- From: Brian Volk
- RE: print if variable matches key
- References:
- RE: print if variable matches key
- From: Brian Volk
- RE: print if variable matches key
- Prev by Date: RE: print if variable matches key
- Next by Date: RE: print if variable matches key
- Previous by thread: RE: print if variable matches key
- Next by thread: RE: print if variable matches key
- Index(es):