perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:
sub fileop($;$) { my ($op, @argv)=@{my $_=shift}; use Carp qw(cluck); no strict 'refs'; &{"CORE::".$op}(@argv) || do { cluck (P "ERROR: $! doing %s(%s): (%s)%s", $op, (join ', ', @arg +v), $!, @_?" (extra info: ".$_[0].")":""); exit (0+$!) } } # can call this with: fileop(['rename', $from_name, $tmpnam]); fileop(['link', $name_of_to_node, $from_name]);
Went to do the same with "unlink":
But had this coming out from perl:sub sched_unlink($$) { fileop(['unlink', $_[0]], "from inode ".$_[1]) + }
Note, I had earlier, tried making such calls without the "CORE::" in front of them, but got errors about no such local routines being defined...so thought 'CORE::' was the way to go for perl built-ins...
Why the exceptions?... and do I just have to special case all the ones that give errors as they come up?
I didn't get from my last read of the docs that "unlink" was somehow radically different from "link"... Ideas?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: why "link", "rename", but no "unlink" in CORE::?
by Anonymous Monk on Feb 27, 2013 at 11:48 UTC | |
by perl-diddler (Chaplain) on Feb 27, 2013 at 20:26 UTC |