[8408] in Perl-Users-Digest
Perl-Users Digest, Issue: 2024 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 4 19:07:25 1998
Date: Wed, 4 Mar 98 16:00:29 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 4 Mar 1998 Volume: 8 Number: 2024
Today's topics:
$1 ? <object01@cc.gatech.edu>
Re: $1 ? (Jim Allenspach)
Re: $1 ? <quentin@jihad.amd.com>
Re: A perl question <Sebastian_Probst@hp.com>
Re: A perl question <uri@sysarch.com>
Re: A specific regular expression... <quentin@jihad.amd.com>
Re: A specific regular expression... <fnord@panix.com>
Are perl $SIG{} handlers inherently unsafe? (Daniel Childers)
Re: Are perl $SIG{} handlers inherently unsafe? <tchrist@mox.perl.com>
Re: Arrays and using output of executed program as inpu <jdf@pobox.com>
building perl on hpux 10.20 with +O3 (Albert Lunde)
Re: Change Unix environment variable using Perl (Earl Hood)
Re: Change Unix environment variable using Perl <quentin@jihad.amd.com>
Re: Change Unix environment variable using Perl (Andrew M. Langmead)
Re: Change Unix environment variable using Perl <vallon@pearl.fi.bear.com>
Re: Debugging Perl and extensions (Perl gurus please he (Ilya Zakharevich)
Re: Example for use Win32::NetResource::AddConnection (Marc Haber)
How to build perl Additional Modules widsk1@hotmail.com
isn't perl clever: short-circuit logic kevin@cmhcsys.com
Re: maintaining state <jdf@pobox.com>
Multidimensional Hashes (Phivu C. Nguyen~)
Re: Multidimensional Hashes (Earl Hood)
Re: Need help to setup Perl win32 in IIS4 (Earl Hood)
Perl & Personal Web Server <adam@pacific-artists.demon.co.uk>
perl for win95? <brains@erols.com>
Re: Perl on MS Personal Web Server (Jim Michael)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 04 Mar 1998 15:37:04 -0600
From: Jeff Stewart <object01@cc.gatech.edu>
Subject: $1 ?
Message-Id: <34FDC980.135@cc.gatech.edu>
What are the read-only variables $1, $2, $3, etc.? How are they
populated?
--
Jeff S.
------------------------------
Date: 4 Mar 1998 17:01:10 -0600
From: jima@MCS.COM (Jim Allenspach)
Subject: Re: $1 ?
Message-Id: <6dkmfm$gig@Mercury.mcs.net>
Jeff Stewart <object01@cc.gatech.edu> writes:
>What are the read-only variables $1, $2, $3, etc.? How are they
>populated?
Did you check your local Perl documentation?[1] If not, you might
try taking a look at the perlvar section. (And then perlre, after that.)
All your answers will be questioned. Er. All questions will be answered.
Yeah, that.
jma
[1] Can't find your local Perl documentation? Go here!
http://www.perl.com/CPAN/doc/manual/html/pod/index.html
--
Jim Allenspach Laziness. Impatience. Hubris.
jima at mcs dot com
Chicago IL It's great to be a Perl programmer.
------------------------------
Date: 04 Mar 1998 17:17:24 -0600
From: Quentin Fennessy <quentin@jihad.amd.com>
Subject: Re: $1 ?
Message-Id: <ximen0i59mj.fsf@jihad.amd.com>
>>>>> "JS" == Jeff Stewart <object01@cc.gatech.edu> writes:
JS> What are the read-only variables $1, $2, $3, etc.? How are
JS> they populated?
Check out backreferences in perlre(1).
--
Quentin Fennessy AMD, Austin Texas
------------------------------
Date: Wed, 04 Mar 1998 14:29:36 -0600
From: Sebastian Probst <Sebastian_Probst@hp.com>
To: demarcao@sysadm.suny.edu
Subject: Re: A perl question
Message-Id: <34FDB9B0.5CE55DD0@hp.com>
$variable=~s/" "/%20/ge
should work.
Sebastian Probst
WLD Marketing
Hewlett Packard
---------------
demarcao@sysadm.suny.edu wrote:
>
> I have aproblem that I need some help on.
>
> I have a variable that I need to check for a space and replace the space with
> %20, Can anyone give me an example on how to do this??
>
> Thanks,
>
> Alex
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 04 Mar 1998 17:57:20 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: A perl question
Message-Id: <x7d8g2xdwv.fsf@sysarch.com>
Sebastian Probst <Sebastian_Probst@hp.com> writes:
> $variable=~s/" "/%20/ge
why the " " and the /e?
the quotes are not in the source string and the %20 is illegal if
executed.
the previous post about using the URI module is best. it works, and
handles all URI quoting problems, not just space.
(note: i didn't write the URI module, we just have the same name!)
if it is basic or common, it is probably in CPAN. look there for ALL
your answers.
uri
--
Uri Guttman SYStems ARCHitecture and Software Engineering
uri@sysarch.com Have Perl, Will Hack
http://www.sysarch.com (781) 643-7504 x*2 FAX: (781) 643-2710
Try the Best Search Engine on the Net --------> http://www.northernlight.com
------------------------------
Date: 04 Mar 1998 16:05:33 -0600
From: Quentin Fennessy <quentin@jihad.amd.com>
Subject: Re: A specific regular expression...
Message-Id: <ximhg5e5cya.fsf@jihad.amd.com>
>>>>> "JS" == Jeff Stewart <object01@cc.gatech.edu> writes:
JS> What does the following line evaluate to? Or, what does this
JS> change $target_dir to?
JS> $target_dir =~ /(.+)\/(.+)\/$/
JS> Is this regular expression looking to match
JS> something/something/ at the end of $dir? Does it populate $1?
JS> It's being used in an uploading script by Kevin Meltzer, and
JS> his comment beside it is "find out upper level"
You can check this out in the debugger:
$ perl -de 42
...
main::(-e:1): 42
DB<1> $target_dir = "/top/next/next/";
DB<2> print "yes" if $target_dir =~ /(.+)\/(.+)\/$/;
yes
DB<3> $target_dir = "/top/next/next/bottom";
DB<4> print "yes" if $target_dir =~ /(.+)\/(.+)\/$/;
This appears to return success if $target_dir has at least
two '/'s, with one at the end of the string. The slashes
must be separated by one or more characters.
This does not change $target_dir.
This may be more readable:
$target_dir =~ m|(.+)/(.+)/$|;
The regexp (.+)/(.+)/$ matches
(.+) one or more characters
/ slash
(.+) one or more characters
/$ slash at the end of record (usually line)
Unless the () parts will be reused it could be further simplified
to
.+/.+/$
Check our perlre(1) for more info.
--
Quentin Fennessy AMD, Austin Texas
------------------------------
Date: 4 Mar 1998 17:06:06 -0500
From: Cliff Heller <fnord@panix.com>
Subject: Re: A specific regular expression...
Message-Id: <upafb6az78.fsf@panix3.panix.com>
Jeff Stewart <object01@cc.gatech.edu> writes:
> What does the following line evaluate to? Or, what does this change
> $target_dir to?
>
> $target_dir =~ /(.+)\/(.+)\/$/
>
> Is this regular expression looking to match something/something/ at the
> end of $dir? Does it populate $1? It's being used in an uploading
> script by Kevin Meltzer, and his comment beside it is "find out upper
> level"
it doesn't change $target_dir because it is only a match operation, not a
substituation.
the / at the beginning and the end delimit the matching portion.
As a matter of style, it's noisy to use this notation when you are matching
literal / characters because they must then be escaped with \ as above.
IMHO, better to use a different delimiter, which only requires that you use
the 'm' operator explicitly.
hence:
$target_dir=~ m!(.+)/(.+)/$!
Now let's break it down.
(.+) at least one of any character (stored in $1)
/ a slash
(.+) at least one of any character
/ a slash
$ the end of a line.
So it looks like he's trying to pick out components of a directory name
that contains two slashes, at least one of them at the end.
At least that's what it looks like. It may not actually accomplish what
he's trying to do in all cases.
--
/ \ Left Reverend Nigh Invulnerable fnord@panix.com
/<0>\ Church of the Subverted Paradigm
/ \ God Plays Dice!
/_______\ --> FIVE TONS OF FLAX <-- Death To All Fanatics!
------------------------------
Date: 4 Mar 1998 18:15:34 -0500
From: dac@kalypso.cybercom.net (Daniel Childers)
Subject: Are perl $SIG{} handlers inherently unsafe?
Message-Id: <6dknam$c5b@kalypso.cybercom.net>
Synopsis: are perl $SIG{} handlers inherently unsafe due to the danger of
concurrent malloc() calls (and/or higher-level perl data structure mods)
in user and interrupt context?
>From the Signals page:
> For example, to trap an interrupt signal, set up a handler like this.
> Notice how all we do is set a global variable and then raise an
> exception. That's because on most systems libraries are not
> re-entrant, so calling any print functions (or even anything that
> needs to malloc more memory) could in theory trigger a memory fault
> and subsequent core dump.
>
> sub catch_zap {
> my $signame = shift;
> $shucks++;
> die "Somebody sent me a SIG$signame";
> }
But the code above *will* crash on Sun and AIX. Not every time of course,
but you cannot use a signal handler to catch repeated events such as death of
child and expect to avoid a core dump. There is no indication from the perl
documentation I have seen that the only thing you can hope to do with a
signal handler is die with an error message.
Details:
We are having an intermittent coredump in perl (5.003) on a script that does a
lot of pipe i/o to child processes. It coredumps after a random amount of time
(data-independent) on AIX 4.2; the backtrace always shows the segvi occurring
in malloc() or free(), and always at a point at which a background process
is ending (either one fork()'ed in perl, or a backtick command). The common
theme appears to be corruption of the malloc list in association with a
signal handler (SIGCHLD...).
On the face of it, it would seem that malloc cannot be used from interrupt
context as the heap list may be concurrently changed from user context; yet
Perl obviously must do mallocs while interpreting the perl-code of a signal
handler. Note in the backtrace below that it shows perl in malloc in both
contexts.
This is also a problem with internal Perl data structures that may be modified
in one context and read/modified concurrently in the other: perl does not seem
to implement critical sections to protect its data structures from signal-
handler modification.
On sun, similar functionality crashes in a test script, and not always in
malloc--it gets various symbol errors as well, indicating that Perl has in
fact corrupted its internal data structures.
Sometimes the code can run for hours without a problem--it seems to be just a
question of when it first happens to modify the heap (or other data structures)
simultaneously in both user and interrupt context.
I have constructed a (fairly) minimal test script which coredumps pretty
reliably on both AIX 4.2 and Sunos 5.4, if you pipe the output to a file (thus
maximizing the number of loops per unit time).
We have tried configuring perl 5.003 a number of different ways on AIX and Sun,
with no improvement. Our AIX version used AIX malloc, sun used perl malloc.
In both cases, the configuration takes advantage of the latest-and-greatest
sigaction() interface. Using the "threadsafe" xlc_r and lib/threads/libc.a's
malloc on AIX 4.2 doesn't solve the problem but instead reliably causes a
deadlock.
Disabling the rsignal(i, sighandler) calls in mg.c makes the crash go away
(but of course disables all signal handler behaviour).
Has anyone seen this? Can anyone suggest a workaround? Does this mean
that perl $SIG{} handlers are inherently unsafe? ("The Ringworld is unstable!
The Ringworld is unstable!").
==============================================================================
The test script:
==============================================================================
#!./perl
$SIG{'INT'} = "handler";
$SIG{'CHLD'} = "handler";
$SIG{'PIPE'} = "handler";
sub handler {
$hadsig = 1;
};
while (1) {
$hadsig = 0;
$kidwr = "KWR";
$kidrd = "KRD";
$rdout = "PRD";
$wrin = "PWR";
pipe($rdout, $kidwr);
pipe($kidrd, $wrin);
if (!($pid = fork())) {
close($rdout);
close($wrin);
open(STDIN, "<&$kidrd");
open(STDOUT, ">&$kidwr");
select((select($kidwr), $| = 1)[0]);
select((select($kidwr), $| = 1)[0]);
for ($i=0; $i<9; $i++) {
chop($a = <>);
printf($kidwr "got [%s] now\n", $a);
}
exit(0);
} else {
close($kidrd);
close($kidwr);
select((select($wrin), $| = 1)[0]);
for ($i=0; $i<9; $i++) {
printf($wrin "hello %d\n", $i);
chop($g = <$rdout>);
printf("Read (%s)\n", $g);
}
close($rdout);
close($wrin);
}
}
==============================================================================
the output:
==============================================================================
...
Read (got [hello 3] now)
Read (got [hello 4] now)
Read (got [hello 5] now)
Read (got [hello 6] now)
Read (got [hello 7] now)
Read (got [hello 8] now)
Corrupt malloc ptr 0xff020013 at 0x137b00
Corrupt malloc ptr 0xff020013 at 0x137b00
Read (got [hello 0] now)
Corrupt malloc ptr 0xff020013 at 0x137b00
Read (got [hello 1] now)
Corrupt malloc ptr 0xff020013 at 0x137b00
Read (got [hello 2] now)
Corrupt malloc ptr 0xff020013 at 0x137b00
Read (got [hello 3] now)
Corrupt malloc ptr 0xff020013 at 0x137b00
Read (got [hello 4] now)
Corrupt malloc ptr 0xff020013 at 0x137b00
Read (got [hello 5] now)
Corrupt malloc ptr 0xff020013 at 0x137b00
Read (got [hello 6] now)
Corrupt malloc ptr 0xff020013 at 0x137b00
Read (got [hello 7] now)
Corrupt malloc ptr 0xff020013 at 0x137b00
Read (got [hello 8] now)
Corrupt malloc ptr 0xff020013 at 0x137b00
Corrupt malloc ptr 0xff020013 at 0x137b00
Corrupt malloc ptr 0xff020013 at 0x137b00
Corrupt malloc ptr 0xff020013 at 0x137b00
Corrupt malloc ptr 0xff020013 at 0x137b00
Corrupt malloc ptr 0xff020013 at 0x137b00
Read ()
Corrupt malloc ptr 0xff020013 at 0xCorrupt malloc ptr 0xff020013 at 0x137b00
Corrupt malloc ptr 0xff020013 at 0x137b00
Bus Error (core dumped)
==============================================================================
The core backtrace in dbx on SunOs 5.4 (note concurrent malloc() calls [1] and
[14]; but the malloc list is already corrupt at this point, presumably from
a previous collision: the fprintf in [13] is the 'Corrupt malloc ptr' msg
you can see in the output above).
==============================================================================
program terminated by signal BUS (invalid address alignment)
Current function is malloc
165 if (*((int*)p) & (sizeof(union overhead) - 1))
(dbx) where
=>[1] malloc(nbytes = 28), line 165 in "malloc.c"
[2] Perl_sv_upgrade(sv = 0x1414bc, mt = 5), line 650 in "sv.c"
[3] Perl_sv_setsv(dstr = 0x1414bc, sstr = 0x132fbc), line 1566 in "sv.c"
[4] Perl_sv_mortalcopy(oldstr = 0x132fbc), line 2858 in "sv.c"
[5] Perl_pp_leavesub(), line 1615 in "pp_hot.c"
[6] Perl_runops(), line 54 in "run.c"
[7] perl_call_sv(sv = 0x132f74, flags = 2), line 786 in "perl.c"
[8] Perl_sighandler(sig = 18), line 1404 in "mg.c"
---- called from signal handler with signal 18 (SIGCLD) ------
[9] write(), at 0xef62c8ec
[10] _fwrite_unlocked(0x10651c, 0x6, 0x0, 0x12a510, 0x10651c, 0x6), at
0xef65dd20
[11] _dowrite(0x10651c, 0x6, 0x12a510, 0xefffeeac, 0x0, 0xef67f9ac), at
0xef64d438
[12] _doprnt(0x106522, 0x0, 0xef67f9b2, 0x10651c, 0x6, 0x25), at 0xef64d63c
[13] _fprintf(0x12a510, 0x106504, 0xff020013, 0x137b00, 0xefffefbc,
0xffffffce), at 0xef659734
[14] malloc(nbytes = 24), line 167 in "malloc.c"
[15] realloc(mp = 0x137b08, nbytes = 9), line 388 in "malloc.c"
[16] Perl_sv_grow(sv = 0x1414c8, newlen = 9), line 986 in "sv.c"
[17] Perl_sv_catpvn(sv = 0x1414c8, ptr = 0x12c590 "\n", len = 1), line 1927
in "sv.c"
[18] Perl_do_sprintf(sv = 0x1414c8, len = 0, sarg = 0x12d418), line 341 in
"doop.c"
[19] Perl_pp_prtf(), line 963 in "pp_sys.c"
[20] Perl_runops(), line 54 in "run.c"
[21] perl_run(sv_interp = 0x12ac08), line 566 in "perl.c"
[22] main(argc = 2, argv = 0xeffff49c, env = 0xeffff4a8), line 49 in
"perlmain.c"
(dbx)
==============================================================================
A core backtrace from AIX (no -g this time, sorry):
==============================================================================
Segmentation fault in rightmost at 0xd0002d3c
0xd0002d3c (rightmost+0x34) 7caa45aa stswi r5,r10,0x8
(dbx) where
rightmost(??) at 0xd0002d3c
free_y(??) at 0xd0004228
free(??) at 0xd0002280
.() at 0x1000b77c
.() at 0x10006e18
.() at 0x100065b8
.() at 0x1006a004
.() at 0x100272c8
.() at 0x10013cbc
.() at 0x10000314
(dbx)
------------------------------
Date: 4 Mar 1998 23:26:11 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Are perl $SIG{} handlers inherently unsafe?
Message-Id: <6dknuj$osg$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, dac@kalypso.cybercom.net (Daniel Childers) writes:
:Synopsis: are perl $SIG{} handlers inherently unsafe due to the danger of
:concurrent malloc() calls (and/or higher-level perl data structure mods)
:in user and interrupt context?
Yes.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
/* This bit of chicanery makes a unary function followed by
a parenthesis into a function with one argument, highest precedence. */
--Larry Wall in toke.c from the perl source code
------------------------------
Date: 04 Mar 1998 17:38:24 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Arrays and using output of executed program as input
Message-Id: <67lunktb.fsf@news.concentric.net>
keefner@kinetic.com (Craig Keefner) writes:
> open(JUSTDO, "|dos_search.exe /p $part /m \"$model\" /s $year >tmp/$$.file");
> close(JUSTDO);
First: you must check the success of both of those calls!
You'd only put that pipe at the beginning if you wanted to feed
something into the STDIN of that executable. Since you want the
output of the executable, you should do this:
open(DOS_SEARCH, "/path/to/dos_search.exe /arg /arg2 |") or die "$!";
# now you can read from DOS_SEARCH, e.g.,
my @results = <DOS_SEARCH>;
close DOS_SEARCH or die "$!";
> system("rm /netscape/suitespot/cgibin/tmp/$$.file");
> @array=<MYFILE>;
Um, why are you nuking the file *before* you read it?
Also, you wanna use the "unlink" builtin rather than "system."
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 4 Mar 1998 22:55:45 GMT
From: Albert-Lunde@nwu.edu (Albert Lunde)
Subject: building perl on hpux 10.20 with +O3
Message-Id: <6dkm5h$p05@news.acns.nwu.edu>
I'm trying to build perl5.004_04 on HP/UX 10.20 on a 831 box.
(The system is patched with nearly all the recommended HP patches
suggested by the custom patch manager as of mid-december)
I'm using HP's ANSI cc, and requesting an optimization level of +O3
Late in the make, I get the warnings like the one below:
= = =
cc -c -Ae -I/usr/local/include -I/opt/local/include +O3 -DVERSION=\
"1.02\" -DXS_VERSION=\"1.02\" +z -I../.. POSIX.c
cc: warning 8006: Do not use optimization levels higher than 2 to generate a sha
red library if a user of that library may redefine a routine within that library
(8006)
= = =
I know I could get around this by reducing the optimzation level, but
for performance, I'd rather leave it where it is.
Does anyone know enough about the internals of the dynamic code to know
is the warning is something I can safely ignore here?
--
Albert Lunde Albert-Lunde@nwu.edu
------------------------------
Date: 4 Mar 1998 22:52:25 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Change Unix environment variable using Perl
Message-Id: <6dklv9$nth@news.service.uci.edu>
In article <34FDCC0B.70C08351@scl.ameslab.gov>,
Zhaobin Zhu <zzhu@iastate.edu> wrote:
>1) Why I can not run in Perl
> system ("setenv MY_EV anyvalue");
setenv is a C-shell built-in command. Call will fail if SHELL not
csh (or tcsh). Did you check the return value?
>2) I can use
> $ENV{"SHELL"}="anyvalue" to set
> SHELL a new string within Perl. But
> SHELL remains the same as before after exit
> of my Perl program.
>
> Any method to modify environment vatiables
> in perl and make them permenant ?
Unix basics: You cannot change the environment of a parent process.
And it is a good thing since it would create a major security
problem.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: 04 Mar 1998 17:14:38 -0600
From: Quentin Fennessy <quentin@jihad.amd.com>
Subject: Re: Change Unix environment variable using Perl
Message-Id: <ximg1ky59r5.fsf@jihad.amd.com>
>>>>> "ZZ" == Zhaobin Zhu <zzhu@scl.ameslab.gov> writes:
ZZ> 2) I can use $ENV{"SHELL"}="anyvalue" to set SHELL a new
ZZ> string within Perl. But SHELL remains the same as before after
ZZ> exit of my Perl program.
ZZ> Any method to modify environment vatiables in perl and make
ZZ> them permenant ?
See perlfaq8(1) - Subsection "I {changed directory, modified my environment}...
--
Quentin Fennessy AMD, Austin Texas
------------------------------
Date: Wed, 4 Mar 1998 23:49:36 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Change Unix environment variable using Perl
Message-Id: <EpBJIo.9Aq@world.std.com>
ehood@medusa.acs.uci.edu (Earl Hood) writes:
>In article <34FDCC0B.70C08351@scl.ameslab.gov>,
>Zhaobin Zhu <zzhu@iastate.edu> wrote:
>>1) Why I can not run in Perl
>> system ("setenv MY_EV anyvalue");
>setenv is a C-shell built-in command. Call will fail if SHELL not
>csh (or tcsh). Did you check the return value?
system() always calls /bin/sh. So it is always fail, regardless of the
SHELL environment variable.
--
Andrew Langmead
------------------------------
Date: 04 Mar 1998 18:50:56 -0500
From: Justin Vallon <vallon@pearl.fi.bear.com>
Subject: Re: Change Unix environment variable using Perl
Message-Id: <x6eogzmm2vz.fsf@pearl.fi.bear.com>
Environment variables are only passed down to children. They are
never passed up to parents.
That is, system runs your command in a shell, which changes the
value of MY_EV, then exits. perl's variables are not affected.
If you use $ENV{"SHELL"}, you have changed the value of perl's
environment variable SHELL. Processes that you start, via exec
or system, will inherit this value. Your parent is not
affected. When you (the perl script) exits, the process and its
environment variables disappear.
Children cannot modify the variables of the parents.
If you want variables to be modified in your shell, you'll have
to source a shell script, and have the variables set there.
For example:
% cat set_variable
setenv MY_EV newvalue
%
% setenv MY_EV oldvalue
% echo $MY_EV
oldvalue <<<< Has old value here
% source set_variable <<<< Changes this shell's $MY_EV
% echo $MY_EV <<<< Has new value here
newvalue
%
Zhaobin Zhu <zzhu@scl.ameslab.gov> writes:
> Hi,
>
> two questions,
>
> 1) Why I can not run in Perl
> system ("setenv MY_EV anyvalue");
>
> 2) I can use
> $ENV{"SHELL"}="anyvalue" to set
> SHELL a new string within Perl. But
> SHELL remains the same as before after exit
> of my Perl program.
>
> Any method to modify environment vatiables
> in perl and make them permenant ?
>
> Thanks in advance ,
>
> Zhaobin Zhu
> zzhu@iastate.edu
> ---
>
--
-Justin
vallon@bear.com
------------------------------
Date: 4 Mar 1998 22:47:37 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Debugging Perl and extensions (Perl gurus please help)
Message-Id: <6dklm9$rmf$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Paul Cunnell
<pcunnell+usenet@csfp.co.uk>],
who wrote in article <34FD957B.3697@csfp.co.uk>:
{{{ THIS MESSAGE WAS POSTED AND MAILED WITHOUT A CORRESPONDING MARKUP }}}
> > Stop spreading the FUD! There is nothing simpler: just use _noinc()
> > variant of newRV_*, and make mortal whatever comes to stack - which
> > means toplevel thing(s).
> That may be so, but it sure puzzled the hell out of me. As far as I
> could determine, I needed to mortalise the 'containers' in the
> structure ( newHV() and newAV ),
Do not.
> but not the items contained within them.
Ilya
------------------------------
Date: Wed, 04 Mar 1998 22:03:06 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: Re: Example for use Win32::NetResource::AddConnection
Message-Id: <6dkj3h$sbd$3@nz12.rz.uni-karlsruhe.de>
nick@NOSPAMTHANKSciof.sbcc.net (Nick Tonkin) wrote:
>Not to mention that no one I have ever talked to has been able to get
>NetResource::AddConnection to work . . . If you do, let me know! I
>hate using the system call for that.
AOL me on all counts.
Greetings
Marc
--
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber | " Questions are the | Mailadresse im Header
Karlsruhe, Germany | Beginning of Wisdom " | Fon: *49 721 966 32 15
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29
------------------------------
Date: Wed, 04 Mar 1998 16:35:08 -0600
From: widsk1@hotmail.com
Subject: How to build perl Additional Modules
Message-Id: <6dkktk$4bf$1@nnrp1.dejanews.com>
I downloaded perl source code and Addtional perl modules from
www.perl.com/CPAN. I was able to compile and build perl in Solaris 2.6 Sparc
successfully, but, I am having trouble to build addtional perl modules such as
CGI Crypt DBD-Oracle DBI Data-Dumper GD Graph-modules IO MD5 SyslogScan libnet
libwww sybperl.
Could you tell me how to do it if you have an experience to build additional
perl modules in Solaris? If you know any company that sells the prebuilt
additional perl module and provides technical support, please let me know.
Thank you in advance.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Wed, 04 Mar 1998 17:34:49 -0600
From: kevin@cmhcsys.com
Subject: isn't perl clever: short-circuit logic
Message-Id: <6dkodg$7p7$1@nnrp1.dejanews.com>
i've been really taken with the cleverness of perl's short-circuit logic,
ever since wiling a flight from boulder to columbus by reading frossie
economou's article on perl logic in a recent edition of tpj. (i'm a pretty
slow reader.) since then i've been using short-circuit logic every chance i
get.
today i found myself writing two short-circuit lines in a row, and it got me
to wondering if i was really being as efficient as i could, or not. here's
the code, edited somewhat for clarity:
# i've got a syllable which i've gotten by splitting up a word. now i want
to split the # syllable into its initial consonant(s), or "onset," and the
rest of it, or its "rime."
# i've got a list of possible syllable-initial consonants, which i'll put
into a character class. $InitialConsonants = "bcdfghjklmnpqrstvwxyz";
# if any of those initial consonants are present, i want to peel them off and
put them into # the variable $onset; the remainder should go into the
variable $rime.
# what if there is no onset consonant? then the whole syllable is the rime.
# this first short-circuit line sets $onset if there be one, and puts the
syllable into $rime # if there be'n't one.
(($onset) = /^([$Conset]+)/) || ($rime = $syllable);
# the next short-circuit line takes care of setting the $rime in the normal
case, i.e. # where there WAS an onset consonant.
($rime) || ($rime = $');
yes, i think perl IS clever, and i delight in it. question is, am I clever?
is there a more efficient way of defining $onset and $rime?
kevin
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 04 Mar 1998 17:45:58 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: maintaining state
Message-Id: <4t1enkgp.fsf@news.concentric.net>
abubic@uoguelph.ca (Alen S Bubic) writes:
> I was wondering if anybody knew a slick way to maintain state in perl
> (between scripts). I've tried several different techniques some of them
> work but they are all clumbersome. All suggestions are welcome!
I find the Data::Dumper module very easy to use for such things. You
can get it at CPAN.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 4 Mar 1998 18:14:49 GMT
From: pcnguyen@chnews.intel.com (Phivu C. Nguyen~)
Subject: Multidimensional Hashes
Message-Id: <6dk5mp$45j6@chntsfs1.ch.intel.com>
Keywords: Hashes, Associative Arrays
Hello:
I am getting some strange results!
I am using perl 5.004.
> Summary of my perl5 (5.0 patchlevel 4 subversion 0)
I expect my code to yield the following result:
x1 : x1d
x2 : x2d
x3 : x3d
x4 : x4d
However, it actually yields
x1 : x4d
x2 : x4d
x3 : x4d
x4 : x4d
I have noticed I can get the expected results if I do one of
two things:
1) erase the "preassign keys into the hash" section of code
or
2) change $my_hash{$_} ='';
to $my_hash{$_}{'d'} = '';
Can anyone tell me why this is?
Here is my perl code:
-------------------------------------------------------------
#! /usr/bin/perl -w
my @my_array = qw(x1 x2 x3 x4);
my $my_hash;
my %random_order = ('x2' => x2d,
'x3' => x3d,
'x4' => x4d,
'x1' => x1d);
# preassign keys into the hash
foreach (@my_array) {
$my_hash{$_} = '';
}
# create a new entry in the hash element
foreach (keys %random_order) {
$my_hash{$_}{'d'} = $random_order{$_};
}
# check for valid entries
foreach $first_dim (sort keys %my_hash) {
foreach (sort keys %{$my_hash{$first_dim}}) {
print "$first_dim : $my_hash{$first_dim}{$_}\n";
}
}
-------------------------------------------------------------
--
Thanks,
Vu Nguyen
-------------------------------------------------------
Phivu Nguyen
CH6-210
Intel Corporation
5000 West Chandler Boulevard
Chandler, AZ 85226
------------------------------
Date: 4 Mar 1998 22:34:19 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Multidimensional Hashes
Message-Id: <6dkktb$n1o@news.service.uci.edu>
Keywords: Hashes, Associative Arrays
In article <6dk5mp$45j6@chntsfs1.ch.intel.com>,
Phivu C. Nguyen~ <pcnguyen@chnews.intel.com> wrote:
>#! /usr/bin/perl -w
>
>my @my_array = qw(x1 x2 x3 x4);
>my $my_hash;
----^
Should be %
>
>my %random_order = ('x2' => x2d,
> 'x3' => x3d,
> 'x4' => x4d,
> 'x1' => x1d);
>
># preassign keys into the hash
>foreach (@my_array) {
> $my_hash{$_} = '';
-----------------^^
Bad initialization. You want:
$my_hash{$_} = { };
since you plan to use $my_hash{$_} as a hash reference.
># create a new entry in the hash element
>foreach (keys %random_order) {
> $my_hash{$_}{'d'} = $random_order{$_};
--------------^^^^^
Here's the gotcha. Reason: Perl tries to treat $my_hash{$_} as a hash
reference that needs to be dereferenced. However, you have set the
value to the empty string. Hence, Perl is treating the empty string
value as the hash reference. Since you explicitly defined the keys to
%my_hash, Perl will not automatically create the anonymous hash.
This is only done if the $my_hash{$_} is not defined.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: 4 Mar 1998 22:43:31 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Need help to setup Perl win32 in IIS4
Message-Id: <6dklej$nfv@news.service.uci.edu>
In article <34FDAC5F.80E39FD7@hp.com>,
Sebastian Probst <Sebastian_Probst@hp.com> wrote:
>Hi James,
>
>running PERL with IIS is not such a problem.
Apparently you have not tried to do I/O redirection in your Perl
CGI programs.
Here is the directions provided to c.l.p.m awhile back:
----------------
From: Steve West <stevew@metafuse.com>
Newsgroups: comp.lang.perl.misc
Subject: How to Configure Perl with IIS 4.0
Date: Wed, 07 Jan 1998 11:41:43 -0800
Lines: 82
Message-ID: <34B3DA76.A3AF561B@metafuse.com>
For all you who are trying to run IIS 4.0 and perl here is what you have
to do to configure it to run properly on IIS 4.0.
I have outlined a two step process to get it to work...here goes
****** STEP 1. CONFIGURE PERL TO WORK WITH IIS 4.0*****
Microsoft changed from having the script mappings in the registry to the
a
configuration in the service manager. Now script mappings are changed
in the
default website properties.
Go to the default website, right mouse click on the properties for that
site....
then click on "Home Directory" tab
Go to the "Applications Settings" toward the bottom of the window...find
the "Configuration" button...the click on it. A new window called
script
mappings exists..you need to either create a new script mappings or edit
the old
one.
It should look like this
.cgi c:\perl\bin\perl.exe %s %s
.pl c:\perl\bin\perl.exe %s %s
I had those set before in the registry...as you may have too...and MS
IIS 4.0
pulled the values out and capitalized the %S %S...that wont work..it
looked like
this
*** MICROSOFT PUT THIS THERE...IT WILL NOT WORK ***
.pl C:\PERL\BIN\PERL.EXE %S %S
*** YOU MUST CHANGE MAPPING TO LOOK LIKE THIS***
.cgi c:\perl\bin\perl.exe %s %s
.pl c:\perl\bin\perl.exe %s %s
***** STEP 2. CONFIGURE PERL TO WORK WITH STANDARD I/O *****
By default you cannot use standard I/O redirection with perl and IIS
4.0.
You have to configure this into the metabase. Here is how you do it:
You need to run a command line from the:
"\winnt\system32\inetsrv\adminsamples" directory
When you get there type this on the command prompt
adsutil set w3svc/CreateCGIWithNewConsole TRUE
You may get an error becuase the .vbs is not set, just click on yes, and
retype the command if you get that error.
You will have to stop the default website, and restart it from the
internet service manager to make the changes.
NOTE: If for some reason you cannot get the adsutil at the command
prompt, or you get unrecognized command, you may want to search for it
using the start menu, find. Look on your system for "adsutil.vbs". If
you still cannot find it, you perhaps did not install all the
samples...you may go to the Windows NT 4.0 Option pack setup from the
start menu and check to see if you can install the administration
samples. I am not sure if the adsutil.vbs shipped in all cases, but
most of you will have it in your
"winnt\system32\inetsrv\adminsamples" directory.
I hope this note helps you guys and keeps you from having same trouble I
had.
Steve West
----------------
Since there is an Apache port for NT, you can use it instead of
IIS. It supports the #! line. Or better yet, move to Linux or
other Unix-based system.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Wed, 4 Mar 1998 23:46:16 -0000
From: "Adam Carden" <adam@pacific-artists.demon.co.uk>
Subject: Perl & Personal Web Server
Message-Id: <889054675.3677.0.nnrp-11.c2de97e4@news.demon.co.uk>
I currently design perl scripts however I find myself spending ages testing
the scripts via telnet. I am running MS Personal Web server on Windows95.
I can run perl scripts from the command line. What I wish to know is that
is it possile to get perl(win32) running with ms personal webserver.
I would be grateful for any help and would design a "free" custom mailform
script (Our retail price of #70, $120)
Thanks.
Adam Carden
Pacific Artists (The Power behind the Web)
------------------------------------------------------------
http://www.pacific-artists.demon.co.uk
adam@pacific-artists.demon.co.uk
------------------------------
Date: Wed, 04 Mar 1998 12:56:21 -0500
From: brain Lorraine <brains@erols.com>
Subject: perl for win95?
Message-Id: <34FD95C5.1EEF@erols.com>
n-e-one know where i can dload perl for win95?
--
peace,
brain
www.gl.umbc.edu/~blorra1
------------------------------
Date: Wed, 4 Mar 1998 22:58:58 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Perl on MS Personal Web Server
Message-Id: <genepoolEpBH6A.CzI@netcom.com>
Steven Savage (badger@infinet.com) wrote:
: I've been wrestling with getting PERL to work on an MS Personal Web
: Server to demo a PERL search engine. Does anyone know how to get this to
: work? it seems my file associations just aren't enough.
Steve,
Whenever you start to wrestle with a MS product, you should say
to yourself, "Self, might anyone else ever had had this problem
before me?" If the answer is a resounding "YES!", hi thee to
dejanews and search on 'perl personal web server'. HTH.
Cheers,
Jim
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 2024
**************************************