Hi Gaal,

On Tuesday 08 Feb 2011 12:19:01 Gaal Yahas wrote:
> I suppose you can use a functional idiom to encapsulate this.
> 
> # not tested
> sub with_path($&) {
>   my($new_path, $code) = @_;
>   local $ENV{PATH} = $new_path;
>   $code->();
> }
> 
> {
>   # ...
>   with_path((join $path_sep, $ENV{PATH}, $some_dir), {
>     # Code to run with modified path
>   });
> }
> 

My problem with my two snippets was not in the call to local, but with the 
fact that $ENV{PATH} is mentioned twice there, which is also the case in your 
snippet (which is also kidna wordy and cluttered, at least if done only 
once.). 

The general paradigm you are describing can still be considered a valid 
approach, and I've seen it used in several CPAN APIs such as DBIx-Class and 
KiokuDB . But see what I wrote about it here:

http://community.livejournal.com/shlomif_tech/49156.html

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
"The Human Hacking Field Guide" - http://shlom.in/hhfg

Chuck Norris can make the statement "This statement is false" a true one.

Please reply to list if it's a mailing list post - http://shlom.in/reply .
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl

Reply via email to