Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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

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 .
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.


        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).

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

        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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://431976]
Approved by jfroebe
[james28909]: i dunno, if i didnt have so little experience in linux i would swap. but it would be to much of a learning curve for me right now.
[choroba]: Low-end is defined as the Perl that generates millions of income
[choroba]: sorry, that's high-end, of coursse
[choroba]: low end, in my talk, will be code that "we don't touch because it works" and noone knows why
[choroba]: I want to present the most bizzare bugs and misfeatures I met when working for a large financial institution
[choroba]: I already gave a similar talk to my friends in a pub and at an internal conference at work and people liked it, so maybe...
[choroba]: LanX: That's the heritage, I can't do anything else
[RonW]: Sounds like some system my employer has "It does exactly what we need it to do and can't afford to risk anything we can't prove is 100% compatible"
[marto]: choroba sounds interesting
[RonW]: james28909 Why not write a Perl program to do the task?

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2017-05-22 21:37 GMT
Find Nodes?
    Voting Booth?