Hi Jerry. "Jerry Preston" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi! > > I am looking for way to reduce the following code, a better way, a perl > way. Any ideas?
I think you've been overlooked a little because your post looks very much like a 'please do my work for me' post, rather than an 'I'm a beginner who's tried everything he can think of and is still stuck' one. I'll give you the benefit of the doubt here and offer a hint. [snip] > $l = length( $Description ); > if( $l > 15 ) { > $Description = substr( $Description, 0, 14 ); > }elsif( $l != 15 ) { > $s = substr( " ", 0, 14 - $l ); > $Description .= $s; > } You're repeating this construct for every column in your database row. Your intention is to force each field to a fixed length by curtailing or space-padding it. (Although what you're actually doing here is adjusting all strings to a length of 14 unless they're already 15 characters long.) This is how to do that in Perl: $Description = sprintf "%-14.14", $Description; But you need to write the whole thing a little more elegantly: the field lengths should be in an array corresponding to the list of field values from the row. And you shouldn't be extracting the fields into named scalars unless the names have relevance to your code - leave them as anonymous array elements if that will suffice. It would be nice if we could see your improved version when it's done! HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]