in reply to Question on using format and write

Not sure if this is the case from what you've got above, but all the variables in a format have to be in scope when you define the format, otherwise you'll simply get a load of blank lines output when you call write, even if the variables are in scope at the time of the write.

I've found the easiest way to ensure this is to define the format right after the write call - but it's not the most elegant way to do it.

Maybe it's something completely different .. not sure from what's there :)

Hope that helps a little ..
-- Foxcub

Replies are listed 'Best First'.
Re: Re: Question on using format and write
by vagnerr (Prior) on Dec 13, 2002 at 20:21 UTC
    Foxcub is correct. It looks like it is a scope problem. If you were to enforce warnings ( perl -w ) then you would get an error allong the lines of
    Use of uninitialized value in formline at ????.pl line ??.
    if you remove your line
    my ($cust, $d1, $d2, $c1, $c2);
    from the function, or perhaps put it before you define your format that should give you your output :-)

    _______________________________________________________
    Remember that amateurs built Noah's Ark. Professionals built the Titanic.