[7711] in Perl-Users-Digest
Perl-Users Digest, Issue: 1337 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 18 11:18:25 1997
Date: Tue, 18 Nov 97 08: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 Tue, 18 Nov 1997 Volume: 8 Number: 1337
Today's topics:
An elegant solution wanted for removing .. in path <shimpei@socrates.caltech.edu>
Re: An elegant solution wanted for removing .. in path <rjc@liddell.cstr.ed.ac.uk>
Re: An elegant solution wanted for removing .. in path (Lloyd Zusman)
Re: An elegant solution wanted for removing .. in path <mjkinnun@ling.helsinki.fi>
Re: An elegant solution wanted for removing .. in path (Gabor)
Re: An elegant solution wanted for removing .. in path (Marek Rouchal)
Building a "...special verions of perl." <bfogarty@ford.com>
Re: Can't make DOS box under Win95 "see" .pl extensions <emorr@fast.net>
Re: CGI Script Output....help. <accu-scan@worldnet.att.net>
Re: Chomp vs Chop <mpezzuto@link.com>
Re: control characters (Gabor)
Dynamic loading in embedded perl <gautamk@bremer-inc.com>
Re: Error 500 on server??? <webmaster@fccj.cc.fl.us>
Re: Error 500 on server??? <accu-scan@worldnet.att.net>
Re: eval and scoping problem <tchrist@mox.perl.com>
Re: eval and scoping problem <lucs@cam.org>
Re: eval and scoping problem (Mike Stok)
Re: exclusive file rights <camerond@mail.uca.edu>
Re: exclusive file rights (Jeremy D. Zawodny)
Re: File Handling in Perl <rootbeer@teleport.com>
Re: header files for scripts run from procmail? <mchase@ix.netcom.com>
HELP - Perl CGI script stops working after SQL query <u2537@shurflo.com>
Re: How to determine absolute file path on UNIX (Alfred von Campe)
Internet Explorer -> Perl CGI Problems? dg50@chrysler.com
Newbie question regarding DNS (Chris Raettig)
Re: nt build of perl5.004_04 <camerond@mail.uca.edu>
Re: Removing text regex? (William L. Gorder)
Re: sequence point? (Gabor)
Re: sequence point? <rootbeer@teleport.com>
Re: setenv problem (Gabor)
sfio with Perl5.004 on hpux 9 problems <s.brugmans@best.ms.philips.com>
Re: User restriction <rootbeer@teleport.com>
Re: Where can I get the pre-compiled binariy "undump" f <mchase@ix.netcom.com>
Win32 Perl and NT IIS <debbi.stott@redact.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Nov 1997 12:37:56 GMT
From: Shimpei Yamashita <shimpei@socrates.caltech.edu>
Subject: An elegant solution wanted for removing .. in path
Message-Id: <64s274$6rt@gap.cco.caltech.edu>
I was writing a perl script last night that required me to change a
pathname like
/usr/blah/blah/blah/blah/../../../../local/lib/perl5/5.004_04/i586_linux/
into its canonical (and human readable) form of
/usr/local/lib/perl5/5.004_04/i586_linux/
I have thought about this for a while, and while it is not hard to
come up with solutions, the only solutions I have found so far are
incredibly ugly (split by / into an array, reconstruct path one
directory at a time)--not any more elegant than what I would write in
C. But this is perl, and this is a very simple problem for a human
being to do mechanically at sight, and I'm sure there is a one-liner
solution just waiting for me somewhere.
Any suggestions?
Shimpei.
PS Note also that this is purely a text manipulation problem of folding
away those ..'s; you do not hav to worry about any of the directories
along the way being symbolic links or anything. In fact, the solution
should not hit the filesystem at all (i.e., you are not allowed to
"cheat" by chdir'ing into the path name and returning `pwd`).
--
Shimpei Yamashita <http://www.patnet.caltech.edu/%7Eshimpei/>
------------------------------
Date: 18 Nov 1997 12:58:12 +0000
From: Richard Caley <rjc@liddell.cstr.ed.ac.uk>
Subject: Re: An elegant solution wanted for removing .. in path
Message-Id: <eyhbtziuzob.fsf@liddell.cstr.ed.ac.uk>
In article <64s274$6rt@gap.cco.caltech.edu>, Shimpei Yamashita (sy) writes:
sy> /usr/blah/blah/blah/blah/../../../../local/lib/perl5/5.004_04/i586_linux/
sy> into its canonical (and human readable) form of
sy> /usr/local/lib/perl5/5.004_04/i586_linux/
Er, am I missing something? ...
$filename =~ s%^(/usr)/.*(/local/.*?)%$1$2%;
--
rjc@cstr.ed.ac.uk _O_
|<
------------------------------
Date: 18 Nov 1997 14:03:48 GMT
From: ljz@asfast.com (Lloyd Zusman)
Subject: Re: An elegant solution wanted for removing .. in path
Message-Id: <slrn6737pd.fv.ljz@ljz.asfast.net>
On 18 Nov 1997 12:58:12 +0000, Richard Caley <rjc@liddell.cstr.ed.ac.uk> wrote:
> In article <64s274$6rt@gap.cco.caltech.edu>, Shimpei Yamashita (sy) writes:
>
> sy> /usr/blah/blah/blah/blah/../../../../local/lib/perl5/5.004_04/i586_linux/
>
> sy> into its canonical (and human readable) form of
>
> sy> /usr/local/lib/perl5/5.004_04/i586_linux/
>
> Er, am I missing something? ...
>
> $filename =~ s%^(/usr)/.*(/local/.*?)%$1$2%;
Unless you're being facetious, it seems so ...
Your solution won't work on the following path name, nor on an
infinite number of others:
/usr/local/blah/blah/blah/blah/../../../../lib/perl5/5.004_04/i586_linux/
The original poster was almost certainly looking for a general
solution to the problem, not just a solution for the specific case
supplied. If a specific solution was desired, no regexp would be
necessary at all, only the following line:
$solution = '/usr/local/lib/perl5/5.004_04/i586_linux/';
Here's one possible starting point for a general solution which doesn't
hit the file system (as per the original request):
while ($path =~ s%[^/]+/\.\./%%) {}
$path =~ s%/\./%/%g;
$path =~ s%//+%/%g;
$path =~ s%^\./%%;
This also handles paths like this:
/this/is/./a/sample/path
And this:
/this/is/another///////sample/path
And this:
./this/is/yet/another
However, it isn't a one-liner, and I don't recall if the original
poster requested one.
--
Lloyd Zusman
ljz@asfast.com
------------------------------
Date: 18 Nov 1997 15:57:07 +0200
From: Matti Kinnunen <mjkinnun@ling.helsinki.fi>
Subject: Re: An elegant solution wanted for removing .. in path
Message-Id: <m6iutqqp8s.fsf@hyry.helsinki.fi>
Shimpei Yamashita <shimpei@socrates.caltech.edu> writes:
> /usr/blah/blah/blah/blah/../../../../local/lib/perl5/5.004_04/i586_linux/
> into its canonical (and human readable) form of
> /usr/local/lib/perl5/5.004_04/i586_linux/
>
Try this
##
while (<>) {
$line = $_;
print "$line";
while ($line =~ /\.\./) {
$line =~ s![^\./]*?/\.\./!!; # black magic
print "\t$line";
}
}
##
Here is a sample run
joenpelto:~/tmp$ echo '/usr/blah/blah/blah/blah/../../../../local/lib/perl5/5.004_04/i586_linux/' | testaus.pl
/usr/blah/blah/blah/blah/../../../../local/lib/perl5/5.004_04/i586_linux/
/usr/blah/blah/blah/../../../local/lib/perl5/5.004_04/i586_linux/
/usr/blah/blah/../../local/lib/perl5/5.004_04/i586_linux/
/usr/blah/../local/lib/perl5/5.004_04/i586_linux/
/usr/local/lib/perl5/5.004_04/i586_linux/
--
* matti.kinnunen@helsinki.fi http://universe.pc.helsinki.fi/~matti *
* !!! +358-(0)40-593 50 91 but try first +358-(0)9-191 23978 *
------------------------------
Date: 18 Nov 1997 13:47:32 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: An elegant solution wanted for removing .. in path
Message-Id: <slrn6736lt.a6d.gabor@vinyl.quickweb.com>
In article <64s274$6rt@gap.cco.caltech.edu>, Shimpei Yamashita wrote:
>I was writing a perl script last night that required me to change a
>pathname like
>
>/usr/blah/blah/blah/blah/../../../../local/lib/perl5/5.004_04/i586_linux/
>
>into its canonical (and human readable) form of
>
>/usr/local/lib/perl5/5.004_04/i586_linux/
>
$_='/usr/blah/blah/blah/blah/../../../../local/lib/perl5/5.004_04/i586_linux/';
1 while s(\w+/\.\./)();
print $_,"\n";
gabor.
--
Just don't compare it with a real language, or you'll be unhappy... :-)
-- Larry Wall in <1992May12.190238.5667@netlabs.com>
mharris@gov.on.ca he, he, he
------------------------------
Date: 18 Nov 1997 16:39:03 +0100
From: Marek.Rouchal@-nospam-hl.siemens.de (Marek Rouchal)
Subject: Re: An elegant solution wanted for removing .. in path
Message-Id: <64scqn$fl4@buffalo.HL.Siemens.DE>
In article <slrn6736lt.a6d.gabor@vinyl.quickweb.com>, gabor@vinyl.quickweb.com (Gabor) writes:
> In article <64s274$6rt@gap.cco.caltech.edu>, Shimpei Yamashita wrote:
> >I was writing a perl script last night that required me to change a
> >pathname like
> >
> >/usr/blah/blah/blah/blah/../../../../local/lib/perl5/5.004_04/i586_linux/
> >
> >into its canonical (and human readable) form of
> >
> >/usr/local/lib/perl5/5.004_04/i586_linux/
> >
> $_='/usr/blah/blah/blah/blah/../../../../local/lib/perl5/5.004_04/i586_linux/';
> 1 while s(\w+/\.\./)();
> print $_,"\n";
This works nicely, but only if there are no symbolic links involved in the
'blah' directories. Imagine
/usr/blah points to /usr/foo/foo/foo
then /usr/blah/../../../local/lib/perl5/and_so_on
is in fact /usr/local/lib/perl5/and_so_on
So a 'proper' resolution script would have to either
1. check every subdir for symbolic links or
2. use the shell (which isn't the perl way, I know) :
$_='/usr/blah/blah/blah/blah/../../../../local/lib/perl5/5.004_04/i586_linux/';
$dir = $_;
$dir =~ s#/[^/+]/?$## unless(-d $d); # strip filename
$resolved_dir = `cd $dir; pwd`;
HTH,
Marek
PS. If you want to reply by Email, please remove -nospam- from the address.
--
Marek Rouchal Phone : +49 89/636-25849
SIEMENS AG, HL CAD SYS Fax : +49 89/636-23650
Balanstr. 73 mailto:Marek.Rouchal@-nospam-hl.siemens.de
81541 Muenchen PCmail:Marek.Rouchal.PC@-nospam-hl.siemens.de
------------------------------
Date: Tue, 18 Nov 1997 09:40:33 -0500
From: Ben Fogarty <bfogarty@ford.com>
Subject: Building a "...special verions of perl."
Message-Id: <3471A8E1.C262AC16@ford.com>
I don't consider myself an expert in perl; I have been
using it for a couple of years or so wherever it seemed
applicable, but I find I am using it more and more with
time because of familiarity, and because it seems the
best routine for any applications that are more than a
line or two of scripting. This said, I have a problem that
someone more familiar with the esoteric idiosyncrasies
might be able to help me solve.
Our skilled and fearless developer provided the means of
building "...your own special copy of perl." with c
subroutines linked into same. I have recently taken over
a position with my company where I have inherited such a
special version of perl that has some c routines as a part
of the build. The old copy of perl was 4.36 and I have been
upgrading all copies on the systems in the network to
5.004. I have finally come to the point where I have to
deal with the special version with the c subroutines built
in. I found the home directory and found the Make file.
I looked over the Makefile, and the initial routine it
is trying to compile is uperl within the perl source directory.
I looked for that routine and it does not exist. I looked
for it in a tar version of perl 4.36 and it did not exist.
I am writing to see if anyone reading this has built a
version of perl with c subroutines and could help me find
or interpret the make file to build our special version.
The Makefile in question:
SRC = ..
GLOBINCS = -I$(CIM_HOME)/include
LOCINCS =
LIBS = /usr/lib/cim/libcimdtps.sl `. $(SRC)/config.sh; echo $$libs`
CFLAGS = `. $(SRC)/config.sh; echo $$ccflags`
dtpsperl: $(SRC)/uperl.o dtpsusersub.o dtpsusub.o
cc $(SRC)/uperl.o dtpsusersub.o dtpsusub.o $(LIBS) -o dtpsperl
dtpsusersub.o: dtpsusersub.c
cc -c -I$(SRC) $(GLOBINCS) $(CFLAGS) dtpsusersub.c
dtpsusub.o: dtpsusub.c
cc -c -D_CLASSIC_ANSI_TYPES -I$(CIM_HOME)/include -I$(SRC)
$(GLOBINCS) $(CFLAGS) dtpsusub.c
dtpsusub.c: dtpsusub.mus
mus dtpsusub.mus >dtpsusub.c
I really would appreciate any help you could give in
solving this problem. Thanks very much.
Ben
------------------------------
Date: Tue, 18 Nov 1997 14:34:31 GMT
From: "Edward Morris, Jr." <emorr@fast.net>
Subject: Re: Can't make DOS box under Win95 "see" .pl extensions...
Message-Id: <3471A791.4087@fast.net>
Hey! Thanks for the quick response! Do you mean that is Perl in my PATH?
It is! I can run a script like this
C:>perl cpmapgen.pl args...
But NOT like this
C:>cpmapgen.pl args...
Or do you mean there's SOMETHING ELSE with autoexec.bat and file
extension mapping I need to do???? Thanks so much.
ed
p.s. etta, i wanted to mail you, but couldn't.
etta wrote:
>
> Is perl set up in your autoexe.bat file? Just a thought!
>
> etta
>
> Edward W. Morris, Jr. <emorr@fast.net> wrote in article
> <01bcf3c2$8ffda120$0891f5ce@emorris>...
> > Hey. I've installed Perl build 5.003_07 for Win32 on my Win95 box. I
> can
> > double click on a .pl script and it runs, but I can't run one from the
> Dos
> > box. He says Unknown command, so I know he's not reading .pl extension
> > like he would .BAT or .EXE. What gives? I know my registry is correct.
> I
> > checked under Classes for .pl, which has Perl in it, and Perl has the
> > proper registry keys. they're the same as NT, which DOESN'T have this
> > problem. Thanks in advance!!!
> > --
> > email: emorr AT fast.net
> > web: http://www.users.fast.net/~emorr
> >
------------------------------
Date: Tue, 18 Nov 1997 09:20:23 -0600
From: Mike Snyder <accu-scan@worldnet.att.net>
To: Michael Butler <mgb@nbnet.nb.ca>
Subject: Re: CGI Script Output....help.
Message-Id: <64sbv1$13r@mtinsc05.worldnet.att.net>
> As you can see this is a simple script but when I hit the submit button
> on my browser I get a message box asking me what file to print to. If I
> select a file then what I get is my CGI script printed exactly as above
> into the file. It never seems to get returned to the browser.
Hi Michael,
I too am new to this and had the exact same problem. First of all, make
sure you have a web server running. In my inexperience, I didn't realize
that you can't just run CGI in your web browser, because it's the
"server" that is responsible for actually running the program.
I am using MS Personal Web Server which came free with Frontpage '97.
There are others... My roommate suggested "omni-httpd" and I found them
easily at www.hotbot.com by searching for "omni-httpd". Anyway, as
somebody else pointed out, the server is misconfigured.
I had the same problem of it thinking it had to "save" the script as a
file. This is because the server has no idea what a .PL or a .CGI file
is for... and any file that has an unrecognized extension will be saved
just like when you click on a .ZIP file at a web page.
First step is to get a personal web server up & running. If you're using
Windows '95 I can tell you what I did (I got this from a faq). If you're
using Microsoft Personal Web Server:
run REGEDIT.EXE -- be careful, you're in the registry now.
click on--
HKEY_LOCAL_MACHINE
System
CurrentContrlSet
Services
W3Svc
Now you should have a folder under W3Svc called Parameters. This is part
of your personal web server. open it up and on the right hand side
you'll make a new string with the name of ---> .pl <---- which is
the extension. Then modify it and make the command like the path to PERL
plus %S %S. Mine is "c:\perl\bin\perl.exe %s %s" and it works.
By doing this, you're configuring your personal web server to
"recognize" the .pl extension as CGI. You could do the same with other
languages too, I'm sure, by configuring other extensions & the program
that runs them.
If You're not in Windows 95 or not using MS PWS, what you have to do may
be a little different. Maybe this will give you an idea of what to try
next.
Mike.
------------------------------
Date: Tue, 18 Nov 1997 10:53:20 -0500
From: Matt Pezzuto <mpezzuto@link.com>
Subject: Re: Chomp vs Chop
Message-Id: <3471B9F0.2781@link.com>
"When using Chop, it is almost always used to remove an eol character.
The typical reason would be to remove eol's from the following sample
of data:
@dirlist=`ls -1`;
foreach (@dirlist)
{
chop;
}
ls -1 forces the ls output into a single column of data (which is the
default for outputting data to non-STDIO outputs). Perl also breaks the
list into different array entries on the eol. So, if there isn't an
eol, then we can't have an array. If no array, ls is really broken
(but this is a simplistic example). So, since we know an eol must be
the delimiter between entries, why can't I just non-discriminantly chop
off the last character?"
Thanks.
Rich Weber
------------------------------
Date: 18 Nov 1997 13:34:11 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: control characters
Message-Id: <slrn6735st.a6d.gabor@vinyl.quickweb.com>
In article <comdog-ya02408000R1711972342550001@news.panix.com>, brian
d foy wrote:
>In article <Pine.OSF.3.95q.971117214552.25328A-100000@osf1.gmu.edu>,
>smantri@gmu.edu wrote:
>
>>Can anyone tell me how to remove any control character??????????
>
>how about just using their octal values?
>
> tr/\000-\037//;
This merely will count the control chars and then throw away the
count. ;-)
tr/\000-\037//d;
^ need the 'd' to actually delete the found chars
of course this will also remove newlines and tabs. May not be what
the guy really wants. :-)
>
>of course, you might want to think about that a bit before doing it ;)
Yip!
>
>--
>brian d foy <comdog@computerdog.com>
>NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
>CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
gabor.
--
Well, enough clowning around. Perl is, in intent, a cleaned up and
summarized version of that wonderful semi-natural language known as
"Unix".
-- Larry Wall in <1994Apr6.184419.3687@netlabs.com>
mharris@gov.on.ca he, he, he
------------------------------
Date: 18 Nov 1997 15:41:55 GMT
From: "Kamal Gautam" <gautamk@bremer-inc.com>
Subject: Dynamic loading in embedded perl
Message-Id: <01bcf439$2f01eda0$5f21f9cc@falcon.bremer-inc.com>
We're using the perl libraries from perl5_00402-bindist04 for Win32.
We have a script that dynamically loads modules and works with the Perl
executable. But when we try to run the same script interpreted through the
libraries calling from C, perl_parse fails:
Can't load module DBI, dynamic loading not available in this perl.
(You may need to build a new perl executable which either supports dynamic
loading or has the DBI module statically linked into it.)
How can we get the dynamic loading in embedded perl?
Kamal
------------------------------
Date: Tue, 18 Nov 1997 07:14:52 -0500
From: "Bill Jones" <webmaster@fccj.cc.fl.us>
Subject: Re: Error 500 on server???
Message-Id: <3471879f.0@usenet.fccj.cc.fl.us>
Common problem, however, you did not supply enough info for any of us to
offer help.
You should look thru dejanews and see similar problems - I am sure your
problem fits in there somewhere.
Bill
HSTUDIOSNY wrote in message
<19971117093600.EAA06289@ladder02.news.aol.com>...
>
>I recently learned perl for my website and tested it with the DOS version.
I
> put the script on the website, changed the mode to executable and when I
went
> to netscape and ran the script I got Error 500, Internal error.
>
>The path for the perl interpreter is correct:
>
>#!/usr/lib/perl
>
>Any other suggestions on what is causing this error?
>
>- Jon
>
------------------------------
Date: Tue, 18 Nov 1997 09:24:40 -0600
From: Mike Snyder <accu-scan@worldnet.att.net>
To: HSTUDIOSNY <hstudiosny@aol.com>
Subject: Re: Error 500 on server???
Message-Id: <64sc71$13r@mtinsc05.worldnet.att.net>
> I recently learned perl for my website and tested it with the DOS version. I
> put the script on the website, changed the mode to executable and when I went
> to netscape and ran the script I got Error 500, Internal error.
I was using FrontPage personal Web Server and got this same error. I
then got Frontpage '97 which came with Microsoft Personal Web Server and
installed that it lo & behold it worked.
You have to configure your system to recognize .pl or .cgi as a CGI
script. I did this based on information in a FAQ I found by going into
REGEDIT to
HKEY_LOCAL_MACHINE->System->CurrentControlSet->Services->W3Svc->Parameters
then make a new string tag called ".pl" with the text
"c:\perl\bin\perl.exe %s %s" and it's working fine.
So, either your local web server isn't capable of CGI, or it's just not
set up to handle it based on the .pl extension.
Good Luck!
Mike.
------------------------------
Date: 18 Nov 1997 13:14:30 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: eval and scoping problem
Message-Id: <64s4bm$ns$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Luc St-Louis <lucs@cam.org> writes:
: sub Foo { ... eval "\$pkg::$Var = \'$Val\'"; ... }
Kill the eval:
sub Foo { ... ${ $pkg . "::$Var" } = $Val; ... }
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
There's going to be no serious problem after this. --Ken Thompson
------------------------------
Date: Tue, 18 Nov 1997 10:13:32 -0500
From: Luc St-Louis <lucs@cam.org>
Subject: Re: eval and scoping problem
Message-Id: <3471B09C.6DE7A4A0@cam.org>
Tom Christiansen wrote:
> Kill the eval:
> sub Foo { ... ${ $pkg . "::$Var" } = $Val; ... }
Thanks for pointing that out. Unfortunately, 'use strict' disallows
this. I see three things I can do:
1. Put a 'no strict' inside Foo()
2. Use eval (like in my example)
3. Get rid of 'use strict' completely.
Maybe 'use strict' is overkill for what I'm doing. I use it because I
get the feeling it will catch some unexpected errors (I will handle the
expected ones :-). What do you think?
By the way, glad to see you're still reading the newsgroup.
Luc
lucs@cam.org
------------------------------
Date: 18 Nov 1997 15:36:11 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: eval and scoping problem
Message-Id: <64sclb$6vs@news-central.tiac.net>
In article <3471B09C.6DE7A4A0@cam.org>, Luc St-Louis <lucs@cam.org> wrote:
>Tom Christiansen wrote:
>
>> Kill the eval:
>> sub Foo { ... ${ $pkg . "::$Var" } = $Val; ... }
>
>Thanks for pointing that out. Unfortunately, 'use strict' disallows
>this. I see three things I can do:
>
>1. Put a 'no strict' inside Foo()
>2. Use eval (like in my example)
>3. Get rid of 'use strict' completely.
>
>Maybe 'use strict' is overkill for what I'm doing. I use it because I
>get the feeling it will catch some unexpected errors (I will handle the
>expected ones :-). What do you think?
>
>By the way, glad to see you're still reading the newsgroup.
What I try to do is have use strict in effect as much as I can and then
explicitly allow the thing I'm interested in in the smallest "natural"
block (i.e. I don't add a bare block unless I'm in the middle of some long
linear code sequence)
sub Foo {
no strict 'refs';
...
${ $pkg . "::$Var" } = $Val;
...
}
I think this gives a maintainer a fair indication of what to expect and
doesn't compromise the benefits of use strict for the rest of the script.
Of course that's just me, I make mistakes more often than not ;-)
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Tue, 18 Nov 1997 09:10:27 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: exclusive file rights
Message-Id: <3471AFE3.E7FAAB6B@mail.uca.edu>
Matt Dowell wrote:
>
> We are running HP-UX and for some reason flock is not in the OS. So
> here is what I did to get around this. I think it's better anyways.
>
> I first lock the file, [snip standard flock workaround]
> Works for me.
This answer comes up time and again to the "flock" question (I brought
it up once, since flock is not supported on Win95), and the rejoinder
always is:
"It is not an atomic solution. Another process *can* start the same perl
script and get to the check line before this process creates the file,
thus invalidating the lock."
Point well taken, but I have a practical question about that, which I
haven't seen answered:
How long does it take to create a file as part of an unless ()
statement, particularly if you are creating this file on a RAM disk
(wouldn't have to be a big one) with nsec read/write times, not on a HD
with msec read/write times? Shouldn't this almost completely fix the
problem unless you are getting 16.375 gigaaccesses per day (assuming
they are somewhat evenly distributed over the 12-hour workday, and I
don't think Win95 would be the OS of choice there, anyway)?
Anybody have any benchmarks or want to take a WAG at this? Inquiring
minds want to know.
Cameron
------------------------------
Date: Tue, 18 Nov 1997 15:38:57 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: exclusive file rights
Message-Id: <3471b5be.406219072@igate.hst.moc.com>
[original author automagically cc'd via e-mail]
On Tue, 18 Nov 1997 09:10:27 -0600, Cameron Dorey
<camerond@mail.uca.edu> wrote:
>How long does it take to create a file as part of an unless ()
>statement, particularly if you are creating this file on a RAM disk
>(wouldn't have to be a big one) with nsec read/write times, not on a HD
>with msec read/write times? Shouldn't this almost completely fix the
>problem unless you are getting 16.375 gigaaccesses per day (assuming
>they are somewhat evenly distributed over the 12-hour workday, and I
>don't think Win95 would be the OS of choice there, anyway)?
>
>Anybody have any benchmarks or want to take a WAG at this? Inquiring
>minds want to know.
Talk to anyone who worries about locking (OS developers, database
developers, and so on) and what you'll hear is that it is *not* a
matter of speed. It's all about timing.
In a multitasking OS, you *never* know when context switching will
take place. Murphy's Law generally applies. Assume that your code will
be swapped out (briefly) while an identical copy of your code runs
thru the same critical section.
The whole point of using atomic operations is that they are
atomic--meaning that they are small units of code which are ALWAYS
executed as such.
Make sense?
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: Tue, 18 Nov 1997 07:46:38 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Andrew <andrew2@one.net>
Subject: Re: File Handling in Perl
Message-Id: <Pine.GSO.3.96.971118074513.17802P-100000@usertest.teleport.com>
On Tue, 18 Nov 1997, Andrew wrote:
> Is it possible create/open a file, using a filename that is a variable?
Yes, and the docs should show you how to do it.
> I would basically like to use
> their email addresses for the file name.
>
> Is this possible?
Depends upon whether their email address is a valid filename on your
system. But you could keep a small database mapping email addresses to
unique file numbers, or some such. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Mon, 17 Nov 1997 17:13:33 -0800
From: "Michael A. Chase" <mchase@ix.netcom.com>
Subject: Re: header files for scripts run from procmail?
Message-Id: <64s0oo$ef1@dfw-ixnews9.ix.netcom.com>
I frequenly paste this somewhere near the top of my scripts:
BEGIN {
( $sCmdDir, $sCmdName ) = ( $0 =~ m#^(.*)?/(.*)# );
$sCmdName = $0, $sCmdDir = "." if ! $sCmdDir;
$sCmdName = $sCmdDir, $sCmdDir = "." if ! $sCmdName;
unshift @INC, $sCmdDir;
}
If you have a recent enough version of Perl you should 'use FindBin;' and
'use lib' instead.
BTW, $PERL5LIB also provides direcories to @INC.
--
Mac :}) mchase@ix.netcom.com
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/CC/E/IT/O d s+:+ a+ C++$ ULUHSC*++$ P++$ L+(++) E- W++ N++ o? K-? w+
O M- V- PS+@ PE Y+ PGP+ t+ 5++ X R tv b+++(++++) DI++(+++) D? G e++ h---
r+++ y+
------END GEEK CODE BLOCK------
Doug Jacobs wrote in message <34695ad4.0@news.tsoft.net>...
>
>Oops, I left out a detail :(
>
>Thanks for the information and pointers.
>
>I have 2 directories, /dev & /prod (Development, Production).
>
>Each have their own libraries and scripts. I don't want /dev using
>stuff in /prod and vice-versa. These scripts may be called 1 of 2
>ways - Procmail or through a webpage. (there are /prod and /dev
>versions of both my procmailrc and webpages.)
>
>I would like to modify stuff in /dev and copy it over to /prod without
>having to make any changes to the scripts. This includes fixing
>paths (used in "use lib..." for instance.)
>
>A partial solution would be to have Procmail call the script like so:
>
>perl5 -I/dev /dev/script.pl
>
>or
>
>perl5 -I/prod /prod/script.pl
------------------------------
Date: Tue, 18 Nov 1997 07:23:27 -0800
From: Thomas Beardshear <u2537@shurflo.com>
Subject: HELP - Perl CGI script stops working after SQL query
Message-Id: <3471B2EF.F4409A76@shurflo.com>
I'm trying to write a few simple programs to access data through our
intranet. The script works fine from the bash shell but does not print
anything after the query statement when run on a browser. Anyone have
any ideas?
Here is the code:
===================================
#!/usr/bin/perl
# Perl Script
# 11/18/97
# tjb
require "cgi-lib.pl";
use Mysql;
&PrintHeader;
$dbh = Mysql->connect("bunny","mysql");
print "\n\nTHIS PRINTS OK\n\n";
$sth = $dbh->query("select user from user;");
print "THIS DOES NOT PRINT\n";
@list = $dbh->listtables;
print "\n";
print $list[1],"\n";
print $list[2],"\n";
print $list[3],"\n";
print "\n";
===================================
The last 6 lines do not print when the script is run by the browser.
i.e. The last 6 perl print statements' output is NOT sent to the
browser.
------------------------------
Date: 18 Nov 1997 15:15:06 GMT
From: alfred@hw.stratus.com (Alfred von Campe)
Subject: Re: How to determine absolute file path on UNIX
Message-Id: <64sbdq$ife@transfer.stratus.com>
Eli the Bearded (usenet-tag@qz.little-neck.ny.us) wrote:
|>Because it can't be done right.
But you can make a good guess that's right most of the time
(and that's all I need for my situation). Actually, the
answer from pwd is really what I need (I know your example
had some cases where this fails, but I don't think I'll be
affected by them). So what algorithm does pwd use? I want
to avoid doing a cd followed by a pwd, but if that's the
only way...
Alfred
--
+------------------------------------------------------------+
| Phone: H: 978.448.6214, W: 508.490.6306, fax: 508.460.2888 \
| Mail: Alfred von Campe, 402 Lowell Road, Groton, MA 01450 \
| Email: alfred@hw.stratus.com \
+----------------------------------+-----------------------------+
| Why is common sense so uncommon? | I'd rather be flying N4381Q |
+----------------------------------+-----------------------------+
------------------------------
Date: Tue, 18 Nov 1997 09:11:57 -0600
From: dg50@chrysler.com
Subject: Internet Explorer -> Perl CGI Problems?
Message-Id: <879861046.23891@dejanews.com>
I've been noticing some problems with some long-established Perl-based
CGI scripts, some of my own construction and some "generic" (like
wwwboard) when used with Internet Explorer 4.0
The symptom is extra data being stuck in odd places in the input stream
that then get parsed out and stuck into the form data fields.
The string that's getting inserted is:
VHosting Agent: some.ip.address:80 by some.ip.address
This only happens with IE4.
Is this a known problem? What's the fix?
DG
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Tue, 18 Nov 1997 14:01:59 GMT
From: chrisr@cheese.org (Chris Raettig)
Subject: Newbie question regarding DNS
Message-Id: <34729ee1.598070041@news.demon.co.uk>
Hi there,
I have seen on various Internet sites DNS checkers which can search through the
DNS for a domain name supplied via a form and reply whether or not it has been
registered. I would be enormously grateful if anybody could point me towards
where I could obtain a Perl script for performing this task, or supply me with
any appropriate information.
Thanks in advance,
Regards,
Chris.
PS. I would appreciate a copy of any reply postings via email.
------------------------------
Date: Tue, 18 Nov 1997 09:20:39 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: nt build of perl5.004_04
Message-Id: <3471B247.B0E79A4B@mail.uca.edu>
Thomas Lockney wrote:
>
> Well, no body seems to be jumping on this one, so maybe y'all can help
> me
[snip]
> If anyone knows where a binary of the standare distribution is
> available
> for NT (with modules available also), please reply.
I was told that GS is working on it, might have it out this week, even.
So, whatever you do, don't interrupt him ;^) I'm sure it'll show up in
comp.lang.perl.announce ASAIA.
Cameron
camerond@mail.uca.edu
------------------------------
Date: Tue, 18 Nov 1997 14:55:08 GMT
From: no@spam.please (William L. Gorder)
Subject: Re: Removing text regex?
Message-Id: <slrn673am0.p7r.no@user2.infinet.com>
Thanks to all the reponders! It looks like the "paragraph mode" solution
may be the best if I can count on the blank lines between identifiers. The
only negative seems to be that it eats any extra blank lines, but this does
not affect the behavior of the program which uses these files.
In any event, I have much more to chew on now.
>My real e-mail address is wlg AT infinet | Sorry for the trouble, but I HATE
>dot com | junk e-mail!
I should have noted I don't expect personal e-mail replies when my address
is munged. Responding to the group is just fine thanks!
Thanks again,
Bill
--
My real e-mail address is wlg AT infinet | Sorry for the trouble, but I HATE
dot com | junk e-mail!
------------------------------
Date: 18 Nov 1997 13:37:22 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: sequence point?
Message-Id: <slrn67362r.a6d.gabor@vinyl.quickweb.com>
In article <64rg3j$2pl$1@renpen.nelson.org>, Bob Nelson wrote:
>Is the behaviour of ``$i = 3; $i = $i++'' ^(un|implementation-)*defined$
>in Perl?
I don't know. But why would you want to do something as stupid as
that? What is the purpose of it? I know for certain that it ias
undefined in C, and I would hope for the same in Perl.
>
>--
>========================================================================
> Bob Nelson -- Dallas, Texas, USA (bnelson@iname.com)
> http://www.geocities.com/ResearchTriangle/6375
>========================================================================
gabor.
--
Besides, including <std_ice_cubes.h> is a fatal error on machines
that don't have it yet. Bad language design, there... :-)
-- Larry Wall in <1991Aug22.220929.6857@netlabs.com>
mharris@gov.on.ca he, he, he
------------------------------
Date: Tue, 18 Nov 1997 07:45:01 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: bnelson@iname.com
Subject: Re: sequence point?
Message-Id: <Pine.GSO.3.96.971118074314.17802O-100000@usertest.teleport.com>
On Tue, 18 Nov 1997, Bob Nelson wrote:
> Is the behaviour of ``$i = 3; $i = $i++'' ^(un|implementation-)*defined$
> in Perl?
The RHS of an expression is supposed to be evaluated early, then the
assignment will be made, so that should always leave 3 in $i. If it
doesn't, though, I wouldn't bother filing a bug report. :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 18 Nov 1997 13:40:17 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: setenv problem
Message-Id: <slrn67368a.a6d.gabor@vinyl.quickweb.com>
In article <347164A6.21D5@amdocs.com>, Daniel Bar Or (Beniluz) wrote:
>Hi all
>----------
>
> On Win Nt 4.0 station. using perl5
> I'm trying to set a new environment variable from a perl script.
>
> $new_env="xxx";
> $ENV{'MYVAR'}=$new_env;
>
> I've tried also :
>
> system("set MYVAR=xxx");
>
> or
>
> `set MYVAR=xxx` ;
>
> The program terminates succesfully
> But when i go out to the commnad prompt the new env var is not set.
>
> Can anybody help ?
What makes you think that the environment will change when you exit
the program? Just think how annoying it would be if this did happen.
I don't want some program going around and changing my environment
vars on me!
gabor.
--
I've heard that there is a shell (bourne or csh) to perl filter, does
anyone know of this or where I can get it?
Yeah, you filter it through Tom Christiansen. :-)
-- Larry Wall
mharris@gov.on.ca he, he, he
------------------------------
Date: Tue, 18 Nov 1997 12:58:43 +0100
From: Sander Brugmans <s.brugmans@best.ms.philips.com>
Subject: sfio with Perl5.004 on hpux 9 problems
Message-Id: <347182F3.45C7@best.ms.philips.com>
Hello,
I am trying to build Perl5 with sfio on HP-UX 9, but i get the following
error messages while compiling Fcntl.c :
cc: "/usr/include/pwd.h", line 71: error 1000: Unexpected symbol: "*".
cc: "/usr/include/pwd.h", line 76: error 1000: Unexpected symbol: "*".
cc: "/usr/include/pwd.h", line 71: error 1506: Parameters allowed in
function
definition only.
cc: "/usr/include/pwd.h", line 76: error 1506: Parameters allowed in
function
definition only.
Is there anybody who has enountered the same problem while building his
Perl5 with sfio? Please help me.
Greetings from Holland,
Sander.
--
+--------------------------------------------------------------------+
| Sander Brugmans MR Systems Software Support Group |
| Integrator Philips Medical Systems |
| Building QR 1136, P.O. Box 218 |
| E-mail : 5600 MD Best, The Netherlands |
| s.brugmans@best.ms.philips.com Telephone : +31(0)40 27 62329 |
+--------------------------------------------------------------------+
------------------------------
Date: Tue, 18 Nov 1997 07:51:47 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Chris Wilson <chris@cjetech.co.uk>
Subject: Re: User restriction
Message-Id: <Pine.GSO.3.96.971118074653.17802Q-100000@usertest.teleport.com>
On Sun, 16 Nov 1997, Chris Wilson wrote:
> I wish to set up a voting booth system which will only let each person
> vote once.
Just so you know, my three wives, fourteen concubines, and thirty-eight
children all share my computer, so between us we get 56 votes. :-)
> I suppose it doesn't have to be perl, even.
That's right, there's nothing perlish about this problem. There is, as
yet, no way to be completely sure that anyone is who they say they are on
the Internet. But you could try discussing the problem in a newsgroup
about security and authentication. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Mon, 17 Nov 1997 17:31:56 -0800
From: "Michael A. Chase" <mchase@ix.netcom.com>
Subject: Re: Where can I get the pre-compiled binariy "undump" for Linux?
Message-Id: <64s0oq$ef1@dfw-ixnews9.ix.netcom.com>
Even if you can you probably shouldn't. Undump works with Perl 4, not
Perl 5.
--
Mac :}) mchase@ix.netcom.com
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/CC/E/IT/O d s+:+ a+ C++$ ULUHSC*++$ P++$ L+(++) E- W++ N++ o? K-? w+
O M- V- PS+@ PE Y+ PGP+ t+ 5++ X R tv b+++(++++) DI++(+++) D? G e++ h---
r+++ y+
------END GEEK CODE BLOCK------
M. Mustun wrote in message <34681F01.5E352E11@active.ch>...
>Hello!
>Where can I get the precompiled binariy "undump" for Linux?
>Many thanks,
------------------------------
Date: Tue, 18 Nov 1997 12:32:40 -0000
From: "Debbi Stott" <debbi.stott@redact.com>
Subject: Win32 Perl and NT IIS
Message-Id: <64s1jq$7f6$1@despair.u-net.com>
I'm having a problem unique to Netscape Navigator. I have a perl script
which parses a text file created by a satellite data stream into an HTML
page which updates on a minute by minute basis. This all works wonderfully
well under Internet Explorer but everytime I try to view via Netscape
Navigator 3.0 or above I get the following message:
You have started to download an file of type application/x-perl click on
"More Info" to learn how to extend Navigator's capabilities.
click away and you get a screen that tells you Netscape doesn't have a
plug-in for use with application/x-perl.
Why is it doing this, the server should do the work of processing the perl
script and not trouble the Navigator browser at all.
The Script Map in
LOCAL_MACHINE/SYSTEM/CURRENTCONTROLSET/SERVICES/W3SRV/PARAMETERS is set
to execute the following for .pl and .cgi extentions:
d:\program files\perl\perl5\bin\perl.exe %s %s
Is this wrong, should I have done something else?
Any help would be invaluable as I have tried everywhere else with no luck
and my Netscape-bound subscribers are getting hungry.
Regards
Debbi Stott
------------------------------
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 1337
**************************************