On 08 Feb 2011 12:19:01 +0200, 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
>   });
> }

You can even stress the perl syntax like this:

sub with_added_path (&@) { ... }

with_added_path { "some perl code" } '/new/opt/bin', '/another/bin';

Regards,
Mikhael.

-- 
perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl

Reply via email to