in reply to help with my unlink
As you can see, there is nothing happening with the file at the moment. It just opens and closes it.open(THING, "$Form{'han'}.txt"); #so far, you have nothing here #code some stuff to deal with the file close(THING); unlink "$Form{'han'}.txt" or die "Couldn't delete $Form{'han'}.txt: $! +";
Cheers!
Update:
Ah, abstracts beat me to it and I see what he means.
You wish to read in filenames from the file and unlink those.
In that case, yes, do as abstracts says :) (or see below)
Update #2:
I couldn't let it go!
Here is another snippet that does the same thing as abstracts:
I wrapped the whole thing in a block { } to localize the 'undef'ing of the input buffering variable ($/).{ open NAMES, "$Form{han}.txt" or die "Oh my. File open failed: $!\n"; $/=undef; for (split("\n", <NAMES>)) { unlink or die "Couldn't delete $_: $!\n"; + } close NAMES; #Delete the file if you want to... unlink "$Form{han}.txt" or die "Couldn't delete the data file: $!\n"; }
Update 3:
Lol, still have one last thought on this idea.
If you only have ONE filename in the .txt file, then your code is almost right enough.
You'd just need to put the close() statement before the unlink one.
That would give you the following:
That would be simple enough!open(THING, "$Form{'han'}.txt"); unlink <THING>; close(THING); unlink "$Form{'han'}.txt" or die "Couldn't delete $Form{'han'}.txt: $! +";
|
|---|