Path: utzoo!attcan!telly!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!mit-eddie!uw-beaver!fluke!gtisqr!roger From: roger@gtisqr.uucp (Roger Droz) Newsgroups: comp.lang.perl Subject: Re: question about using format Message-ID: <1991Feb05.223438.15456@gtisqr.uucp> Date: 5 Feb 91 22:34:38 GMT References: <090557.28625@timbuk.cray.com> Organization: Global Tech International Inc. Lines: 48 In article composer@chem.bu.edu writes: >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 > > . > > > > 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? > >You can kludge it a tiny bit, using sprintf with something like.. > > format pageheader = > The time is @<<< > $time > . > > $time = sprintf("%02d:%02d", $hour, $min); > I'm not sure this trick is even between the lines in the man page, but I have had success using expressions (including subroutine calls) in formats: format pageheader = This time is @<<<< sprintf("%-2.2d:%-2.2d", $hour, $min) . I'm not a fan of using undocumented features, so I'd like the official blessing of the Gurus before continuing to use expressions in formats. ____________ Roger Droz () () Maverick International / Global Technology International (_______) Mukilteo, WA ( ) | | Disclaimer: "We're all mavericks here: | | Each of us has our own opinions, (___) and the company has yet different ones!" Internet: roger@mav.COM UUCP: uw-beaver!gtisqr!roger