> -----Original Message----- > From: Brian Volk [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 28, 2007 12:24 > To: Brian Volk; beginners@perl.org > Subject: RE: print if variable matches key > > > > > -----Original Message----- > > From: Brian Volk [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, February 28, 2007 1:34 PM > > To: beginners@perl.org > > Subject: print if variable matches key > > > > Hello, > > > > > > > > I'm trying to print a tab delimited file based on a colon > separated file > > matching a key in %hash. I've attempted a few different > things w/ the > > colon separated file (splitting it into to variables, > making it %hash2) > > but I'm not having any luck. > > > > > > > > I'm trying to match up a text file, created from an email > form, into the > > correct tabbed column. The %hash contains all the fields > possible that > > could come over in the emailed form... the email (text file) only > > contains fields that were completed. > > > > > > > [Brian Volk] Sorry to respond to my own post... but I think > 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 > I am jusmping into the middle, so not real certain on what the 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. ********************************************************************** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/