[22463] in Perl-Users-Digest
Perl-Users Digest, Issue: 4684 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 8 14:06:56 2003
Date: Sat, 8 Mar 2003 11:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 8 Mar 2003 Volume: 10 Number: 4684
Today's topics:
/proc equivalent in HP-UX (amar)
Re: /proc equivalent in HP-UX (Jay Tilton)
absolute path <ggkuo@yahoo.com>
Re: absolute path <someone@somewhere.nl>
Re: absolute path <tore@aursand.no>
Re: Can Perl can have the include head file like c? <palladium@spinn.net>
Re: foreach in while-block cancels while (Anno Siegel)
is a hash the best way to do this? (david)
Re: Lightweight CGI module? <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
Re: Lightweight CGI module? <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
Re: Lightweight CGI module? <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
Re: Lightweight CGI module? <tore@aursand.no>
Re: new Perl feature request: call into shared libs <no.spam@gknw.de>
Re: Non-fatal error, "script not found or unable to sta (Anno Siegel)
Re: perl locks up my win98 computer (Irwin Feuerstein)
Redirect with links stored in external txt file (Maria Kovacs)
Re: Redirect with links stored in external txt file <mpapec@yahoo.com>
Re: Redirect with links stored in external txt file <noreply@gunnar.cc>
Re: Redirect with links stored in external txt file <noreply@gunnar.cc>
Re: Redirect with links stored in external txt file <flavell@mail.cern.ch>
Re: Regular Expressions (Anno Siegel)
Re: Skip directories and Find (kydongau)
Re: SUBSTR or pattern matching? <barryk2@SPAM-KILLER.mts.net>
Re: SUBSTR or pattern matching? <asby@kinderen4kinderen.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 Mar 2003 02:30:36 -0800
From: amarsantpur@hotmail.com (amar)
Subject: /proc equivalent in HP-UX
Message-Id: <51db1bd3.0303080202.141c370d@posting.google.com>
Hi,
In unix the files for a pid is present in /proc directory.
Can anyone tell me the equivalent directory name where i
can find all the files for a given pid in HP-UX systems.
Thanks & Regards
Amar
------------------------------
Date: Sat, 08 Mar 2003 12:09:47 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: /proc equivalent in HP-UX
Message-Id: <3e69dd4b.14036105@news.erols.com>
amarsantpur@hotmail.com (amar) wrote:
: In unix the files for a pid is present in /proc directory.
: Can anyone tell me the equivalent directory name where i
: can find all the files for a given pid in HP-UX systems.
Yes, anyone can tell you that.
Did you have a Perl question?
------------------------------
Date: Sat, 08 Mar 2003 06:26:13 GMT
From: "C&J" <ggkuo@yahoo.com>
Subject: absolute path
Message-Id: <92gaa.626$Dn2.442583191@newssvr11.news.prodigy.com>
Hi,
In my perl application, the user will input the file, which could be a full
path, or relative path.
Is there any way ( shell, function or module) that I can always translate to
absolute/full path ?
exp :
if current dir is /a/b/c/d/e/f and the user input ../../g/h/readme, how can
I get /a/b/c/d/g/h/readme ?
Thanks
C&J
------------------------------
Date: Sat, 8 Mar 2003 16:01:25 +0100
From: "Stefan" <someone@somewhere.nl>
Subject: Re: absolute path
Message-Id: <3e6a0734$0$138$e4fe514c@dreader9.news.xs4all.nl>
"C&J" <ggkuo@yahoo.com> schreef in bericht
news:92gaa.626$Dn2.442583191@newssvr11.news.prodigy.com...
> Hi,
> In my perl application, the user will input the file, which could be a
full
> path, or relative path.
> Is there any way ( shell, function or module) that I can always translate
to
> absolute/full path ?
>
> exp :
> if current dir is /a/b/c/d/e/f and the user input ../../g/h/readme, how
can
> I get /a/b/c/d/g/h/readme ?
>
> Thanks
> C&J
>
perldoc -m Cwd
look for abs_path
------------------------------
Date: Sat, 08 Mar 2003 18:47:19 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: absolute path
Message-Id: <pan.2003.03.08.13.45.28.623305@aursand.no>
On Sat, 08 Mar 2003 06:26:13 +0000, C&J wrote:
> if current dir is /a/b/c/d/e/f and the user input ../../g/h/readme, how
> can I get /a/b/c/d/g/h/readme ?
File::Spec
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Sat, 8 Mar 2003 09:46:07 -0700
From: "Rod" <palladium@spinn.net>
Subject: Re: Can Perl can have the include head file like c?
Message-Id: <v6k9532d06dtc8@corp.supernews.com>
"Clark Zhong" <unixfighter@163.com> wrote in message
news:265c2336.0303050518.6550f6cf@posting.google.com...
> Thank you for your answer, Martien.
>
> It is my duty to say clearly about my project. This time I have coded a
> perl script to do some LDAP backup works, on TurboLinux, Perl 5.6. The
code
> is all in one script file, and it works well. But the client want a .conf
file
> for some reasons. May be he thought it can make the script more like linux
> program. so I must split some code from the original file to get a .conf
file.
> That is what puzzle me. This my first Perl script, So I want to find some
quick
> solution from c, such C head file.
>
> I have already try the "do" function, but I found it can include the
variables
> I defined in my "~.conf" file.
>
> Hope you can again.
>
<Snip Snip>
How about using something like XML::Simple for defining a logical
configuration file, then when you read in the XML structure, you have a
logical perl structure to deal with? Or goto CPAN and search for config..
------------------------------
Date: 8 Mar 2003 15:44:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: foreach in while-block cancels while
Message-Id: <b4d34q$1ga$1@mamenchi.zrz.TU-Berlin.DE>
W. Citoan <wcitoan@NOSPAM-yahoo.com> wrote in comp.lang.perl.misc:
> On Fri, 07 Mar 2003 19:10:19 +0100, Tore Aursand wrote:
[snip solution to a different problem]
> This will do the opposite of what the OP wants. It will delete the file
> if the process is found. The OP wants to delete it if it's not found.
> I'd recommend something like:
>
> #!/usr/bin/perl
> #
> use strict;
> use warnings;
> use Win32::Process::Info;
>
> while ( 1 ) {
> my $pi = Win32::Process::Info->new();
> unless ( grep /saplgpad.exe/, $pi->getProcInfo() ) {
^
That dot should be escaped.
> if ( -e 'c:\\perl\\test\\check.txt' ) {
> unlink 'c:\\perl\\test\\check.txt';
> }
Since you don't check the return value of unlink(), you might as well
drop the existence test. It only excludes some of the errors that might
occur.
[snip rest of solution to original problem]
Anno
------------------------------
Date: 8 Mar 2003 10:17:30 -0800
From: dwlepage@yahoo.com (david)
Subject: is a hash the best way to do this?
Message-Id: <b09a22ae.0303081017.5d6754dd@posting.google.com>
I currently have a program that opens a file and finds data to
replace. The problem is the current code that I have takes between
5-10 minutes to run on a 2MB file. I am sure there must be better ways
to do this - can anyone help?
Here is what I have:
#Initialize variables
my $infile = "testfile.ldif";
my $outfile = "newfile.txt";
my ($keyname, $keyvalue, $search, $replace) = "";
my %uid = ();
open(IN, "<$infile") or die "Could not open: $infile $!";
flock (IN, 1); #Shared lock
open(OUT, ">$outfile") or die "Could not open: $outfile $!";
flock (OUT, 2); #Exclusive lock
while (<IN>) {
#Reset $keyname and $keyvalue for each new record
if (/^dn: UserId=/) {
$keyname = $keyvalue = "";
#Set $keyname to "UserId".TOK.0
if (/^dn: UserId=([a-zA-Z]+),/) {
$keyname = $1 . ".TOK.0";
}
}
#Set $keyvalue to true authenticator value
if (/^Comment:\s*(.{9})/) {
$keyvalue = $1;
}
#Add values to hash
if (!($keyname eq "") && !($keyvalue eq "")) {
$uid{"$keyname"} = $keyvalue;
}
foreach $key (keys(%uid)) {
$search = $key;
$replace = $uid{"$key"};
s/$search/$replace/g;
}
#Send each line to new file
print OUT $_;
}
close(IN);
close(OUT);
This code does work, but I assume that because I add everything to a
hash, and for each record increment the hash and then go back through
the hash to replace the value later in the file, that this is very
inefficient.. Any suggestions to make this process go faster?
------------------------------
Date: Sat, 8 Mar 2003 17:14:16 +0100
From: "alex" <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
Subject: Re: Lightweight CGI module?
Message-Id: <b4d4so$ctt$01$1@news.t-online.com>
> Customers are assholes, I know, and in this case they are satisfied with
> what they've got, and just want me to install my damn application. No
> matter how much sweat and tears that is for me, they're not feeling any
> sympathy for me until the thing works.
yes - and this is good *g*. i bought a software only tested on Apache and we
are running on IIS - it has taken *realy* long to get this piece running on
IIS. One of the mayor problems was redirection with "print location" - the
progger never used CGI.pm... he told me - 210kb for a 4kb script is too
much. i think so, too. but now i'm not interrested in investing 700$ per CPU
= every machine 1400$ - in PerlEx. And we are moving to Apache and mod_perl
now. Additional - mod_deflate oder mod_gzip for "nothing" - this costs for
IIS about min 800$... realy am i money shit'er?
Alex
------------------------------
Date: Sat, 8 Mar 2003 17:17:27 +0100
From: "alex" <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
Subject: Re: Lightweight CGI module?
Message-Id: <b4d52o$fk3$02$1@news.t-online.com>
> I don't have any experience with other "fast CGI" solutions like FastCGI
> or SpeedyCGI. Maybe I should take a look at them.
i have thought about this too. will this makes sense? is this possible
without changing all .cgi to FastCGi or SpeedyCGI? i have tryed to install
FastCGI in the past - and was unsucessful under Windows. maybe my fault...
Alex
------------------------------
Date: Sat, 8 Mar 2003 17:30:59 +0100
From: "alex" <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
Subject: Re: Lightweight CGI module?
Message-Id: <b4d5s4$1p6$03$1@news.t-online.com>
hi
i have a small script with DBI access - and i found out on my test not the
CGI.pm is the real bottleneck... DBI for e.g. is the real problem in IIS. As
i have seen DBI for e.g. is loaded persistend in IIS (as a running
dllhost.exe process). i have asked myself how DBI handles this - ir is
perlis.dll doing this? nevertheless the real bottelneck seems to bei the
ODBC connect... it takes about 0.22 seconds!!! if i remove it and for e.g.
use CGI and a param it takes about 0.01sec.
a good idea i have seen in the docs is loading CGI only with the required
functions. but i haven't tested this for speed... only follow a good idea -
only use things realy needed if possible. additional to this evangelism is
not doing a DB query with "SELECT * from table"... :-)
use CGI 'param','redirect','cookie';
Alex
------------------------------
Date: Sat, 08 Mar 2003 19:16:24 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Lightweight CGI module?
Message-Id: <pan.2003.03.08.17.52.57.982025@aursand.no>
On Sat, 08 Mar 2003 17:30:59 +0100, alex wrote:
> i have a small script with DBI access - and i found out on my test not
> the CGI.pm is the real bottleneck... DBI for e.g. is the real problem in
> IIS.
If you use PerlEx (from ActiveState), you can keep the connection open and
in memory. I tend to do this and only check if the database connection is
defined (or "ping()-able") at each run.
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Sat, 08 Mar 2003 19:43:46 +0100
From: Guenter <no.spam@gknw.de>
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <3E6A39E2.5060400@gknw.de>
Hi Ben,
Benjamin Goldberg schrieb:
> Guenter wrote:
> use Win32::API;
yes, others already pointed to it, and it's exactly what I was looking
for...
> If you want it to work with NetWare, you'll have to write it yourself.
I know; and I'm in contact with the porters; and in addition the .xs
code from Win32-API looks good for porting to NetWare...
thanks, Guenter.
------------------------------
Date: 8 Mar 2003 13:51:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Non-fatal error, "script not found or unable to stat"
Message-Id: <b4csh9$rsr$1@mamenchi.zrz.TU-Berlin.DE>
Mike <csdude@hotmail.com> wrote in comp.lang.perl.misc:
> Hey, guys,
Hey, guy, don't top-post please.
[...]
> open INFILE, "$basepath/data.xls" || die "$!";
> @data = <INFILE>;
> close INFILE;
So you read all of your file into the @data array. This is a waste of
memory unless it is necessary, which it rarely is.
> $current_data = join(/\n/, @data);
> @olddata = split(/\n/, $current_data);
This is so wrong, it hurts. What you achieve here is indeed the effect
of
chomp( @olddata = @data);
As the warning was trying to tell you, "join( /regex/, ...)" is rarely
what you want to do. The first parameter of join() is a string. If
you put a regex there (like /\n/), it will be applied to $_ (which is
probably undefined, so you'll get more warnings). The result of this
in scalar context is a boolean that tells whether the regex matched or
not. If it didn't (that is, if $_ didn't happen to contain a newline),
/\n/ will return an empty string, which is used by join to put all
lines in @data together into a string. It this were what you actually
want, you could just read the whole file into $current_data and be done
with. Except that your code will mysteriously fail when $_ happens to
contain a newline.
But you go on and split $current_data on newlines, which splits them
exactly where they were split before join(). The only difference is
that split( "\n", ...) consumes the newlines. You could have said
chomp( @olddata = <INFILE>);
to the same effect.
> The program runs perfectly (as far as I've tested it, anyway),
Try setting $_ = "\n".
> but in
> the error log I get something like "/\n/ should probably be \n." I
> figure that the word "probably" means that it's just a suggestion, and
> that it can be ignored.
Using a regex in join() is almost certainly wrong, that's not what
"probably" is about. The guess that it should be "\n" instead is
restricted by "probably", and it would be indeed wrong in this case.
However, nothing would really be right here, the whole construction
is misguided.
> I used to use chomp, but it's been so long
> that I don't remember why it became a problem.
Use chomp again. Also see if you really need all of the data in memory
at once. If you don't (as is likely), rewrite it as a loop over the
input lines:
while ( my $line = <INFILE> ) {
chomp;
# do something with the line in $_
}
Anno
------------------------------
Date: 8 Mar 2003 07:27:53 -0800
From: ebct@hotmail.com (Irwin Feuerstein)
Subject: Re: perl locks up my win98 computer
Message-Id: <542d2ca5.0303080727.16ba8623@posting.google.com>
Yes, but with most conflicts, it comes and goes. When I type PPM, it
hangs my machine every time. I am not used to seeing that with DOS
type programs. Does anyone know of any programs or loaded utilities
that consistently conflict with perldoc, or with PPM? Am I the only
one here having this problem? Seems like it, from the paucity of
similar messages on Google searching.
Thanks,
Irwin
Crapnut566@yahoo.com (Nataku) wrote in message news:<7e48fc99.0303060800.62dfb544@posting.google.com>...
> I would imagine that since you are running Win98, you probably dont
> have too much RAM on your system. This could be the cause. Im
> assuming you have the correct distrobution via activestate.
>
> Ignore all the MS cynicism that is present near everywhere. I have
> never had a problem running perl under windows myself. Im guessing
> its either hardware, or a specific issue with your windows install.
>
> Sorry I cant be of much help, but OS lockups are hard to diagnose.
>
> James McIninch <james.mcininch@attbi.com> wrote in message news:<NHB9a.378452$Ec4.380535@rwcrnsc52.ops.asp.att.net>...
> > On Wednesday 05 March 2003 07:15 pm, Doglover posted to comp.lang.perl.misc:
> >
> > > Hi. Does anyone know why Perl locks up my win98 machine when I do
> > > simple things like type PPM, or perldoc perldoc?
> >
> > This is a feature of Microsoft Windows. It's one of the things that
> > differntiates it from other operating system products on the market.
> >
> >
> > > Can't even do
> > > control-alt-delete. It is totally locked. Simple "hello world" scripts
> > > run fine. Seems to be with both 5.6.1 and with 5.8.0, since I tried
> > > both. Strange, because 5.6 used to work. Then I tried 5.8, and started
> > > locking up. Uninstalled, and went back to 5.6, still locked up. So now
> > > I am back at 5.8.
> > >
> > > A google search revealed almost nothing.
------------------------------
Date: 8 Mar 2003 07:51:39 -0800
From: mariakovacs@lycos.com (Maria Kovacs)
Subject: Redirect with links stored in external txt file
Message-Id: <6f76be22.0303080751.1c161e62@posting.google.com>
Hello,
I need some advice on redirection using an external cgi and text file.
OR ANYTHING THAT CAN SOLVE MY PROBLEM! I have been searching for
solution all around for this but I found answers only for simple
redirects in the same document.
I am working on a redirect script that would allow me to store all my
redirect links separately in a txt file. I would like to do this
because the external weblinks I am working with will be locked into a
software permanently, but most likely will be changed eventually. Then
I would like to avoid broken links in the software. I could make up a
new redirect page for all external links but I know I will have more
links of this type in the future.
I have a system set up but instead of redirecting me to the external
URL it either redirects me to the same file or it wants to list the
contents of the directory thus giving me an error "Denied directory
listings". Can anybody help what I did wrong? I don't find the problem
in the script.
I have a mock up screen of this portion of the software at:
http://www.cliq-on.com/pirates/Index.htm
The system desctibed below:
I am using an external txt file that stores links as:
Schedule | http://www.domain.com/schedule.htm
Then I am using the following link format (that would be locked into
the software):
a href="../cgi-bin/gothere.cgi?name=Schedule"
which then passes through a cgi script that is the following:
#!/usr/local/bin/perl
######################################
# datafile
# (the file containing the urls)
$datafile = "C:\Websites\cliqon479\cliq-on.com\PIRATES\mysites.txt";
#
#####################################
############ THE PROGRAM ############
&parse;
&incomplete unless $FORM{'name'};
$name = "$FORM{'name'}";
&findurl;
&doit;
############ END PROGRAM ############
############ SUBROUTINES ############
# Sends browser to the
# url the findurl subroutine digs out of the
# datafile.
sub doit
{
print ("Location: $url\n");
print ("Content-type: text/html\n\n");
}
############ FIND URL ############
# Digs in to the datafile, checks each name against
# the value the html link submitted to the script. If
# it finds a match, it reads the url after the name
# in the datafile and sends that value to the do it
# subroutine
sub findurl
{
open (INFO, "$datafile");
@information = <INFO>;
foreach $information (@information)
{
($title, $location) = split(/\|/ , $information);
{
if ($title eq $name)
{
$url = $location;
}
}
}
close (INFO);
}
############ PARSE ############
# Reads input from your form.
sub parse
{
read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
$input = $ENV{'QUERY_STRING'} if $ENV{'QUERY_STRING'};
@pairs = split(/&/, $input);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
}
sub incomplete
{
print "Content-type: text/html\n\n ";
print <<"HTML";
<HTML><HEAD><TITLE>Broken Link</TITLE></HEAD>
<BODY bgcolor=white>
<H1>URL not Found</H1>
<p>
<hr noshade size=1>
</BODY>
</HTML>
HTML
exit;
}
------------------------------
Date: Sat, 08 Mar 2003 17:10:22 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: Redirect with links stored in external txt file
Message-Id: <lt4k6vsb5l7vh3bsf29ss499lekhj9cbcb@4ax.com>
X-Ftn-To: Maria Kovacs
mariakovacs@lycos.com (Maria Kovacs) wrote:
>contents of the directory thus giving me an error "Denied directory
>listings". Can anybody help what I did wrong? I don't find the problem
>in the script.
>
>I have a mock up screen of this portion of the software at:
>http://www.cliq-on.com/pirates/Index.htm
>
>The system desctibed below:
>I am using an external txt file that stores links as:
>Schedule | http://www.domain.com/schedule.htm
^
Extra space before pipe looks like what's the problem here.
Did you wrote this script? It looks very arhaic and from old age.
--
Matija
------------------------------
Date: Sat, 08 Mar 2003 17:41:05 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Redirect with links stored in external txt file
Message-Id: <b4d6ej$1u2abi$1@ID-184292.news.dfncis.de>
Maria Kovacs wrote:
> I need some advice on redirection using an external cgi and text file.
I see two direct reasons why it can't work.
> $datafile = "C:\Websites\cliqon479\cliq-on.com\PIRATES\mysites.txt";
You may not use single backslashes within doublequotes. Any of the
following should work:
$datafile='C:\Websites\cliqon479\cliq-on.com\PIRATES\mysites.txt';
$datafile="C:\\Websites\\cliqon479\\cliq-on.com\\PIRATES\\mysites.txt";
$datafile="C:/Websites/cliqon479/cliq-on.com/PIRATES/mysites.txt";
A tip: Always use straight slashes in Perl code.
> I am using an external txt file that stores links as:
> Schedule | http://www.domain.com/schedule.htm
----------^-^
Are those spaces really there? In that case, this is insufficient:
> ($title, $location) = split(/\|/ , $information);
This should work, though:
($title, $location) = split(/ *\| */ , $information);
-------------------------------------^^--^^
A detail:
> if ($title eq $name)
> {
> $url = $location;
> }
I'd add a 'last;' to stop the loop when the title has been found:
if ($title eq $name)
{
$url = $location;
$last;
}
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 08 Mar 2003 17:47:29 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Redirect with links stored in external txt file
Message-Id: <b4d6qk$1ve7b3$1@ID-184292.news.dfncis.de>
Gunnar Hjalmarsson wrote:
> I'd add a 'last;' to stop the loop when the title has been found:
>
> if ($title eq $name)
> {
> $url = $location;
> $last;
> }
Correction: Without $-sign, of course:
if ($title eq $name)
{
$url = $location;
last;
}
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 8 Mar 2003 17:57:39 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Redirect with links stored in external txt file
Message-Id: <Pine.LNX.4.53.0303081655450.14508@lxplus085.cern.ch>
On Sat, Mar 8, Maria Kovacs inscribed on the eternal scroll:
> I need some advice on redirection using an external cgi and text file.
> OR ANYTHING THAT CAN SOLVE MY PROBLEM!
Considerations for implementing such a scheme would be no different
in principle if you were coding in COBOL, or server-side Javascript,
whatever. Only the coding details would be different, but we aren't
discussing those, not yet. AND PLEASE DON'T SHOUT. :-}
> I am working on a redirect script that would allow me to store all my
> redirect links separately in a txt file.
What convinces you that you need a CGI script to do this?
> I would like to do this
> because the external weblinks I am working with will be locked into a
> software permanently, but most likely will be changed eventually.
You don't need to run a program every time that a link gets used.
Even if they occasionally need to be changed, that's better done by
changing a web server configuration, than by running a program.
> I have a system set up but instead of redirecting me to the external
> URL it either redirects me to the same file or it wants to list the
> contents of the directory thus giving me an error "Denied directory
> listings". Can anybody help what I did wrong?
But unless there's something significant that you're hiding from us, I
don't see why you can't achieve what's wanted without using any CGI
scripts.
If you're definite that you want to perform redirections, rather than
some other solution, then I'd recommend looking at the possibilities
offered by server configuration (in the case of Apache-family servers
this would be done by Redirect, RedirectMatch, or if necessary,
mod_rewrite). Uh-uh, the two servers mentioned in your example seem
to be respectively an IIS and a Netscape-Enterprise, so I can't help
you with that, but they surely have analogous facilities.
> I don't find the problem in the script.
You haven't asked Perl to help you...
> I have a mock up screen of this portion of the software at:
> http://www.cliq-on.com/pirates/Index.htm
It seems to be a client-side imagemap. Congratulations for correct
use of ALT attributes on the AREAs - one sees that so rarely!
But to get to the point, some of the URLs in the imagemap end in
.jsp - which suggests that they're not coded on Perl. hmmm?
> The system desctibed below:
> I am using an external txt file that stores links as:
> Schedule | http://www.domain.com/schedule.htm
>
> Then I am using the following link format (that would be locked into
> the software):
> a href="../cgi-bin/gothere.cgi?name=Schedule"
So to boil this down to the key issue: you want an unchanging URL in
the released software, but you want your server to rewrite it as
necessary to accommodate subsequent changes in real URLs, right?
I still say that running a script on the server is unnecessary for
this - adding complexity and overhead which you don't need. And every
piece of server-side software you write is a potential security
exposure for your server, so if you're not very confident of writing
bullet-proof scripts, there's another benefit of doing it via server
configuration.
> which then passes through a cgi script that is the following:
I take it you aren't really showing us your script in action from your
so-called mock up page, right?
> #!/usr/local/bin/perl
> ######################################
You're ignoring the posting guidelines for this group. That's unwise.
I frankly still think you've chosen the wrong solution to the problem
that you're trying to solve. But let's discuss how you're going about
trying to diagnose the details of your difficulty, anyway.
Aside from recommending that you use warnings and strict, as
recommended by the posting guidelines, and preferring to do CGI-like
work with appropriate module(s), I would suggest to you that you need
to prune your coding down to a simple test-case. Try just coding a
script with a half-dozen lines which disregard the query string, just
simply try redirecting to a constant absolute URL using exactly the
coding that you're trying to use. Does it work for you? If so, then
build it up progressively into what you're aiming for. If not, then
find out why. There's just too much extraneous detail in what you
posted to expect a straight answer as to what it's doing wrong.
[much source code snipped]
That looked very much like perl-4-flavoured "cargo cult", I'd have to
say. I'm not in the mood for detailed source code critique just now,
but I'd like to help you with your troubleshooting technique.
Take a look at brian's excellent CGI troubleshooting page,
http://www.perl.org/troubleshooting_CGI.html
Don't overlook the benefits of troubleshooting a CGI script from the
command line before trying to run it from the server. I suspect that
would have helped iron out your script much more quickly. Of course
you _do_ need to know what the output should look like, so you can
recognise it when you see it.
Your description earlier in your posting was hardly very definite, and
the crystal ball is still rather cloudy.
good luck
------------------------------
Date: 8 Mar 2003 10:50:36 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regular Expressions
Message-Id: <b4chts$jcq$1@mamenchi.zrz.TU-Berlin.DE>
bach <bach@nospamworld.com> wrote in comp.lang.perl.misc:
Don't top-post.
> Thanks for your concern, Anno, but Benjamin Goldberg already answered with
> very useful information. I guess that my gibberish didn't bother him too
> much though yes, I admit, my examples were pseudo-code.
Pseudo-code is one thing, sloppiness is another.
> I guess he was
> able to look past my incompetence, ignorance and other faux-pas to provide
> help that would actually direct me on the right path. Go figure...
So? You got lucky.
> > You just landed yourself in a number of killfiles
> > of those who could potentially help you.
>
> My, I didn't know I could instill so much fear (or disdain). Such a serious
> reaction to such an innocent little post...this is almost funny.
For those of us who try to answer questions, innocent little posts like
yours sum up to a huge waste of time. Fear and disdain are not involved.
Anno
------------------------------
Date: 8 Mar 2003 03:13:20 -0800
From: kydongau@yahoo.com.au (kydongau)
Subject: Re: Skip directories and Find
Message-Id: <738c2d89.0303080313.698c730d@posting.google.com>
Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3E685FF1.4C29605A@earthlink.net>...
> kydongau wrote:
> >
> > Hi,
> > I want to get the total size of all files under $path except for those
> > under @exclude directories. I am using Prune but it does not seem
> > working,
> [snip]
> > $File::Find::Prune = 1;
>
> Reread the documentation. The variable's name is not "Prune".
>
> Here's a hint: You are exactly one bit off from the right name.
Thanks, got it "p"
KD
------------------------------
Date: Sat, 8 Mar 2003 08:31:06 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: SUBSTR or pattern matching?
Message-Id: <MPG.18d3baa9f8a100de989734@news.mts.net>
In article <que76vctuialp9vo5hkvdeflrku8jd8mfv@4ax.com>,
impervious@attbi.com (impervious@attbi.com) says...
> What is the best technique to use when trying to work with a string
> that contains a date and you want to find the day? Ie. in a string
> like this is want to find out that the day is the 25th:
>
> 12/25/2000 blah blah blah blah
>
> However, for the single digit months, the line will read:
>
> 3/25/2000 blah acih jklm wish
>
> So I can't use substr($_, 3, 2); in both cases because the day will be
> offset by one depending on how many digits the month has. So my
> question is, would pattern matching help solve this?
>
> And how could I trim everything beyond the date and 'blah' to the end
> of line so that I ended up with
>
> 3/25/2000 blah
>
$buffer = "12/25/2000 blah acih jklm wish"
$buffer =~ m/(\d+)\/(\d+)\/(\d+)\s+(\w+)/; # match date & following word
$month = $1;
$day = $2;
$year = $3;
$word = $4;
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: Sat, 8 Mar 2003 17:25:13 +0100
From: "Asby" <asby@kinderen4kinderen.org>
Subject: Re: SUBSTR or pattern matching?
Message-Id: <3e6a196b$0$49113$e4fe514c@news.xs4all.nl>
"Barry Kimelman" <barryk2@SPAM-KILLER.mts.net> wrote in message
news:MPG.18d3baa9f8a100de989734@news.mts.net...
> $buffer =~ m/(\d+)\/(\d+)\/(\d+)\s+(\w+)/; # match date & following word
Or maybe more readable:
$buffer =~ m!\d+/(\d+)/\d+!;
$day =$1;
--
ttfn,
Asby
$_="qdjb3H kqdP qdgsnmA srtJ";y/a-y3/b-za/;print scalar reverse
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4684
***************************************