[8226] in Perl-Users-Digest
Perl-Users Digest, Issue: 1844 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 10 04:07:51 1998
Date: Tue, 10 Feb 98 01:00:27 -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 Tue, 10 Feb 1998 Volume: 8 Number: 1844
Today's topics:
Re: Binary Search Trees <rjk@coos.dartmouth.edu>
Re: creating new file with perl (Johnny Fingers.)
Re: defined() bug? (or feature? :) <rjk@coos.dartmouth.edu>
Re: defined() bug? (or feature? :) <xxTony.Curtis@vcpc.univie.ac.at>
Re: foreach and my() [GUTS; LONG] <dgoddard@us.oracle.com>
garbage collection in perl <mikedoug@texas.net>
Re: garbage collection in perl (Craig Berry)
Re: getting rid of duplicate lines in a file <rjk@coos.dartmouth.edu>
Re: Good perl editor? (Jonathan Nicholson)
Re: Happy with Prel?? No my teeth could be whiter... (Wef)
Re: How do I export environment variables? (Jamie O'Shaughnessy)
Re: How to tell if your CGI-related question belongs in <rjk@coos.dartmouth.edu>
Location-variable <t1812@nospam.net>
Re: More regular expressions <rjk@coos.dartmouth.edu>
Re: Perl documentation (was re: Perl Year 2000 ...) <bcoleman@mindspring.com>
Re: reading in a file to an associative array (Martin Vorlaender)
Re: Sharing variables between scripts (Brian M. Beaulieu)
Too simple to ask but then .... <glchy@csah.com>
Re: Too simple to ask but then .... (Craig Berry)
Re: Too simple to ask but then .... (Jamie O'Shaughnessy)
What can I do when Perl panics? JWears@msn.com
Re: Year 2000 Compliance: Lawyers, Liars, and Perl <zooko@xs4all.nl>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 10 Feb 1998 01:21:06 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: Binary Search Trees
Message-Id: <34DFF1DC.5267FD00@coos.dartmouth.edu>
Tom Christiansen wrote:
>
> In comp.lang.perl.misc, olm@mail1.csun.edu writes:
> :Is there any way to implement Binary Search Trees or AVL Trees in Perl.
>
> Sure. Why do you want to? You prefer the logarhytmic time of trees
> to the constant of hashes for some nonobvious reason?
How about, trees can keep their elements in sorted order.
Chipmunk
------------------------------
Date: Tue, 10 Feb 1998 06:41:49 GMT
From: wyldkard@total.net (Johnny Fingers.)
Subject: Re: creating new file with perl
Message-Id: <MPG.f49c0f992493539989684@news.videotron.ca>
[This followup was posted to alt.perl and a copy was sent to the cited
author.]
In article <34e4ab20.8293201@flood.xnet.com>, efflandt@xnet.com says...
> steve@clara.net (Steve Rawlinson) wrote:
>
> >>I've been using
> >> system "touch emailaddress.com";
> >>
> >>but this only works if I run the script inside the server, after I've
> >>telneted... It doesn't work when I run the script from the browser.
> >
> >Its probably a path or permission problem or both but you might want
> >to try using
> >
> >open(Out, ">>filename") ;
> >close Out ;
> >
> >instead since this is what touch does anyway. Remember the web daemon
> >user will need write permission in the directory you're creating these
> >files in.
>
> You also need execute permission on a dir to create new files. Not
> sure why, but it doesn't work without it.
>
> >steve
>
>
> David Efflandt/Elgin, IL USA
> efflandt@xnet.com http://www.xnet.com/~efflandt/
>
In case you worry about these things. Watch the security aspect of a
program like that. Put full paths to executables (/user/local/bin/touch
$var), and parse out any unwanted characters in that 'email variable'.
(Nothing worse than finding our your innocent script is a gateway to hell
on your server because of a leak.) :)
Run a pattern match and take out garbage characters like '!". etc. This
will tighten it up a bit.
Also, you need to have exec in the dir you want to create, becaue the
'touch/open' whatever is executed to create the file IN that directory.
(think of it as if it's 'referencing' the binary in the /usr/bin dir and
running in the dir of file creation.)
--
--------------------------------
J.Fingers - wyldkard@total.net
--------------------------------
------------------------------
Date: Tue, 10 Feb 1998 01:48:16 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Mark Morgan <morganm@qualcomm.com>
Subject: Re: defined() bug? (or feature? :)
Message-Id: <34DFF830.906F1798@coos.dartmouth.edu>
[posted and mailed]
Mark Morgan wrote:
>
> I have a module named CONFIG.pm
There is already a module in the standard distribution named Config.pm.
Perhaps you should rename your module.
> [...]
>
> Unfortunately, that doesn't work, because it expects a reference, not a
> value, so I'm have to do the following:
>
> $::{ $key } = \eval{ $value };
>
> The eval being required because I don't want to make it a reference to the
> real variable $value, which changes as I read in each line of the config
> file.
If you don't want it to change, why are you making it a reference?! Just
assign it the scalar value!
$::key = $value;
Chipmunk
------------------------------
Date: 10 Feb 1998 09:52:08 +0100
From: Remove xx to reply <xxTony.Curtis@vcpc.univie.ac.at>
Subject: Re: defined() bug? (or feature? :)
Message-Id: <7x1zxb970n.fsf@beavis.vcpc.univie.ac.at>
Re: defined() bug? (or feature? :), Mark
<morganm@qualcomm.com> said:
Mark> I have a module named CONFIG.pm, who's job is to read
Mark> in a configfile and load the entries of that file into
Mark> global variables.
Somewhat defeats the point of modules and OOness if you ask
me.
Make the constructor for the module slurp in the data and
for each
left = right
do
$self->{left} = right;
and maybe add a "keys" field which enumerates all the
"left"s.
push(@{$self->{keys}}, left);
self(:-)-contained. No more global variables.
hth,
tony
------------------------------
Date: Mon, 09 Feb 1998 20:51:55 -0800
From: Denis Goddard <dgoddard@us.oracle.com>
Subject: Re: foreach and my() [GUTS; LONG]
Message-Id: <34DFDCEB.F143D4D1@us.oracle.com>
Chipmunk wrote:
>
[DG: Note: snipped away lots of cascade, left in the most-relevant stuff...]
>
> > > The perlsyn manpage reads:
> > > ...If the variable was previously declared
> > > with my, it uses that variable instead of the global one, but it's still
> > > localized to the loop.
>
> Nevertheless ... why is it implemented that way?
>
> In particular, since this is legal syntax:
> foreach my $a (@list) {...
>
> It makes no sense for this to have the same effect:
> my($a);
> foreach $a (@list) {...
>
I tell you this!
One can learn a *lot* picking thru the source and with the '-Dx' flag!
HOLY COW!! :)
FOR THE IMPATIENT:
==================
In a nutshell, "foreach my $a" is *identical* to "for my $a",
whereas "my $a; foreach $a" is *entirely* distinct from "foreach my $a" !!!
Okay, source code (what I understand of it) first,
debugger "analysis" after...
... and don't misss "TO CHIPMUNK'S ACTUAL QUESTION", below.
SOURCE CODE OBSERVATIONS: (my comments denoted "# shell-style")
=========================
toke.c:
-------
# Looks like when the tokenizer gets a "for", it plows thru with no care
# about "foreach" vs. "for", which is why "for $a ( 1 .. 3 )" works
# *exactly* like "foreach $a ( 1 .. 3 )" Hah! I always wondered about that.
# Moreover, if a "my" is present, we just skip right on over it, too!
toke.c:
case KEY_for: # hey! for and foreach processed in the same way!?
case KEY_foreach:
yylval.ival = curcop->cop_line;
s = skipspace(s);
if (isIDFIRST(*s)) {
char *p = s;
if ((bufend - p) >= 3 &&
strnEQ(p, "my", 2) && isSPACE(*(p + 2))) #WHOA! Skipped!
p += 2;
p = skipspace(p);
if (isIDFIRST(*p))
croak("Missing $ on loop variable");
}
OPERATOR(FOR);
perly.y:
--------
# The answer seems to be in perly.y....
# Three things to Note:
# 1. newFOROP args: (flags,label,forline,OP *sv,OP *expr,OP *block,OP *cont)
# (I have numbered the tokens passed to newFOROP for easier reference)
# 2. 'mexpr' ==> my-expression (expr to get "introduced" into the lex. scope)
# 3. "FOR MY" is handled as a special-case:
| label FOR MY remember my_scalar '(' mexpr ')' mblock cont
# LABEL: for my $a ( 1 .. 3 ) { ...
# 1 2 3 4 5 6 7 8 9 (token #s)
newFOROP(0, $1, $2, $5, $7, $9, $10)); }
| label FOR scalar '(' remember mexpr ')' mblock cont
# LABEL: for $a ( 1 .. 3 ) { ...
# 1 2 3 4 5 6 7 8 (token #s)
newFOROP(0, $1, $2, mod($3, OP_ENTERLOOP),
$6, $8, $9)); }
#(Note, the "traditional" for(;;){} syntax is handled separately)
# Hmmmm...
# The difference, really, is that FOR MY passes a my_scalar directly on
# to the newFOROP, after 'remember'-ing a new lexical scope.
# On the other hand, the FOR (with no "MY") passes mod(scalar, OP_ENTERLOOP)
# to the newFOROP, and *then* starts the new scope.
# AHA!!! What's this mod() thingy? And what _exactly_ does newFOROP() do?
# We're getting close!!
op.c:
-----
# HERE is where mod(op, type) is defined. "op" in this case is the iteration
# variable (OP *sv), and "type" is OP_ENTERLOOP.
# But first, note that in newFOROP, we explicitly handle
# "my" variables vs. symbol-table variables....
newFOROP(flags,label,forline,sv,expr,block,cont)
{
if (sv) {
if (sv->op_type == OP_RV2SV) { /* symbol table variable */
sv->op_type = OP_RV2GV; # settin' up the typeglob (GV)
sv->op_ppaddr = ppaddr[OP_RV2GV];
}
else if (sv->op_type == OP_PADSV) { /* private variable */
padoff = sv->op_targ; # settin' up the "scratch pad"
op_free(sv);
sv = Nullop;
}
}
#(BTW, if there was no sv, Perl creates one on-the-fly as $_ [snipped]...)
########### HERE IT IS (I THINK...) ##############################
#... EITHER WAY, GV or Private variable, it gets OPf_STACKED...
#... which (I *think*) effectively localizes it on each iteration!
##################################################################
if (expr->op_type == OP_RV2AV || expr->op_type == OP_PADAV) {
expr = scalar(ref(expr, OP_ITER));
iterflags |= OPf_STACKED;
}
#.. and then we execute the WHILEOP code!! Wild!!
# HEY GUYS, a FOR loop *is* a WHILE loop!!! (which makes sense...)
DEBUGGING ANALYSIS:
===================
I made 3 scripts:
"global.pl" (uses global $a throughout, no local() or my() or nuthin')
"loop_my.pl" looks like: 'foreach my $a ...'
"implicit_my" looks like: 'my $a; foreach $a ...'
Ran them with -Dx
[Chipmunk, again:]
>
> Unlike the first two, which leave $a scoped to the package level,
> foreach has $a lexically scoped to the foreach loop.
>
Actually, I think that it's not "for" vs "foreach", but rather the
different types of expressions you used to control the loop iteration.
global.pl: # foreach $a ( 1 .. 3 )
----------
15 TYPE = enteriter ===> 16 # enter the loop
FLAGS = (LIST,KIDS) # flags from newFOROP
#...[extraneous snipped]
12 TYPE = rv2av ===> 13 # makin' a list out of 1..3
FLAGS = (LIST,KIDS,MOD) # (I think)
#...
10 TYPE = pushmark ===> 11 # pushing the GV below onto
# a stack...
#...
14 TYPE = rv2gv ===> 15 # at each iter, a kid off of
FLAGS = (SCALAR,KIDS,REF,MOD) # the above list gets stuffed
{ # into the 'stacked'
13 TYPE = gv ===> 14 # $main::a (I think)
FLAGS = (SCALAR)
GV = main::a
}
loop_my.pl: # foreach my $a ( 1 .. 3 )
-----------
13 TYPE = enteriter ===> 14 # Enter the loop
FLAGS = (LIST,KIDS)
#...
12 TYPE = rv2av ===> 13 # makin' the list, again
#...
10 TYPE = pushmark ===> 11 # pushing the my variable on
#... # a stack, this time...
12 TYPE = rv2av ===> 13 # There's that kid, again...
{
14 TYPE = iter ===> 15 # ...conspicuously absent GV
FLAGS = (SCALAR)
}
implicit_my.pl: # my $a; foreach $a ( 1..3 )
---------------
15 TYPE = enteriter ===> 16 # Enter the loop
FLAGS = (LIST,KIDS)
{
TYPE = null ===> (12) # Looky here:
(was pushmark) # a whole new scope!
FLAGS = (SCALAR) # (I think)
}
#...
14 TYPE = rv2av ===> 15 # makin' the list, again
FLAGS = (LIST,KIDS,MOD) # .. and again, conspicuously
{ # absent GV.
13 TYPE = const ===> 14
FLAGS = (SCALAR)
SV = AV()
}
}
TO CHIPMUNK'S ACTUAL QUESTION! :)
==============================
Yeah, I *think* I see a number of reasons why it behaves the way it does.
First and foremost, it avoids the crap we had to do in 100-level CS classes:
"int i,j,k,l,m,n,o,x,y,z,p,d,q; /* iteration variables */"
Second and secondmost, no matter what kind of variable or loop is being
used, it goes into a new context (via 'remember') which gets neatly STACKED.
Third, and it seems most importantly, speed. You want a new scope to spring
up and protect yer fast-acting loop variable at just the right moment, right?
WRAP-UP:
========
Well, this is the first time I ever really tried to look into the Black
Box that is the actual implementation of Perl.
Actually, plugging thru the perl source is not nearly so bad or scary as I
would have been led to believe. I mean, I've had to pick through Perl
*scripts* that were ten times more obscure, due to lack of structure
(and/or discipline) on the part of the original coder.
On the other hand, would I feel comfortable modifying "op.c"?
HELL, NO! I have *no idea* how youse guys manage to tweak this stuff....
To get as arrogant as I possibly can be:
I guess extremely verbose commenting would be nice, because things are
spread among many files (but then that's what grep is for), and because of
all those darn #defines (but then they are there to make things real fast).
...Just my $0.02, I'm not complaining in the least, okay?
Then again, my "analysis" may turn out to be wholly incorrect;
it's happened before... :)
-Denis
P.S. "Okay, I am cool enough to hang out in this newsgroup now?" :)
(you can say, "no".....)
--
__ __ _ __ __
~~~~(__)|-< /-\(__ |__(-_ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Denis Goddard, Senior Member, Tech. Staff |"I see the heads of men arise
email: dgoddard@us.oracle.com |with hungry minds and open eyes!"
ourworld.compuserve.com/homepages/d_goddard| -Rush, from 2112: _The Oracle_
------------------------------
Date: 10 Feb 1998 07:21:15 GMT
From: Michael Douglass <mikedoug@texas.net>
Subject: garbage collection in perl
Message-Id: <6bov5b$i0f$1@news3.texas.net>
I've searched the web and I've searched the news groups... Does anyone
have any information on the garbage collection under perl? Is it
done automatically as you release variables? Or does it que them up
for a while before taking care of them. I ask because I have a fairly
busy program I wrote using perl that does quite a bit with hashes...
The memory footprint grows to about 50MB with about half of that
resident at all time. I find it terribly hard to believe that my
data is taking up that much space in reality; this doesn't say much
about perl's memory management.
--
Michael Douglass
Texas Networking, Inc.
<tnet admin> anyway, I'm off, perl code is making me [a] crosseyed toady
------------------------------
Date: 10 Feb 1998 08:07:10 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: garbage collection in perl
Message-Id: <6bp1re$7k$2@marina.cinenet.net>
Michael Douglass (mikedoug@texas.net) wrote:
: I've searched the web and I've searched the news groups... Does anyone
: have any information on the garbage collection under perl?
Read Hall's _Effective Perl Programming_ for a good basic look at this
(and a zillion other cool Perl things). In short, Perl uses reference
counting for runtime memory management, plus a mark-and-sweep pass to
clean up as the application is exiting. Also, Perl never returns any
memory to the OS (it keeps it in a pool for reuse instead), so freeing a
lot of stuff inside your app won't show up externally. In effect, the
total allocation is a 'high water mark' of your app's memory use.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Tue, 10 Feb 1998 01:19:14 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Tim Gray <tim@hcirisc.cs.binghamton.edu>
Subject: Re: getting rid of duplicate lines in a file
Message-Id: <34DFF16C.C5406229@coos.dartmouth.edu>
[posted and mailed]
Tim Gray wrote:
>
> How would you go about getting a perl script to remove all duplicate
> lines in a file? I basically want to do the equivalent of
> `cat filename | uniq > filename` but since this will be in perl for
> win32 I can't do it that way. Thanks.
You could use others' suggestion of a hash, but if you really want the
equivalent of `uniq`:
perl -ni -e 'BEGIN{$_=""} print unless $_ eq $prev; $prev = $_;' filename
[you don't need to use cat with that]
Chipmunk
------------------------------
Date: 9 Feb 1998 22:00:31 -0000
From: jono@nospam.nowhere.noorg (Jonathan Nicholson)
Subject: Re: Good perl editor?
Message-Id: <6bnu9v$q9$1@acme.demon.co.uk>
In article <6biltp$ng5$1@usenet48.supernews.com>,
Don O'Neil <don@whtech.com> wrote:
>Does anyone know of a good windows or unix (X-Windows) based perl editor w/
>context sensitive coloring, auto indent, etc...??? I've tried Win Edit, but
>it does not have built in Perl syntax, I could add it, but that's a pain.
>I'm looking for something along the order of the editors that come w/ MS C
>and Borland C.
I use nedit version 5, it's very good it does context colouring for C,
perl, shell script, html etc.
It's available from http://www-pat.fnal.gov/nirvana/nedit.html
We recommend it at work as it is quite a small package and it is very
powerful, it can be almost used as a shell, running commands within the
editor.
Regards,
Jonathan
--
| Jonathan Nicholson (jono at acme dot demon dot co dot uk) 0973 199 983 |
| TV doesn't rule my life, it just has a casting vote |
------------------------------
Date: Tue, 10 Feb 1998 07:51:23 GMT
From: wef@N0SPAM_wef.net (Wef)
Subject: Re: Happy with Prel?? No my teeth could be whiter...
Message-Id: <34e306f8.62443168@news>
On 9 Feb 1998 16:45:36 -0000, markl@blinx.lizard.org (Mark Lewis)
wrote:
>I am looking into the possibility of rewriting all the site-specific shell
>scripts for our company in perl, but am checking to see if anybody else
>has done this and wished they hadn't.
>
If a million pounds are at stake && your shell scripts are running
fine, then save your energy and stop thinking so much!
------------------------------
Date: Tue, 10 Feb 1998 08:05:33 GMT
From: joshaugh@uk.oracle.com (Jamie O'Shaughnessy)
Subject: Re: How do I export environment variables?
Message-Id: <34e10985.579071350@newshost.us.oracle.com>
On Mon, 09 Feb 1998 12:17:01 -0800, William Wishon <bwishon@adobe.com> wrote:
>At the end of a config script I wrote I would like to export my
>environment variables. I want the perl script to leave the environment
>of the shell it's running in different than when it started. Then other
>commands executed from the shell that executed the perl script can use
>the modified environment variables.
>
>-Bill
If you're talking about on Windows then see the thread "How can I set
enviroment variables on Win32?" of 14 Jan 98.
I don't know about on unix, or other platforms, but this was my response
(you'll probably be interested in the 3rd suggestion of altering the .bat
file...):
On Thu, 15 Jan 1998 16:53:42 GMT, joshaugh@uk.oracle.com (Jamie O'Shaughnessy)
wrote:
>If you want to set the env var within your script and for any programs you call
>from within your script (e.g. by doing a system()) - just add/set the env var
>in %ENV, e.g.
>$ENV{new_var} = "value";
>
>If you want to set the env var in *future* command prompts then you can set the
>env var in the registry (using Win32::Registry). The env vars are stored in:
>\\HKEY_CURRENT_USER\\Environment
>
>Some example code to set an env var in the registry is:
>
>use Win32::Registry;
>my $regkey;
>$HKEY_CURRENT_USER->Open('Environment', $regkey) || die;
>$regkey->SetValueEx("env_var_name", &NULL, ®_SZ, "value");
>$regkey->Close();
>
>You get my drift. This only works on NT as 95 doesn't store env vars in the
>registry. For 95 you have to alter autoexec.bat.
>
>If you want to alter the env vars within the shell/program that called your
>perl script, this is a different matter. The only way I've found to do this is
>to write out a temporary file from within your perl script, and then execute
>this as a batch file, e.g.
>
>@rem = 'Perl Script Wrapper';
>@rem = '
>set CMD=%0
>set ARGS=
>:loop
>if .%1==. goto endloop
>set ARGS=%ARGS% %1
>shift
>goto loop
>:endloop
>perl.exe -S %CMD% %ARGS%
>if exist %temp%\shellenvs.bat call %temp%\shellenvs.bat
>if exist %temp%\shellenvs.bat del %temp%\shellenvs.bat
>goto endofperl
>@rem ';
>
># this is where the perl starts!!!
>my $tempfile = $ENV{TEMP} . "\\shellenvs.bat";
>open(BATFILE, "> $tempfile") || die;
>print BATFILE "set THISVAR=VALUE\n";
>close(BATFILE);
>
>__END__
>:endofperl
>
>Save all of the above in a .bat file and it should work. Note the couple of
>lines at the top of the .bat bit that calls the shellenvs.bat - this is the
>script your perl script will generate and it's in here that you issue the shell
>"set" commands to set the env vars.
>
>All of the above methods work and I use them in a number of scripts we use
>daily.
Hope that helps,
Jamie
___________________________________________________________________________
Jamie O'Shaughnessy Work: joshaugh @ uk.oracle.com
Oracle C++ Object Layer Generator Team
______________________________________________________ __ __ _ __ . __
Opinions expressed here are my own and not those of... (__)|-</-\(__ |__ -_
------------------------------
Date: Tue, 10 Feb 1998 01:12:07 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Joe McMahon <joe.mcmahon@gsfc.nasa.gov>
Subject: Re: How to tell if your CGI-related question belongs in comp.lang.perl.misc
Message-Id: <34DFEFC1.51218143@coos.dartmouth.edu>
[posted and mailed
Joe McMahon wrote:
>
> Try comp.infosystems.cgi.authoring for help on how to get started writing
> CGI programs. You're not ready for comp.lang.perl.misc yet.
That's a good idea, direct them to a newsgroup that doesn't exist.
That should be comp.infosystems.www.authoring.cgi
Chipmunk
------------------------------
Date: 10 Feb 1998 07:33:56 GMT
From: Rene Hertell <t1812@nospam.net>
Subject: Location-variable
Message-Id: <6bovt4$904@myy.helia.fi>
Howdy!
Is there any other variable instad of the location: variable available.
I'm trying to configure script that should run on the microsoft personal
webserver 1.0a that does not return the www-address, but returns and
errormessage instead. The same identical script runs without problems on a
linux machine, but it fails ont the win32-platform.
Any suggestions?
Reni
___
You got this message from:
Rene
t1812@myy.helia.spam-hater.fi
------------------------------
Date: Tue, 10 Feb 1998 01:34:47 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: More regular expressions
Message-Id: <34DFF506.53C7C7A1@coos.dartmouth.edu>
Michael Fuhr wrote:
>
> Ummm...where did I say that it can't be done? If you had read the
> section I mentioned, you'd see that it mentions how it *can* be done.
Woops, you didn't. Sorry!
Chipmunk
------------------------------
Date: Tue, 10 Feb 98 02:36:21 +0400
From: "Ben Coleman" <bcoleman@mindspring.com>
Subject: Re: Perl documentation (was re: Perl Year 2000 ...)
Message-Id: <zxpwyoicymgzils.pminews@user-38lcp82.dialup.mindspring.com>
On 10 Feb 1998 05:35:54 GMT, Ilya Zakharevich wrote:
>[A complimentary Cc of this posting was sent to Ben Coleman
><bcoleman@mindspring.com>],
>who wrote in article <idzmeiqsqwuuryy.pminews@user-38lcp82.dialup.mindspring.com>:
>> Odd. On all 3 of the Perls I have access to (5.00401 on OS/2 and
>> Linux, and the standard Win32 binary distribution), perldoc -f
>> doesn't page its output, but does page normal POD output. Am I just
>> holding my mouth wrong?
>
>You got me! Indeed, I missed the significance of -f!
Which brings me back to my original question - is there a reason for
this?
Ben
--
Ben Coleman NJ8J | The attempt to legislatively
Internet: bcoleman@mindspring.com | micromanage equality results, at
http://bcoleman.home.mindspring.com/ | best, in equal misery for all.
------------------------------
Date: Tue, 10 Feb 1998 06:44:43 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: reading in a file to an associative array
Message-Id: <34dfe94b.524144494f47414741@radiogaga.harz.de>
Brian Charles (charlesb@ccmail.orst.edu) wrote:
: I have a file with name and email separated by a '|'
: I want to use a while loop to read it in as an associative array, the
: name being the key and email the value. How do I do that? I'm used to
: just scalar variables.
my %hash;
while (<FILE>)
{
my ($name,$email) = split /|/, $_, 2;
$hash{$name} = $email;
}
I suggest you read the perldata POD page for a start. You won't get very
far using only scalars... ;-)
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
Ceterum censeo | work: mv@pdv-systeme.de
Redmondem delendam esse. | http://www.pdv-systeme.de/users/martinv/
| home: martin@radiogaga.harz.de
------------------------------
Date: 9 Feb 1998 22:34:05 -0600
From: banman@earth.execpc.com (Brian M. Beaulieu)
Subject: Re: Sharing variables between scripts
Message-Id: <6bolbu$4f0@newsops.execpc.com>
Brian M. Beaulieu (banman@earth.execpc.com) wrote:
: I've seen this done before but can't recall how again. All I need to do
: is share variables that are located in 1 perl script between other scripts
: .. I've tried 'require' .. that didn't seem to do the trick (and I did
: give it the relative path to the script with my variables)
Elaborating....
one perl script .. has $foo = 'bar';
but say there are 50 variables.. in that one script..
and I want another script to use the variable, not necessarily
the values.. the script that contains the variables.. *just* contains
variables.. no other functions..
To make it simple.. I have for instance 30 scripts.. CGI or non CGI .. that
are going to be using the same variables..and say there are 30 variables...
is there a simple way to 'include' or 'require' a script.pl that has the
variables listed. Maybe this can't be done.. thought it could be.
Thanks,
Brian
------------------------------
Date: Tue, 10 Feb 1998 15:12:50 +0800
From: Gilles Chong <glchy@csah.com>
Subject: Too simple to ask but then ....
Message-Id: <34DFFDF1.891FF917@csah.com>
Hi guys n gals,
Im getting into tt PERL thing n would like to do an extremely simple
thing.
I wanna display a list of files sitting on a directory on my Unix system
on a web page. How to proceed? Actually I can use the "system" command
rite? Like: system "cd /X/Y/Z; ls -l". But then where will the list be
displayed? N if i wanna display it on my webpage, do i get the list
first in a string n then parse it n display the parsed string in my HTML
page?
Surely there is a much easier way to do it, rite?
Help help! Pls advise me thru email.
Fanx
G.
--
Gilles Chong (glchy@csah.com, glchy@csa.com.sg)
Systems Engineer, Internet Division
CSA Holdings Ltd, Singapore.
------------------------------
Date: 10 Feb 1998 07:54:56 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Too simple to ask but then ....
Message-Id: <6bp14g$7k$1@marina.cinenet.net>
Gilles Chong (glchy@csah.com) wrote:
: I wanna display a list of files sitting on a directory on my Unix system
: on a web page. How to proceed? Actually I can use the "system" command
: rite? Like: system "cd /X/Y/Z; ls -l". But then where will the list be
: displayed? N if i wanna display it on my webpage, do i get the list
: first in a string n then parse it n display the parsed string in my HTML
: page?
: Surely there is a much easier way to do it, rite?
Um, 'rite'. Look up file globbing, either via the glob or <*>
operators. (I've never liked the latter, it's too damn much like a
filehandle reader...but I digress.)
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Tue, 10 Feb 1998 07:56:37 GMT
From: joshaugh@uk.oracle.com (Jamie O'Shaughnessy)
Subject: Re: Too simple to ask but then ....
Message-Id: <34e00765.578527248@newshost.us.oracle.com>
On Tue, 10 Feb 1998 15:12:50 +0800, Gilles Chong <glchy@csah.com> wrote:
>Hi guys n gals,
>Im getting into tt PERL thing n would like to do an extremely simple
>thing.
>I wanna display a list of files sitting on a directory on my Unix system
>on a web page. How to proceed? Actually I can use the "system" command
Usually there's some kind of directory browsing on/off option on your web
server - if you just want people to browse directories to download stuff. If
you want to do something more fancy...
>rite? Like: system "cd /X/Y/Z; ls -l". But then where will the list be
>displayed? N if i wanna display it on my webpage, do i get the list
You sort of can do it that way. When a perl script is running after being
called as a CGI script from your web server, whatever you write to STDOUT will
be piped back and displayed in the browser, so you kind of can do it how you
suggest.
>first in a string n then parse it n display the parsed string in my HTML
>page?
>Surely there is a much easier way to do it, rite?
Use opendir/readdir/closedir to read the contents of your directory and then
format it with a nice bit of HTML and write it to STDOUT.
Jamie
___________________________________________________________________________
Jamie O'Shaughnessy Work: joshaugh @ uk.oracle.com
Oracle C++ Object Layer Generator Team
______________________________________________________ __ __ _ __ . __
Opinions expressed here are my own and not those of... (__)|-</-\(__ |__ -_
------------------------------
Date: Tue, 10 Feb 1998 02:17:26 GMT
From: JWears@msn.com
Subject: What can I do when Perl panics?
Message-Id: <34dfb36a.8970873@news.idt.net>
I have a long-running Perl script which dispatches processes as
prerequisites are completed and system resources are avaliable. Twice
it has died with a "panic: leaving_scope inconsistency" message. The
instruction flagged id a text-comparison in an if statement, which
compares the control variable of a foreach loop to the response from a
message to objects in an array in a nested foreach loop.
It has run sucessfully with 50+ processes in the inner array looped
over, but failed twice (after running 18-20 hours) when the array size
is over 100. I need to get it over 600. Is there any hope? Should I
find a different algorithm? Is there any way to get more information
on just what goes wrong, or why, or when?
This is running in Perl 5.003 under AIX 4.1.5 on an RS/6000-40.
------------------------------
Date: 10 Feb 1998 08:15:31 +0100
From: Zooko Journeyman <zooko@xs4all.nl>
Subject: Re: Year 2000 Compliance: Lawyers, Liars, and Perl
Message-Id: <6bouqj$lm1$1@xs1.xs4all.nl>
Tom Christiansen <tchrist@mox.perl.com> wrote:
>
>I'm still thinking about the issue of people learning bad
>habits from the bad old days of Cobol.
I'm not exactly a geezer-- rather the opposite.
Last year, 1997, after having warned my family to prepare their
assets for Y2K catastrophe, I accidentally coded up a nice, fat
canonical Y2K bug in Perl. The Perl util I was writing, which
would be shipped to my employer's clients for integration into
their systems, needed to output timestamps. I glanced at the
Perl time functions, said "Holy shit! Looks like the Y2K
bug!", put "printf("19%2d", time);" for the timestamp, and made
a note to myself to check up on that bug.
Fortunately I got around to checking up on it before the
utility shipped to any of our customers. When I did so a
co-worker, friend and Real Perl Hacker, Branko L, pointed
out to me what my mistake was, and all was solved. If that
utility _had_ shipped, there is a high probability that it
would have still been in use (that, in fact, the bug-patch we
would later have to ship would never be applied) at the moment
of truth.
But my point is, this kind of bug is not indigenous to
IBM 1401's, COBOL, the 1960's, or whatever. My guess is that
a fair fraction of the damage will be completely unconnected
(at least, in the direct causal sense) with such legacy
systems.
Regards,
Zooko, Journeyman Hacker
"Half-assed programming was a time-filler that, like knitting,
must date to the beginning of the human experience."
-- Vernor Vinge, _A_Fire_Upon_the_Deep_
------------------------------
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 1844
**************************************