Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bu.edu!nntp-read!composer From: composer@chem.bu.edu (Jeff Kellem) Newsgroups: comp.lang.perl Subject: Re: question about using format Message-ID: Date: 29 Jan 91 16:02:49 GMT References: <090557.28625@timbuk.cray.com> Sender: news@bu.edu.bu.edu Reply-To: composer@chem.bu.edu Organization: Boston University Chemistry Department Lines: 38 In-reply-to: eric@redwood06.cray.com's message of 29 Jan 91 15:29:20 GMT In article <090557.28625@timbuk.cray.com> eric@redwood06.cray.com (Eric Markwardt) writes: > Date: 29 Jan 91 15:29:20 GMT > > I'm trying to get the current time displayed as part of part of > my page header -- something like: > > format pageheader = > The time is @>:@> > $hour, $min > . > > I can't seem to get the leading zeros to print if needed (i.e. I get > 'The time is 4: 5', rather than 04:05). > > Is it possible to do this in a format, or do I need to mess around with > using printf to create a correctly formatted string, which I then can > use in the format? Off hand, I don't believe it's possible with just the format. My mind could be missing something. ;-) You can kludge it a tiny bit, using sprintf with something like.. format pageheader = The time is @<<< $time . $time = sprintf("%02d:%02d", $hour, $min); then, do whatever else you want .. along with your `write'. Cheers... -jeff Jeff Kellem Internet: composer@chem.bu.edu