<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>This kind of task is perfect for the module “Path::Tiny”</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>It has all of the functionality you’re talking about except the date stuff, and for that I’d probably choose Time::Piece because it’s shipped with core perl and can do date formatting easily. (See perldoc Time::Piece for all the details.) Path::Tiny *<b>should</b>* be in core Perl IMO but it’s a quick and dependency free download.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>use 5.014;</p><p class=MsoNormal>use Path::Tiny;</p><p class=MsoNormal>use Time::Piece;</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>my $t = localtime; # Time::Piece object</p><p class=MsoNormal>say “$t”; # Fri Jun  8 01:25:46 2018</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>my $dir = path(“.”);</p><p class=MsoNormal>for my $f ( $dir->children() ) {</p><p class=MsoNormal>   $f->spew_utf8(“project xyz\n$t\n”)</p><p class=MsoNormal>}</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">Mail</a> for Windows 10</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='border:none;padding:0in'><b>From: </b><a href="mailto:rlharris@oplink.net">rlharris@oplink.net</a><br><b>Sent: </b>Thursday, June 7, 2018 11:58 PM<br><b>To: </b><a href="mailto:houston@pm.org">Houston Perl Mongers</a><br><b>Subject: </b>[pm-h] write to empty files</p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>My need is to write a string to each file in a directory (the same string,</p><p class=MsoNormal>such as, "project xyz", needs to be written to each file).  The files have</p><p class=MsoNormal>been created with "touch", run from a bash script; so the file length is</p><p class=MsoNormal>zero.  My system is Debian.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The operation "s//project xyz/" fails on a file of zero length. My Perl</p><p class=MsoNormal>skills are rusty, and I have spent more than an hour searching the web</p><p class=MsoNormal>without success, looking for a solution.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Even more useful to me would be the ability to write to each file in a</p><p class=MsoNormal>directory a string or a set of lines which include the current date and</p><p class=MsoNormal>the filename or the full filepath:</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>    project xyz</p><p class=MsoNormal>    documentname.tex</p><p class=MsoNormal>    2018.06.07 1950gmt</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>    project xyz</p><p class=MsoNormal>    /home/rlh/scratch/documentname.tex</p><p class=MsoNormal>    2018.06.07 1950gmt</p><p class=MsoNormal>_______________________________________________</p><p class=MsoNormal>Houston mailing list</p><p class=MsoNormal>Houston@pm.org</p><p class=MsoNormal>http://mail.pm.org/mailman/listinfo/houston</p><p class=MsoNormal>Website: http://houston.pm.org/</p><p class=MsoNormal><o:p> </o:p></p></div></body></html>