[30083] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1326 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 2 09:09:42 2008

Date: Sun, 2 Mar 2008 06:09:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 2 Mar 2008     Volume: 11 Number: 1326

Today's topics:
    Re: Converting "&#x2019;" to an Apostrophe? <noreply@gunnar.cc>
        killing the children <lekonna@gmail.com>
        new CPAN modules on Sun Mar  2 2008 (Randal Schwartz)
    Re: Parsing multi-line text <noreply@gunnar.cc>
    Re: Parsing multi-line text <hjp-usenet2@hjp.at>
    Re: Regular Expression to Replace UPPER Case Text with  <hjp-usenet2@hjp.at>
        unsetenv in the shell <smcbutler@gmail.com>
    Re: unsetenv in the shell <thepoet_nospam@arcor.de>
    Re: unsetenv in the shell <klaus03@gmail.com>
    Re: unsetenv in the shell <hjp-usenet2@hjp.at>
    Re: unsetenv in the shell <jurgenex@hotmail.com>
    Re: unsetenv in the shell <jurgenex@hotmail.com>
    Re: use CGI::Carp qw(fatalsToBrowser) not sending file  <noreply@gunnar.cc>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 02 Mar 2008 10:50:31 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Converting "&#x2019;" to an Apostrophe?
Message-Id: <62vbniF23uf7cU2@mid.individual.net>

Ilya Zakharevich wrote:
> [A complimentary Cc of this posting was sent to
> Gunnar Hjalmarsson 
> <noreply@gunnar.cc>], who wrote in article <62pdc2F24jiheU1@mid.individual.net>:
>> A. Sinan Unur wrote:
>>> In the mean time, here in 2008, in the docs shipped with Perl 5.10
>>>
>>> perldoc perlop
>>>
>>>    s   Treat string as single line. (Make . match a newline)
>> Great, that's a clarification I wasn't aware of.
> 
> In which way it is a clarification?

Compared to the previous perlop versions, where the part within 
parentheses was not there.

> IMO, the semantic of these "( )"
> is clear ONLY if you know the answer already...  :-(  [I.e., how would
> one guess that what is in () is the ONLY effect?]

I see you point, and I agree it could be better. The best solution IMO 
would be that the explanations of /s and /m in perlre were repeated in 
perlop. The next best solution would be that perlop's 'short form 
explanations' were dropped and _replaced_ with references to perlre.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Sun, 2 Mar 2008 05:27:19 -0800 (PST)
From: lekonna <lekonna@gmail.com>
Subject: killing the children
Message-Id: <a870a637-b4db-497f-b47f-62a15a7aaab7@i29g2000prf.googlegroups.com>

Hi guys,

i'm having a bit of a problem here with the exec functionality. I seem
to be unable to kill the children of my process. Hope you can help me
with this one.

I'm doing a client-server setup where the server requests the clients
to start instances of a certain application and now the bugger doesn't
seem to die properly. The code in nutshell is here, i'll eliminate my
crappy message handling and just quote the handler funcs:

<start block>
$pid = fork;
if ( $pid == 0 )
{
  exec( $my_command,$my_args) or die "can't do it Jim!";
} else {
$jobs{$pid} = $my_args;
}
</start block>

<kill block>
foreach ( keys( $jobs ) )
{
  kill 9,$_;
}
delete %jobs;
</kill block>

What happens is that the exec starts the program properly and returns
a pid. the kill however seems to be unable
to do anything to the program that is executed, it just keeps
running.

Am i actually execing a command shell instance that then starts the
program as child and my kill hangs there?

At the moment coding in Win32 environment but the code should port to
linux/osX as well.

Br,
Lekonna


------------------------------

Date: Sun, 2 Mar 2008 05:42:17 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Mar  2 2008
Message-Id: <Jx396H.1q7s@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Apache2-AuthenOpenID-0.05
http://search.cpan.org/~danjou/Apache2-AuthenOpenID-0.05/
OpenID authen hander for mod_perl2. 
----
Bit-MorseSignals-0.01
http://search.cpan.org/~vpit/Bit-MorseSignals-0.01/
The MorseSignals protocol. 
----
Bit-MorseSignals-0.02
http://search.cpan.org/~vpit/Bit-MorseSignals-0.02/
The MorseSignals protocol. 
----
Blog-Normalize-0.0rc2
http://search.cpan.org/~damog/Blog-Normalize-0.0rc2/
Specification for a sane transition between different blogging systems 
----
Catalyst-Plugin-RedirectAndDetach-0.01
http://search.cpan.org/~drolsky/Catalyst-Plugin-RedirectAndDetach-0.01/
Redirect and detach at the same time 
----
Catalyst-Plugin-RedirectAndDetach-0.02
http://search.cpan.org/~drolsky/Catalyst-Plugin-RedirectAndDetach-0.02/
Redirect and detach at the same time 
----
Class-Inspector-1.22
http://search.cpan.org/~adamk/Class-Inspector-1.22/
Get information about a class and its structure 
----
DBD-Pg-2.2.1
http://search.cpan.org/~turnstep/DBD-Pg-2.2.1/
PostgreSQL database driver for the DBI module 
----
DBIx-Class-0.08010
http://search.cpan.org/~ash/DBIx-Class-0.08010/
Extensible and flexible object <-> relational mapper. 
----
DBIx-Connect-FromConfig-0.03
http://search.cpan.org/~saper/DBIx-Connect-FromConfig-0.03/
Creates a DB connection from a configuration file 
----
Devel-Fail-MakefilePL-1.012
http://search.cpan.org/~mthurn/Devel-Fail-MakefilePL-1.012/
a distro that always fails the `perl Makefile.PL` stage 
----
Devel-Hook-0.002
http://search.cpan.org/~ferreira/Devel-Hook-0.002/
Mess around with BEGIN/CHECK/INIT/END blocks 
----
Devel-Hook-0.003
http://search.cpan.org/~ferreira/Devel-Hook-0.003/
Mess around with BEGIN/CHECK/INIT/END blocks 
----
Devel-Leak-Module-0.01_04
http://search.cpan.org/~adamk/Devel-Leak-Module-0.01_04/
Track loaded modules and namespaces 
----
ExtUtils-Install-1.46
http://search.cpan.org/~yves/ExtUtils-Install-1.46/
install files from here to there 
----
File-Flat-1.03
http://search.cpan.org/~adamk/File-Flat-1.03/
Implements a flat filesystem 
----
GRID-Machine-0.084
http://search.cpan.org/~casiano/GRID-Machine-0.084/
Remote Procedure Calls over a SSH link 
----
HTML-FillInForm-Lite-0.09
http://search.cpan.org/~gfuji/HTML-FillInForm-Lite-0.09/
Fills in HTML forms with data 
----
HTML-FillInForm-Lite-0.10
http://search.cpan.org/~gfuji/HTML-FillInForm-Lite-0.10/
Fills in HTML forms with data 
----
HTML-Normalize-1.0003
http://search.cpan.org/~grandpa/HTML-Normalize-1.0003/
HTML light weight cleanup 
----
HTML-Tagset-3.20
http://search.cpan.org/~petdance/HTML-Tagset-3.20/
data tables useful in parsing HTML 
----
HTML-Template-Pro-0.69
http://search.cpan.org/~viy/HTML-Template-Pro-0.69/
Perl/XS module to use HTML Templates from CGI scripts 
----
Handel-1.00010
http://search.cpan.org/~claco/Handel-1.00010/
A cart/order/checkout framework with AxKit/TT/Catalyst support 
----
KSx-Search-WildCardQuery-0.01
http://search.cpan.org/~sprout/KSx-Search-WildCardQuery-0.01/
Wild card query class for KinoSearch 
----
Language-MuldisD-0.22.1
http://search.cpan.org/~duncand/Language-MuldisD-0.22.1/
Formal spec of Muldis D relational DBMS lang 
----
Lingua-ZH-ZhuYin-0.04
http://search.cpan.org/~clsung/Lingua-ZH-ZhuYin-0.04/
The great new Lingua::ZH::ZhuYin! 
----
Mac-Pasteboard-0.001
http://search.cpan.org/~wyant/Mac-Pasteboard-0.001/
Manipulate Mac OS X clipboards/pasteboards. 
----
Math-MatrixReal-2.05
http://search.cpan.org/~leto/Math-MatrixReal-2.05/
Matrix of Reals 
----
Math-ODE-0.04
http://search.cpan.org/~leto/Math-ODE-0.04/
Solve N-th Order Ordinary Differential Equations 
----
Module-Pragma-0.02
http://search.cpan.org/~gfuji/Module-Pragma-0.02/
Support for implementation of pragmas 
----
Net-Amazon-S3-0.43
http://search.cpan.org/~lbrocard/Net-Amazon-S3-0.43/
Use the Amazon S3 - Simple Storage Service 
----
Net-DNS-SEC-Validator-1.20
http://search.cpan.org/~gsm/Net-DNS-SEC-Validator-1.20/
interface to libval(3) and related constants, structures and functions. 
----
Net-OBEX-Packet-Request-0.001
http://search.cpan.org/~zoffix/Net-OBEX-Packet-Request-0.001/
create OBEX protocol request packets. 
----
Net-OBEX-Packet-Request-0.002
http://search.cpan.org/~zoffix/Net-OBEX-Packet-Request-0.002/
create OBEX protocol request packets. 
----
Osgood-Server-1.0.4
http://search.cpan.org/~gphat/Osgood-Server-1.0.4/
Catalyst based application 
----
POE-Component-DBIx-MyServer-0.01_03
http://search.cpan.org/~eriam/POE-Component-DBIx-MyServer-0.01_03/
A pseudo mysql POE server 
----
POE-Component-DBIx-MyServer-0.01_04
http://search.cpan.org/~eriam/POE-Component-DBIx-MyServer-0.01_04/
A pseudo mysql POE server 
----
Perl6-Doc-0.35_2
http://search.cpan.org/~lichtkind/Perl6-Doc-0.35_2/
all useful Perl 6 Docs in your command line 
----
R-Writer-0.00001
http://search.cpan.org/~dmaki/R-Writer-0.00001/
Generate R Scripts From Perl 
----
Test-Count-0.0105
http://search.cpan.org/~shlomif/Test-Count-0.0105/
Module for keeping track of the number of tests in a Test Script. 
----
Test-Tester-0.107
http://search.cpan.org/~fdaly/Test-Tester-0.107/
Ease testing test modules built with Test::Builder 
----
Text-CSV_XS-0.35
http://search.cpan.org/~hmbrand/Text-CSV_XS-0.35/
comma-separated values manipulation routines 
----
WWW-CPAN-0.010
http://search.cpan.org/~ferreira/WWW-CPAN-0.010/
CPAN as a web service 
----
WWW-CPAN-0.011
http://search.cpan.org/~ferreira/WWW-CPAN-0.011/
CPAN as a web service 
----
WWW-ImagebinCa-Create-0.02
http://search.cpan.org/~zoffix/WWW-ImagebinCa-Create-0.02/
"paste" images to <http://imagebin.ca> from Perl. 
----
WWW-Tumblr-0
http://search.cpan.org/~damog/WWW-Tumblr-0/
----
Win32-API-0.51
http://search.cpan.org/~cosimo/Win32-API-0.51/
Perl Win32 API Import Facility 
----
Win32-API-0.52
http://search.cpan.org/~cosimo/Win32-API-0.52/
Perl Win32 API Import Facility 
----
Win32-API-0.53
http://search.cpan.org/~cosimo/Win32-API-0.53/
Perl Win32 API Import Facility 
----
XPanel-0.0.1
http://search.cpan.org/~xpanel/XPanel-0.0.1/
Perl extension to XPanel servers 
----
rpm-build-perl-0.6.7
http://search.cpan.org/~atourbin/rpm-build-perl-0.6.7/


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Sun, 02 Mar 2008 10:50:27 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Parsing multi-line text
Message-Id: <62vbneF23uf7cU1@mid.individual.net>

Peter J. Holzer wrote:
> On 2008-02-18 11:18, Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>> keith@bytebrothers.co.uk wrote:
>>> I have a data file structured something like this:
>>>
>>> ------------------8<-----------------------
>>> Chunk 01
>>> 	NAME: "Alice"
>>> 	Description: "Some other string"
>>> 	Age: 37
>>> Chunk 02
>>> 	NAME: "Bob"
>>> 	Description: "Some other string"
> 
> change this line to
> 
> 	Description: "Some Chunky string"
> 
>>> 	Age: 28
> ...
>>> ------------------8<-----------------------
>>      local $/ = 'Chunk';
>>      while (<>) {
>>          if ( /(\d+).+[A-Z]+:\s+"([^"]*)".+Age:\s+(\d+)/s ) {
>>              printf "%02d NAME: %-10s -> %d\n", $1, $2, $3;
>>          }
>>      }
> 
> and then run this script again.

Well, what's the likelihood that that would happen? At least the OP 
didn't object to the idea with 'Chunk' as record separator.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Sun, 2 Mar 2008 14:43:50 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Parsing multi-line text
Message-Id: <slrnfslbon.39d.hjp-usenet2@hrunkner.hjp.at>

On 2008-03-02 09:50, Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Peter J. Holzer wrote:
>> On 2008-02-18 11:18, Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>>> keith@bytebrothers.co.uk wrote:
>>>> I have a data file structured something like this:
>>>>
>>>> ------------------8<-----------------------
>>>> Chunk 01
>>>> 	NAME: "Alice"
>>>> 	Description: "Some other string"
>>>> 	Age: 37
>>>> Chunk 02
>>>> 	NAME: "Bob"
>>>> 	Description: "Some other string"
>> 
>> change this line to
>> 
>> 	Description: "Some Chunky string"
>> 
>>>> 	Age: 28
>> ...
>>>> ------------------8<-----------------------
>>>      local $/ = 'Chunk';
>>>      while (<>) {
>>>          if ( /(\d+).+[A-Z]+:\s+"([^"]*)".+Age:\s+(\d+)/s ) {
>>>              printf "%02d NAME: %-10s -> %d\n", $1, $2, $3;
>>>          }
>>>      }
>> 
>> and then run this script again.
>
> Well, what's the likelihood that that would happen?

How would I know? The OP didn't say much about the contents of the
fields. But I'd say it is non-zero. "Chunk" is an English word which
might occur in a description, and it might even be the first 5
characters of a name. Finally, we don't know where data comes from -
somebody might deliberately try to sabotage the script.

> At least the OP didn't object to the idea with 'Chunk' as record
> separator.

I was under the impression that he was glad to understand your solution
at all and wasn't trying to find flaws in it. Far too few people think
about the edge-cases of possible input.

A word of warning about the solution I posted in a different message: It
doesn't handle embedded quotes - that would be quite easy to add, but
there are different systems of escaping quotes and one would need to
know which one to use - the OP didn't tell us.

	hp



------------------------------

Date: Sun, 2 Mar 2008 12:14:22 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Regular Expression to Replace UPPER Case Text with lower case text
Message-Id: <slrnfsl30g.39d.hjp-usenet2@hrunkner.hjp.at>

On 2008-03-01 23:01, John W. Krahn <someone@example.com> wrote:
> Joost Diepenmaat wrote:
>> "Peter J. Holzer" <hjp-usenet2@hjp.at> writes:
>>> Maybe not, but \L works in perl also (reading this thread (yes, I'm a
>>> bit behind ...) I was astounded that nobody came up with this).
>> 
>> That's because you don't need to use a regex if you're going to use \L.
>> In fact \L isn't valid in a regex (only in the replacement string of a
>> regex replace operator)
>
> While technically true, \L is not a valid regular expression escape 
> sequence, it is valid in that the m// and s/// operators which use 
> regular expressions are evaluated as double quoted strings so \L is 
> valid in that context.

More importantly, the OP only asked about a "Regular Expression" because
he didn't understand the concept. A regular expression can never replace
anything, it can only match something. What he wanted was a
substitution. So

s/.*/\L$&/s;

or

s/(.*)/\L$1/s;

fit the question (that misconception is frequent enough that I think
everybody in this newsgroup is familiar with it). The OP also wrote that
he wasn't actually using perl but some software which uses PCRE. Of
course he might have said that only after most of the answers and even
if he had said it in his very first posting, by asking in a perl group
he must be prepared to get perl answers, not PCRE answers.

	hp




------------------------------

Date: Sun, 2 Mar 2008 01:00:33 -0800 (PST)
From: Si <smcbutler@gmail.com>
Subject: unsetenv in the shell
Message-Id: <ad1b9ca3-3a06-480a-8eca-44333ff36aee@s12g2000prg.googlegroups.com>


hi, i have a perl program that calls another application. this second
application uses the value of certain environment variables during its
operation. i'm having trouble with unsetting those variables during
the course of the perl script.

my (wrong) pseudo code:

$var1 = $ENV{'VAR1};
$var2 = $ENV{'VAR2'};
$var3 = $ENV{'VAR3'};

system( "unsetenv VAR1");
system( "unsetenv VAR2");
system( "unsetenv VAR3");

run_the_external_app;

system( "setenv VAR1 $var1");
system( "setenv VAR2 $var2");
system( "setenv VAR3 $var3");


can someone tell me what the correct syntax should be for this?


------------------------------

Date: Sun, 02 Mar 2008 10:21:55 +0100
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: unsetenv in the shell
Message-Id: <47ca7040$0$11010$9b4e6d93@newsspool4.arcor-online.net>

Si wrote:
> hi, i have a perl program that calls another application. this second
> application uses the value of certain environment variables during its
> operation. i'm having trouble with unsetting those variables during
> the course of the perl script.
> 
> my (wrong) pseudo code:
> 
> $var1 = $ENV{'VAR1};
> $var2 = $ENV{'VAR2'};
> $var3 = $ENV{'VAR3'};
> 
> system( "unsetenv VAR1");
> system( "unsetenv VAR2");
> system( "unsetenv VAR3");
> 
> run_the_external_app;
> 
> system( "setenv VAR1 $var1");
> system( "setenv VAR2 $var2");
> system( "setenv VAR3 $var3");

Calling setenv/unsetenv via system doesn't work, because it
first forks of a child shell. Modifications there don't,
of course, propagate up to the parent environment.

Luckily, you can directly modify the %ENV hash, as
"perldoc perlvar" explains:
----------------------------- snip ----------------------------
  %ENV
  $ENV{expr}
    The hash %ENV contains your current environment. Setting a value
    in "ENV" changes the environment for any child processes you
    subsequently fork() off.
----------------------------- snap ----------------------------

So doing "my $var1 = delete $ENV{'VAR1'};" before calling the
external app and assigning "$ENV{'VAR1'} = $var1;" afterwards
will do the trick.

-Chris


------------------------------

Date: Sun, 2 Mar 2008 01:36:00 -0800 (PST)
From: Klaus <klaus03@gmail.com>
Subject: Re: unsetenv in the shell
Message-Id: <97e7581f-9731-4d95-95a0-9cd9bc543aa5@x30g2000hsd.googlegroups.com>

On Mar 2, 10:00 am, Si <smcbut...@gmail.com> wrote:
> hi, i have a perl program that calls another application. this second
> application uses the value of certain environment variables during its
> operation. i'm having trouble with unsetting those variables during
> the course of the perl script.
>
> $var1 = $ENV{'VAR1};
> $var2 = $ENV{'VAR2'};
> $var3 = $ENV{'VAR3'};
>
> system( "unsetenv VAR1");
> system( "unsetenv VAR2");
> system( "unsetenv VAR3");
>
> run_the_external_app;

Environment variables will be restored to their original state after a
system call, therefore whatever system("unsetenv...") (or any other
system() call for that matter) does to the environment variables has
no effect whatsoever on the environment variables of the running perl
program, this includes the effect on any subsequent actions in the
running perl program, such as "run_the_external_app;"

However, if you are running under Unix, perlfaq 8 might be helpful:

+++++++++++++++++++++++++++++++++++++++++++
++ perlfaq 8:
++ ----------
++ "I {changed directory, modified my environment} in a
++ perl script. How come the change disappeared when I
++ exited the script? How do I get my changes to be
++ visible?"
++
++ Unix: In the strictest sense, it can't be done--the script
++ executes as a different process from the shell it was
++ started from. Changes to a process are not reflected in
++ its parent--only in any children created after the change.
++ There is shell magic that may allow you to fake it by
++ eval()ing the script's output in your shell; check out the
++ comp.unix.questions FAQ for details.
+++++++++++++++++++++++++++++++++++++++++++

--
Klaus


------------------------------

Date: Sun, 2 Mar 2008 12:32:02 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: unsetenv in the shell
Message-Id: <slrnfsl41k.39d.hjp-usenet2@hrunkner.hjp.at>

On 2008-03-02 09:36, Klaus <klaus03@gmail.com> wrote:
> On Mar 2, 10:00 am, Si <smcbut...@gmail.com> wrote:
>> hi, i have a perl program that calls another application. this second
>> application uses the value of certain environment variables during its
>> operation. i'm having trouble with unsetting those variables during
>> the course of the perl script.
>>
>> $var1 = $ENV{'VAR1};
>> $var2 = $ENV{'VAR2'};
>> $var3 = $ENV{'VAR3'};
>>
>> system( "unsetenv VAR1");
>> system( "unsetenv VAR2");
>> system( "unsetenv VAR3");
>>
>> run_the_external_app;
>
> Environment variables will be restored to their original state after a
> system call,

That's wrong. The variables will not be restored after the call, they
never change. 

system( "unsetenv VAR1");
starts a second process which then tries to execute the "unsetenv"
program, which probably doesn't exist ("unsetenv" is a builtin command
of the csh). But even if program was a shell which could unset
environment variables (try system("unset VAR1;");) it would only unset
it's own copy of the variable, never the variable of the perl process.

	hp


------------------------------

Date: Sun, 02 Mar 2008 12:04:35 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: unsetenv in the shell
Message-Id: <aq5ls3h50qe1ckegbkud7m8c7v37l2mmmp@4ax.com>

Si <smcbutler@gmail.com> wrote:
>
>hi, i have a perl program that calls another application. this second
>application uses the value of certain environment variables during its
>operation. i'm having trouble with unsetting those variables during
>the course of the perl script.
>
>my (wrong) pseudo code:
>
>$var1 = $ENV{'VAR1};
>$var2 = $ENV{'VAR2'};
>$var3 = $ENV{'VAR3'};
>
>system( "unsetenv VAR1");
>system( "unsetenv VAR2");
>system( "unsetenv VAR3");

"Unsetting" an environment variable is in no way different from setting it.
Your case is a variation of the FAQs:
  I {changed directory, modified my environment} in a perl script.  How come
the change disappeared when I exited the script?  How do I get my changes to
be visible?

Just do those changes in the script itself instead of in a child process
(perldoc -f delete)

jue


------------------------------

Date: Sun, 02 Mar 2008 12:06:14 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: unsetenv in the shell
Message-Id: <836ls394qf8jbt8o9419nr6lupfc7592nn@4ax.com>

Klaus <klaus03@gmail.com> wrote:
>On Mar 2, 10:00 am, Si <smcbut...@gmail.com> wrote:
>> system( "unsetenv VAR1");
>
>Environment variables will be restored to their original state after a
>system call, 

Actually they are never modified for the parent process in the first place.

jue


------------------------------

Date: Sun, 02 Mar 2008 11:17:59 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: use CGI::Carp qw(fatalsToBrowser) not sending file handle errors to    browser
Message-Id: <62vdb2F251kp9U1@mid.individual.net>

Bennett Haselton wrote:
> I wrote the following script to test whether, if I try writing to an
> invalid filehandle, the error message would get sent to the browser:
> 
> #!/usr/bin/perl
> 
> use strict;
> use IO::File;
> use CGI::Carp qw(fatalsToBrowser);
> 
> print "Content-type: text/html\n\n";
> 
> # This will not open a valid filehandle since the script runs as
> nobody
> my $fh = IO::File->new("> doesnotexist.txt");
> print $fh "foo";
> 
> die "Die here, if you get this far";
> 
> The line 'print $fh "foo";' does generate an error, however that error
> gets written to /var/log/httpd/error_log where it says "Can't use an
> undefined value as a symbol reference at /var/www/html/carptest/open-
> wrong-file-with-carp-fatalstobrowser.cgi line 11".  I want that sent
> to the *browser*, not written to the log file.  The line 'die "Die
> here, if you get this far";' never gets executed.

As Xho indicated, you may be using a buggy version of CGI::Carp, so it 
could be worth trying to upgrade. The usual check of the return value, 
when doing IO operations, may be another solution:

     my $fh = IO::File->new("> doesnotexist.txt")
       or die "Filehandle creation failed: $!";

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1326
***************************************


home help back first fref pref prev next nref lref last post