http://www.perlmonks.org?node_id=431976

pugsly62 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I would like to put the 'localtime(date())' function results in my report header - how do I do that? i.e., I made a header using 'STDOUT_TOP =' I would like to put the date in my header. Thanks! Scott

Replies are listed 'Best First'.
Re: localtime(time()) function in header
by Roy Johnson (Monsignor) on Feb 17, 2005 at 15:51 UTC
    What's the actual problem? Do you know how to fetch the date/time value you want into a variable? Do you know how to include a variable in a format? That's all you need to know.

    Caution: Contents may have been coded under pressure.
Re: localtime(time()) function in header
by dReKurCe (Scribe) on Feb 17, 2005 at 17:35 UTC
    Here's one possible solution :
    #! /usr/bin/perl use Time::localtime; $day=localtime->yday(); $month=localtime->mon(); $year=localtime->year() ; $month=+1; $year +=1900; $string="Spacley"; @date=("$day","$month","$year" ); write(); format STDOUT_TOP= Spacely Sprockets Report Beta 1 @##@##@#### $day ,$month,$year . format STDOUT= @<<<<< @<<<<<<<< @<<<<<<< $string,$string,$string .
A reply falls below the community's threshold of quality. You may see it by logging in.