|Do you know where your variables are?|
TIMTOWTDI Challenge: Create a filenameby Tanktalus (Canon)
|on Jan 08, 2009 at 20:31 UTC||Need Help??|
In this, the second in a series of challenges (see the first such challenge), the goal is to explore the language in ways to create a filename. Inspired by a brief conversation on the CB where thezip suggested the mundane "sprintf is your friend," I'm looking for any and all ways to create a filename.
As in the previous challenge, the wording is deliberately vague. You can take this to mean anything you want, as long as the end result is the name of a file. The file may exist, or it may not exist, or its existence may be indeterminate. The choice is up to you.
Entries need not be serious - they can be exploratory (as davido pointed out last time, exporing the corners of the language is sometimes valuable), but pros and cons should be listed. Sometimes an off-beat approach is just what is needed, and knowing the pros and cons of an approach is vital in such evaluation. And, in the context of this challenge, it proves you know what you're doing rather than just copying and pasting it :-)
As to some examples:
Straight-forward, though there's a bit more work to get natural numbers for year and month. strftime would probably be better here.
pro: we're preparing this for open, so what could be more natural than using open for that? :-)
con: um, don't ever do this?
If you have some standard tools, even if wacky, esoteric, domain-specific, please share them. Or if you just are going for bonus points for obtuseness, please do. I managed to learn a lot from last time (including IO::All, the "cat $file |" trick for too-large-for-perl files, using Win32::OLE on Windows, though not necessarily in this order of usefulness ;-)), and I noticed others did as well, so don't be afraid to add your trick - you won't know who will find it helpful, even as an eye-opener, unless you do.