I was putting an error message wrapper around some file operations like rename and link to get the error handling
'out of band' -- not have it inline w/the code so it obscured the flow of the code. Created a small wrapper:
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":
sub sched_unlink($$) { fileop(['unlink', $_[0]], "from inode ".$_[1])
+ }
But had this coming out from perl:
&CORE::unlink cannot be called directly at <file> line <#>
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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.