[13308] in Perl-Users-Digest
Perl-Users Digest, Issue: 718 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 5 12:07:18 1999
Date: Sun, 5 Sep 1999 09:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 5 Sep 1999 Volume: 9 Number: 718
Today's topics:
[Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
Re: CGI in PERL (Marc)
Re: CGI.pm on linux <hpepper@mindspring.com>
Re: CGI.pm on linux <gellyfish@gellyfish.com>
Re: Checking number of messages <will@localadsSPAM.net>
Re: Checking number of messages (Markus Fischer)
do 'file' for config file and use strict <hfader@hotpop.com>
Re: do 'file' for config file and use strict (Sam Holden)
fork? <wablief@freemail.nl>
Re: fork? <meowing@banet.net>
Re: fork? <wablief@freemail.nl>
How to Process MULTIPLE select values <webman@geneaware.com>
Re: How to Process MULTIPLE select values (Sam Holden)
HTML Code read from file not being interpreted <Hendrik.Holtmann@pmnet.uni-oldenburg.de>
Re: HTML-to-Perl CGI converter <gellyfish@gellyfish.com>
Re: Looking for tools. <jebsb@bellatlantic.net>
Newbie: Perl DOS Window Runs Too Fast <hansi@lancnews.infi.net>
Parsing links in HTML files <nmorison@ozemail.com.au>
Re: Perl-Server-Applikation wird bei exec() beendet (Leo Schalkwyk)
Routine for normalising file paths <nmorison@ozemail.com.au>
Re: Routine for normalising file paths (Sam Holden)
Re: Routine for normalising file paths (Randal L. Schwartz)
Re: Socket:: relocation error ... (Brandon S. Allbery KF8NH)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 05 Sep 1999 10:24:01 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage936527041.14399@news.teleport.com>
Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 18 Aug 1999
[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last major update of the Perl FAQ was in Summer of
1998; of course, ongoing updates are made as needed. ]
For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).
http://www.cpan.org/doc/FAQs/
Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.
perldoc perlfaq
man perlfaq
If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.
If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.
http://www.cpan.org/
http://www.perl.com/CPAN/
http://www.cpan.org/doc/FAQs/FAQ/html/
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/
You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)
California ftp://ftp.cdrom.com/pub/perl/CPAN/
Texas ftp://ftp.metronet.com/pub/perl/
South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
Australia ftp://cpan.topend.com.au/pub/CPAN/
Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
Another possibility is to use one of the FTP-via-email services; for
more information on doing that, send mail to <mail-server@rtfm.mit.edu>
(not to me!) with these lines in the body of the message, flush left:
setdir usenet-by-group/news.announce.newusers
send Anonymous_FTP:_Frequently_Asked_Questions_(FAQ)_List
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.
Have fun with Perl!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 05 Sep 1999 14:40:22 GMT
From: puma@mailandnews.com (Marc)
Subject: Re: CGI in PERL
Message-Id: <7qtggm.3vse8bt.0@pumamarcmailandnews.h32CBBA51.invalid>
>> 'Technically' Nate is correct PERL is an acronym
>> for Practical Extraction and Reporting Language.
>>
>
><snip>
>
>>
>> Just make sure you know what your talking about
>> before you slam someone. (Hope I dont eat my
>> words! eheh)
Except that it has not been proven that Perl is an acronym, there's a
debate about that, supposedly "Practical Extaction and Reporting Language"
was invented after the fact. Also, if Perl is an acronym, then "Perl" is
the correct spelling, for that is how you write down an acronym.
Marc
------------------------------
Date: Sun, 5 Sep 1999 07:34:24 -0400
From: "Howard Pepper" <hpepper@mindspring.com>
Subject: Re: CGI.pm on linux
Message-Id: <7qtke6$4mi$1@nntp8.atl.mindspring.net>
Paul,
How did CGI.pm get on your Linux server? The reason I ask this is with
RedHat 6.0 (I'm running it on 2 servers), CGI.pm came with the distribution.
I have no trouble with generating CGI output.
Howard Pepper
Paul Reid wrote in message <37D0723B.BE9FF8E1@cableinet.co.uk>...
>> here is the Calling script:
>
>#!/usr/bin/perl -w
>
>use CGI;
>$co = new CGI;
>print $co-> header,
>$co->start_html (-title=>'CGI Example'),
>$co->center($co->h1('Welcome to CGI')),
>$co->textarea(
> -name=>'textarea',
> -default=>'No opinion',
> -rows=>10,
> -columns=>60
>),
>$co->end_html;
>
>
------------------------------
Date: 5 Sep 1999 10:31:23 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: CGI.pm on linux
Message-Id: <7qtgpr$2cu$1@gellyfish.btinternet.com>
On Sat, 04 Sep 1999 02:09:40 +0100 Paul Reid wrote:
> hello,
> I am trying out the CGI.pm module which is new to me.
> I have successfully tried it on a unix server and on my PWS but when i
> try to run it on a Linux server I get an error.
> On contacting my server people they told me it may be because it
> contains dos line feeds and this is the error log:
>
> Can't find string terminator "END_OF_AUTOLOAD" anywhere before EOF at
> CGI.pm line 694.
The module is broken somehow. This could be because it wasnt installed
properly in the first place - possibly by simply being copied somewhere
a version that originated on a DOS system.
You should reinstall the module.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 5 Sep 1999 11:22:08 +0100
From: "WL" <will@localadsSPAM.net>
Subject: Re: Checking number of messages
Message-Id: <7qtg93$glm$1@uranium.btinternet.com>
Hi,
Thanks for the reply. I tried it, replacing username with a User, and host
with the domain name (correct?). it said Login incorrect. What do you
suggest I do?
Thanks in advance,
Will
Markus Fischer <mfischer@josefine.ben.tuwien.ac.at> wrote in message
news:slrn7t3em9.jsk.mfischer@josefine.ben.tuwien.ac.at...
> In article <7qs57k$j99$1@uranium.btinternet.com>, WL wrote:
> >I want to do something very simple: have a perl script that will log into
my
> >mail account (on same server - usr/home/myname), check how many messages
> >there are, and email another account.
>
> how about :
>
> rsh -l username host frm -s new|wc -l|mail user@other.account
>
> Of course I would give ssh more preference than rsh.
>
> kind regards,
> Markus
>
> --
> Speaking mutt/vim/slrn/screen/perl/html/php/perl/sgml/bash/eperl.
------------------------------
Date: 5 Sep 1999 11:08:54 GMT
From: mfischer@josefine.ben.tuwien.ac.at (Markus Fischer)
Subject: Re: Checking number of messages
Message-Id: <slrn7t4jq6.csq.mfischer@josefine.ben.tuwien.ac.at>
Next time put a note in the mail/post that its
mailed/posted somewhere else too.
------------------------------
Date: Sun, 05 Sep 1999 15:15:25 GMT
From: Hugh Fader <hfader@hotpop.com>
Subject: do 'file' for config file and use strict
Message-Id: <37D2890C.37E4D8C9@hotpop.com>
I am trying to set up a config file which sets perl variables as
suggested in the perl man pages. I also want to use strict. I can't get
both of these to work together. Here is what I have:
---f1.pl---
#! /usr/bin/perl
use strict;
my $v1;
do 'f2.pl' or die "can't do f2.pl";
---f2.pl---
$v1 = "123";
---------
If I don't use strict everything works as expected. If I use strict,
then I need to declare my $v1 or I get an error. If I declare my $v1,
then it uses the local copy of $v1 not what is set in f1.pl.
Anybody know a workaround for this?
Thanks.
------------------------------
Date: 5 Sep 1999 16:03:53 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: do 'file' for config file and use strict
Message-Id: <slrn7t5539.v6.sholden@pgrad.cs.usyd.edu.au>
On Sun, 05 Sep 1999 15:15:25 GMT, Hugh Fader <hfader@hotpop.com> wrote:
>I am trying to set up a config file which sets perl variables as
>suggested in the perl man pages. I also want to use strict. I can't get
>both of these to work together. Here is what I have:
>
>---f1.pl---
>#! /usr/bin/perl
>use strict;
>my $v1;
>do 'f2.pl' or die "can't do f2.pl";
>
>---f2.pl---
>$v1 = "123";
>---------
>
>If I don't use strict everything works as expected. If I use strict,
>then I need to declare my $v1 or I get an error. If I declare my $v1,
>then it uses the local copy of $v1 not what is set in f1.pl.
>
>Anybody know a workaround for this?
Did you bother to read the documentation that comes with perl before
deciding to bother everyone else.
What does 'perldoc strict' tell you about strict. It mentions three ways to
use variables under 'use strict'. Using 'my' is only one of the ways. The first
way listed might be of interest to you, but you would know that if you could
be bothered reading the documentation that comes with perl.
How could you be using something from the man pages, and then not bother
looking them up when you have a problem...
--
Sam
You are bordering on ridiculous if you think you need to support your
premises. Such an argument is an infinite regression.
--George Reese in <wv0O1.1521$Ge.4809664@ptah.visi.com>
------------------------------
Date: Sun, 05 Sep 1999 13:01:07 +0200
From: GiN <wablief@freemail.nl>
Subject: fork?
Message-Id: <37D24D72.96A17143@freemail.nl>
--------------25D4B73422318881D7BBB095
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
in a program is a global value: $chick = "blah";
when i fork the process and the child sets $chick to "blah2"
then i fork another child to print $chick. it prints "blah"
what am i doing wrong?
--
#phreak.nl http://www.casema.net/~gin
--------------25D4B73422318881D7BBB095
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
in a program is a global value: $chick = "blah";
<p>when i fork the process and the child sets $chick to "blah2"
<br>then i fork another child to print $chick. it prints "blah"
<p>what am i doing wrong?
<br>
<pre>--
#phreak.nl <A HREF="http://www.casema.net/~gin">http://www.casema.net/~gin</A></pre>
</html>
--------------25D4B73422318881D7BBB095--
------------------------------
Date: 05 Sep 1999 07:12:02 -0400
From: meow <meowing@banet.net>
Subject: Re: fork?
Message-Id: <87g10tsjct.fsf@banet.net>
GiN <wablief@freemail.nl> wrote:
> in a program is a global value: $chick = "blah";
> when i fork the process and the child sets $chick to "blah2"
> then i fork another child to print $chick. it prints "blah"
Right, that's how it's supposed to work.
> what am i doing wrong?
Nothing, except expecting that forking will do what threads do.
Fork() preserves a copy of the state of the parent process' state in
the child, but it's just that, a copy. As soon as parent or child
changes a variable, they are different and stay that way.
------------------------------
Date: Sun, 05 Sep 1999 13:28:53 +0200
From: GiN <wablief@freemail.nl>
Subject: Re: fork?
Message-Id: <37D253F5.CB8A61EE@freemail.nl>
--------------D944634942943C46D58C5DFC
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
meow wrote:
> GiN <wablief@freemail.nl> wrote:
>
> > in a program is a global value: $chick = "blah";
>
> > when i fork the process and the child sets $chick to "blah2"
> > then i fork another child to print $chick. it prints "blah"
>
> Right, that's how it's supposed to work.
>
> > what am i doing wrong?
>
> Nothing, except expecting that forking will do what threads do.
> Fork() preserves a copy of the state of the parent process' state in
> the child, but it's just that, a copy. As soon as parent or child
> changes a variable, they are different and stay that way.
thanks for your reply!
but how can i modify the source to let the child print "blah2"?
--
#phreak.nl http://www.casema.net/~gin
--------------D944634942943C46D58C5DFC
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
meow wrote:
<blockquote TYPE=CITE>GiN <wablief@freemail.nl> wrote:
<p>> in a program is a global value: $chick = "blah";
<p>> when i fork the process and the child sets $chick to "blah2"
<br>> then i fork another child to print $chick. it prints "blah"
<p>Right, that's how it's supposed to work.
<p>> what am i doing wrong?
<p>Nothing, except expecting that forking will do what threads do.
<br>Fork() preserves a copy of the state of the parent process' state in
<br>the child, but it's just that, a copy. As soon as parent or child
<br>changes a variable, they are different and stay that way.</blockquote>
thanks for your reply!
<br>but how can i modify the source to let the child print "blah2"?
<pre>--
#phreak.nl <A HREF="http://www.casema.net/~gin">http://www.casema.net/~gin</A></pre>
</html>
--------------D944634942943C46D58C5DFC--
------------------------------
Date: Sun, 5 Sep 1999 08:38:01 -0300
From: "WebMan" <webman@geneaware.com>
Subject: How to Process MULTIPLE select values
Message-Id: <wwsA3.5526$qY3.208614@newscontent-01.sprint.ca>
I have a form that has a <SELECT MULTIPLE NAME="FOO"> defined in it and I
want to process the multiples. My program ends up placing only the last
selected option value in the hash no matter what. Is there a way to treat
these separately or specially?
My parse_form routine is a pretty standard one that is used pretty
universally for all form processing and returns my name/value pairs in a
hash called $FORM.
Any and all help is deeply appreciated.
------------------------------
Date: 5 Sep 1999 12:34:03 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How to Process MULTIPLE select values
Message-Id: <slrn7t4opr.ggb.sholden@pgrad.cs.usyd.edu.au>
On Sun, 5 Sep 1999 08:38:01 -0300, WebMan <webman@geneaware.com> wrote:
>I have a form that has a <SELECT MULTIPLE NAME="FOO"> defined in it and I
>want to process the multiples. My program ends up placing only the last
>selected option value in the hash no matter what. Is there a way to treat
>these separately or specially?
>
>My parse_form routine is a pretty standard one that is used pretty
>universally for all form processing and returns my name/value pairs in a
>hash called $FORM.
use CGI.pm since it gets it right, whereas your code obviously does not.
--
Sam
The very fact that it's possible to write messy programs in Perl is also
what makes it possible to write programs that are cleaner in Perl than
they could ever be in a language that attempts to enforce cleanliness.
--Larry Wall
------------------------------
Date: Sun, 5 Sep 1999 13:08:19 +0200
From: "Hendrik Holtmann" <Hendrik.Holtmann@pmnet.uni-oldenburg.de>
Subject: HTML Code read from file not being interpreted
Message-Id: <7qtmds$qck@newssrv2.hrz.uni-oldenburg.de>
Hi,
I want to read HTML-Code from an extern file called text.html and sent it to
a browser. I try this by the following algorithm:
open(INFILE,"test.hmtl");
WHILE (<INFILE>) {
print $_;
}
The HTML-Code contains parts, that I want perl to be interpreted. For
example data->{titel} is an access to an HASH containing data from an
SQL-database. Unfortunately perl sends only data->{titel} to the browser as
text and not the interpreted from, which would mean the data from the
SQL-database. If I copy the HTML-Code into the perl-script everything works
fine.
I tried thinks like print "$_"; and print qq! $_ !; but had no success. The
data read from the HTML_File is never interpreted.
Is there any way to do it.
Any help is highly appreciated,
Hendrik
------------------------------
Date: 5 Sep 1999 10:28:16 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: HTML-to-Perl CGI converter
Message-Id: <7qtgk0$2cr$1@gellyfish.btinternet.com>
On Fri, 03 Sep 1999 17:39:27 -0500 Keith G. Murphy wrote:
> I'm wanting to convert a complex HTML file with a form to Perl code
> (using CGI.pm or similar) that generates the same page w/form.
>
I think you are looking for something like:
<http://www.stonehenge.com/merlyn/WebTechniques/col30.html>
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 05 Sep 1999 14:57:32 GMT
From: "Shawn & Jocelin Borisow" <jebsb@bellatlantic.net>
Subject: Re: Looking for tools.
Message-Id: <wxvA3.202$es3.34379@typhoon1.gnilink.net>
Why does noone like to use a standard text editor..... Comes with most OS...
Am I the only cheap mug around any longer.... LOL .... I tried perl builder
but I didn't like it...... I just prefer command line and a text editor
though....
------------------------------
Date: Sun, 05 Sep 1999 12:00:17 +0000
From: David <hansi@lancnews.infi.net>
Subject: Newbie: Perl DOS Window Runs Too Fast
Message-Id: <37D25B50.F6E5D719@lancnews.infi.net>
I just bought a "Perl 5 How To" book with a CD-ROM. It says I have to
have access to a server with Perl on it, but I want to run it on my
Windows 98 machine first. The problem I'm running into is that there is
a version of Perl32.exe on my PC on which I am running the book's
scripts, BUT the trouble is that a MS-DOS window opens up to run the
script and then closes so quickly that I can't see what the script
does. When I eventually tailor one of these scripts or write my own, I
want to test it on my PC before uploading it to the cgi-bin on the
server.
What am I doing wrong, and what should I be doing?
Thanks in advance.
------------------------------
Date: Mon, 06 Sep 1999 00:05:22 +1000
From: Neale Morison <nmorison@ozemail.com.au>
Subject: Parsing links in HTML files
Message-Id: <37D278A2.C746E8E0@ozemail.com.au>
Hi folks. I want to parse <A HREF . . .> tags in HTML files to perform
site management functions like finding bad links, orphan files with no
links to them, converting absolute to relative links, optimising
relative links and so on.
I would like to use the most appropriate Perl module. I have found
mention of libwww and HTML::Parser. I have HTML::Parser but the
documentation is very terse and has no sample code. I think it wants me
to write callback functions to process particular tags, but I'm not sure
how to please it.
Could anyone recommend the best module to use, and perhaps point me to
some sample code?
I use ActiveState Perl on Windows, and it's easier for me to use modules
which can be installed using the ActiveState PPM facility.
Many thanks for your assistance.
Best, regards, Neale
------------------------------
Date: 5 Sep 1999 10:31:07 GMT
From: schalkwy@minnie.RZ-Berlin.MPG.DE (Leo Schalkwyk)
Subject: Re: Perl-Server-Applikation wird bei exec() beendet
Message-Id: <7qtgpb$s84$1@fu-berlin.de>
Karsten Lehmann (klehmann-news@gmx.net) wrote:
: I=B4m sorry for writing this text in German. I just realized afterwards
: that i forgot the "de." in front of "comp.lang.perl.misc".
: So I have to try to tell my problem again, this time in English:
: I am currently writing a perl script in order to calculate the amount of
: money everybody has to pay for his online activities in a network.
: On the server I run a script like
: while (1)
: {
: #check the message queue file
: #if there are any lines in there, go online/offline
: #go into idle mode, a Cyrix doesn=B4t like 99 percent activity
: sleep(1);
: }
: If I write "Online,Karsten,Nikoma" into /connect-logs/queue.file , the
: server tries to execute pppd:
: exec("/connect-logs/provider/Nikoma/ppp-up");
: My problem is: after this command is executed, my script is beeing
: stopped with "Exit 5" - I startet it with "./daemon &".
: How can I avoid this?
: I thought, "exec" would generate an independent process. How can it
: force my script to end?
: Karsten
from the perlfunc manpage:
The exec() function executes a system command I<AND NEVER RETURNS> -
use system() instead of exec() if you want it to return. It fails and
returns FALSE only if the command does not exist I<and> it is executed
directly instead of via your system's command shell (see below).
doch klar?
--
------------------------------------------------------------
schalkwy@molgen.mpg.de
------------------------------
Date: Mon, 06 Sep 1999 00:17:11 +1000
From: Neale Morison <nmorison@ozemail.com.au>
Subject: Routine for normalising file paths
Message-Id: <37D27B66.5C2B9638@ozemail.com.au>
Hello Perl afficionados.
I have in my confused way been attempting to write a subroutine meant to
take a path such as ../mary/alice/george/../fred/../../ralph/ted and
convert it to ../mary/ralph/ted
The input path might be created by concatenating paths, for example the
path of an HTML file and a relative link path found within it.
Input paths should be directories only, without a file as the final node
It strips trailing separators.
The code below does more or less what I want. The stripping happens
accidentally, because a trailing slash does not create an array entry
with split on slash.
If the directory path is absolute (has a leading /), it does not allow a
path higher than the top level and returns an error.
I am faintly hoping there is some obvious way to do this in a few lines,
or perhaps someone could suggest a module that does it.
WARNING: The following code is for consenting adults only. Viewers may
find what follows offensive and disturbing.
#---------------------------------------------------------
sub normalise_path ($) {
my $absolute_top_token = '<'; # illegal in a path so won't occur unless
I put it there
my $FILE_PATH_SEPARATOR = '/';
my $error_string = '|ERROR|';
my $ipath = shift;
my $token = "";
my @i = split m{$FILE_PATH_SEPARATOR}, $ipath;
#debug
# for (my $j = 0;$j<scalar(@i);$j++){
# print "$j $i[$j] ";
# }
# print "<BR>\n";
# my $count=0;
#/debug
my @o = ();
if ($i[0] eq ''){ # happens when $ipath begins with a slash, ie
absolute path
shift @i;
push @o, $absolute_top_token;
}
while (@i) {
$itoken = shift @i;
if ($itoken eq '.') { # do nothing
}
elsif ($itoken eq '..') {
my $otoken = pop @o;
if ($otoken eq $absolute_top_token){
return $error_string; # top level - can't go higher so throws an
error
}
elsif (!(defined $otoken) or ($otoken eq "")) {
push @o, '..';
} elsif ($otoken eq '..' ){
push @o, ('..','..');
}
} else {
push @o, $itoken;
}
#debug
# $count++;
# my $test = join ' : ', @o;
# print " $count $test<BR>\n";
#/debug
}
my $opath='';
if (@o) {
if ($o[0] eq $absolute_top_token){
$o[0]=''; # this generates a leading slash on join
}
$opath = join $FILE_PATH_SEPARATOR, (@o,);
}
else {
$opath = '.';
}
return $opath;
} # END SUB normalise_path
------------------------------
Date: 5 Sep 1999 15:56:26 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Routine for normalising file paths
Message-Id: <slrn7t54la.v6.sholden@pgrad.cs.usyd.edu.au>
On Mon, 06 Sep 1999 00:17:11 +1000,
Neale Morison <nmorison@ozemail.com.au> wrote:
>Hello Perl afficionados.
>I have in my confused way been attempting to write a subroutine meant to
>take a path such as ../mary/alice/george/../fred/../../ralph/ted and
>convert it to ../mary/ralph/ted
<snip>
>
>sub normalise_path ($) {
>
> my $absolute_top_token = '<'; # illegal in a path so won't occur unless
>I put it there
That is blatantly false. Did you try creating a path with a '<' in it before
arbitrarily ruling out perfectly valid paths...
Try the following in your favourite shell :
mkdir \<
Oh look './</../.' is now a valid path...
The only illegal characters for file names in the OS I'm using are :
'/' and '\0'.
The first because it has a meaning already, and the second I guess because
strings in C are implemented in such a stupid way that allowing it would
annoy lots of C programmers...
--
Sam
I guess I really am an optimist. A paranoid optimist, true, but an
optimist nonetheless.
-- Larry Wall
------------------------------
Date: 05 Sep 1999 09:04:25 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Routine for normalising file paths
Message-Id: <m17lm5gx9y.fsf@halfdome.holdit.com>
>>>>> "Neale" == Neale Morison <nmorison@ozemail.com.au> writes:
Neale> I have in my confused way been attempting to write a subroutine meant to
Neale> take a path such as ../mary/alice/george/../fred/../../ralph/ted and
Neale> convert it to ../mary/ralph/ted
Neale> The input path might be created by concatenating paths, for example the
Neale> path of an HTML file and a relative link path found within it.
If that's the case (and in another post you said you had access to LWP),
you should be using LWP:
use URI; # not Guttman :-)
my $normal = URI->new_abs("../../ralph/ted",
"http://some.host/../mary/alice/george/../fred/")->canonical;
print "$normal";
RTFM for details.
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 3 Sep 1999 19:19:39 -0400
From: allbery@apk.net (Brandon S. Allbery KF8NH)
Subject: Re: Socket:: relocation error ...
Message-Id: <7qpl2b$5q4@junior.apk.net>
Also sprach "Dave Haywood" <D.Haywood@btinternet.com> (<7qo4jc$gm8$1@plutonium.btinternet.com>):
+-----
| ld.so.1: perl: fatal: relocation error: file
| /opt/gnu/lib/perl5/site_perl/5.005/sun4-solaris/auto/Socket/Socket.so:
| symbol __inet_ntoa: referenced symbol not found
| Killed
+--->8
Educated guess from the times this has happened to me:
You compiled Perl against BIND 8's netdb.h and linked against Solaris's
libresolv.so instead of BIND 8's libbind.a. This won't be caught when you
build a .so (Socket.so in this case); you only discover it at runtime, when
this happens.
--
brandon s. allbery [os/2][linux][solaris][japh] allbery@kf8nh.apk.net
system administrator [WAY too many hats] allbery@ece.cmu.edu
carnegie mellon / electrical and computer engineering KF8NH
Kiss my bits, Billy-boy.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 718
*************************************