Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Follow up to RFC: Templating without a System (required)

by tye (Sage)
on Jul 01, 2006 at 15:48 UTC ( [id://558774]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Follow up to RFC: Templating without a System (required)
in thread Follow up to RFC: Templating without a System

So, not only are you using an undocumented feature of require, but you are also using it in a manner contrary to its purpose. In a code review, I'd reject such use unless you documented and enforced your unusual requirements. That is, you should check %INC before requireing so you can report that the file got required already (and include a comment about why that matters and that the feature of require that you are depending on is not documented).

Even better, Perl already has a tool that does what you are using require for: do $file. Use that instead.

- tye        

  • Comment on Re^3: Follow up to RFC: Templating without a System (required)

Replies are listed 'Best First'.
Re^4: Follow up to RFC: Templating without a System (required)
by shmem (Chancellor) on Jul 03, 2006 at 09:53 UTC
    Right, I'll use do. It just does what I want.

    I have to use require for the same reasons AutoLoader uses require and not just do FILE. do FILE, when wrapped in a string eval

    my $sub = eval "package $package; do '$file'";
    doesn't set $@ outside the eval. require dies, do does not. $sub is just undef, nothing more, and all I can do is mumble "something went wrong while 'do $file' at line $foo" which ain't any good.

    I need require; requiring a file twice happens only at development time (or if you do funny things like generating template source on the fly and ask for trouble unless you know what you're doing); it provides for re-compiling on the fly and shortens turnaround time.

    I'll include an argument to the package's import() function - recompile_on_change - which will enable such behaviour, and note the implications prominently in the code and in the pod.

    Does that stand to your scrutiny?

    thanks for the hint again,

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://558774]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-19 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found