Re: remove function
by moritz (Cardinal) on Jan 29, 2009 at 13:55 UTC
|
What should it remove? Hash items can be deleted, files can be unlinked, and scalars can be undefed. | [reply] |
|
| [reply] |
Re: remove function
by Corion (Patriarch) on Jan 29, 2009 at 13:56 UTC
|
Because we don't know what you mean. Maybe you want the unlink function? Or the delete function? Or maybe the undef keyword/function/value?
If you can't find it yourself, maybe you can describe to us what kind of function you are searching for.
| [reply] |
Re: remove function
by Bloodnok (Vicar) on Jan 29, 2009 at 14:02 UTC
|
| [reply] |
Re: remove function
by borisz (Canon) on Jan 29, 2009 at 14:01 UTC
|
Because perl do not need another name for an already existing function.
| [reply] |
Re: remove function
by BrowserUk (Patriarch) on Jan 29, 2009 at 14:01 UTC
|
sub remove {
my $path = shift;
if( -f $path ) { unlink $path; }
elsif( -d $path ) { rmdir $path }
else{ die "Dunno what to do with $path?" }
}
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |
A reply falls below the community's threshold of quality. You may see it by logging in. |
Re: remove function
by cdarke (Prior) on Jan 29, 2009 at 15:41 UTC
|
At an attempt to take your question seriously, you probably mean the remove program as used by cmd.exe on Microsoft Windows. I suspect that your experience is limited to just that one operating system and just that one shell (cmd.exe, that is). Other operating systems and environments have other names for that. unlink is the name of the UNIX kernel function to delete a file, it is called DeleteFile by the Windows kernel, but 'remove' at the Windows command line and 'rm' at the UNIX command line. I have no idea what it is called on MAC, IBM Mainframe, VMS, or mumble-mumble.
So, whatever Perl had called it, someone would have complained that it was not the same as they are used to.
Update: OK, I'm wrong again, the remove function is part of the ISO C library not cmd.exe, and Mr. Google tells me it is used in other places, like DB2, but I think my point still stands. | [reply] |
|
| [reply] [d/l] [select] |
Re: remove function
by leocharre (Priest) on Jan 29, 2009 at 21:14 UTC
|
Just because a language does not have a function of the name you are seeking, it does not mean that you can't do what you want to do- just as easily.
Different (programming) languages have different names for functions, because the people who created the languages- were different people, who had their own idea of what the 'remove' function should be named.
You're invited to read about perl and find what you are seeking. You can also search for something like 'remove' on that site.
| [reply] |
Re: remove function
by swampyankee (Parson) on Jan 30, 2009 at 00:11 UTC
|
You mean "Why doesn't Perl have a function named 'remove'?" Because it doesn't. This is exactly the same reason why Perl doesn't have a function named "insert." It may be obvious to you what a remove function would do, but it does beg the question "remove what?" A lot of functions that interact with the file system are derived from Unix system calls, and unlink is one of them.
Incidentally, your node title is not terribly informative. It could easily mean "what is the remove function," "how does one remove a function," or "where is the function named remove?" Indeed, my first interpretation was the second, whereas your meaning seems to be closer to the third.
Information about American English usage here and here. Floating point issues? Please read this before posting. — emc
| [reply] |