Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Think about Loose Coupling
 
PerlMonks  

localtime(time()) function in header

by pugsly62 (Novice)
on Feb 17, 2005 at 15:34 UTC ( #431976=perlquestion: print w/ replies, xml ) Need Help??
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

Comment on localtime(time()) function in header
Re: localtime(time()) function in header
by prasadbabu (Prior) on Feb 17, 2005 at 15:46 UTC

      Why do you post an answer when you don't answer the question? The OP is obviously asking a question related to perl formats. Why are you giving random links about localtime?

      pugsly62, if you're listening, you might want to try something along the lines of the following:

      format STDOUT_TOP = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< scalar localtime . format STDOUT = some data here . write;

      Update: forgot to mention that I downvoted prasadbabu's post for being a non-answer.

      --
      edan

        The OP is obviously asking a question related to perl formats.
        I would not call it "obviously". It can be guessed, yes, but not known. He also might want to put a date in a HTTP-header or something.
        The OP should read Tutorials, esp. On asking for help and How to ask questions the smart way (off-site).

        Update:
        And since you are new to this site pugsly62, the OP is you ,)

        Update:
        And as for you edan,
        it seems encouraging people reading the site-docs is worth the time. This post is nicely asked and well formatted.


        holli, /regexed monk/
        Thanks everyone...I had been searching diligently through my perl books but I could not find any reference to using functions in headers, thus my question. I'll give your example a try. Thanks! Scott
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 .

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://431976]
Approved by jfroebe
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (12)
As of 2014-04-23 19:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (553 votes), past polls