PrePAN

Sign in to PrePAN

Sudo::Lexical Lexcically scope code with elevated permissions

Author
torbjorn@github
Date
URL
Status
In Review
Good

Synopsis

use Sudo::Lexical
use Path::Tiny;

SUDO {
    my @roots_files = path("~root/")->children;
 }

Description

Lexically scope elevated code, as the example shows. This will most likely mean invoking the system's sudo in one way or another. Typically a password prompt. With a fatal error if it fails.

I don't see 100% how to pull this off, localizing $> most likely, and invoking system's sudo to do so.

EDIT: Changed it from a label (SUDO:) to a sub SUDO (&)

Comments

Please sign up to post a review.