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

On my Perl action page on a Unix server, I would like to have a last modified date:
Page contact: Brent Jones Last modified Mon, May 17, 2004
My below attempt just prints out the whole stat line words and not the last mod date. Please advise.
print header, <<"EOF"; <HTML> <body> <table width="99%" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center">my action page stuff here etc </td> <tr> <tr> <td valign="bottom" align="right"><font size="-1">Page Contact:&nbsp;B +rent Jones <br> print "Last Modified localtime((stat(/cgi-bin/dir/lastmodif.pl))[9])\n +"; </td> </tr> </table> </body> </html> EOF

Replies are listed 'Best First'.
Re: Last mod on my Perl action page
by matija (Priest) on May 17, 2004 at 19:47 UTC
    You can't put a print in the middle of a here document. You should assign the value to a variable first,
    $latmod=localtime((stat(/cgi-bin/dir/lastmodif.pl))[9]); print header, <<"EOF" ... <br>Last Modified: $lastmod</td> ...

      Not a print, but you can interpolate an arbitrary expression:

      print header, <<"EOF" ... <br/>Last Modified: @{[ scalar localtime( (stat( ".../blah" ))[9] ) ]} </td> ... EOF