Do you know where your variables are? | |
PerlMonks |
Re^3: Better way of finding HTML tags positions in HTML string (updated)by haukex (Archbishop) |
on May 15, 2019 at 20:43 UTC ( [id://11100039]=note: print w/replies, xml ) | Need Help?? |
What's wrong with File::Temp? It's a core module, and it cleans up after itself pretty reliably:
And if you want to control the filename, you can do something like tempfile( TMPDIR=>1, TEMPLATE=>'.something_XXXXXXXXXX', SUFFIX => '.html', UNLINK=>1 ), or if you wanted to create the file in the same directory and based on the same name as some other file (File::Basename is also a core module):
I also like to use something like Corion's Text::CleanFragment on the above $fn, but that's not necessarily required. Update: Since I'm already dumping some File::Temp snippets, here's two more that use a temporary directory instead, allowing you to keep the original file name. File::Spec is also a core module. tempdir supports the same TEMPLATE, DIR, and TMPDIR arguments as above. Note that if you use only TEMPLATE with a relative name, the resulting filename will also be relative to the current working directory, which is IMO not good, so I'd strongly recommend using an additional TMPDIR=>1 or DIR argument.
In Section
Seekers of Perl Wisdom
|
|