[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] stupid question about format



<x-flowed>

Just a stupid question or a simple question from a (stupid & dummy) 
perl programer ;-)

I spended an hour trying to format a record that must be fixed length 
but with spaces at the end of the record using perl format.

I wanted to use format to get my record set properly.

let say I write :

#!perl

$field1='field1';
$field2='field2';
$field3='1';

format STDOUT =
@<<<<<<<<@>>>>>>>>@>>>
$field1,$field2,$field3
.

write;


the result is : (^ is space and  is cariage return)
field1^^^^^^field2Â

I never suceed to get the last field correct if it happen that the
last field is constitued with spaces like in this script example.

if I try to place the blank inside the write arg list I get the
same result because perl only see two items in the list.

Can a perl guru can write this using write and format ?

note : using printf and a C like format work with no problem indeed.

---------------------------------------------------------------------
Vincent Nonnenmacher
AgentSpace
116 Av de la Republique
38320 BRESSON
tel :  (33) 476 33 25 06        mailto:Vincent.Nonnenmacher@agentspace.com
fax :  (33) 476 33 25 01        http://www.agentspace.com

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch

</x-flowed>