[7953] in Perl-Users-Digest
Perl-Users Digest, Issue: 1578 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 4 14:07:18 1998
Date: Sun, 4 Jan 98 11:00:30 -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 Sun, 4 Jan 1998 Volume: 8 Number: 1578
Today's topics:
Re: "Excessive Paranoia" using crypt (Chris Winters)
CGI Bin Locked????? HAY-ELP!! (Sean O'Dwyer)
Re: Fast Suggestions for this string manipulation probl (Justin Vallon)
Help im stuck <agtbjw@btinternet.com>
How to install new modules in private dir <lxu@rice.edu>
I tired to modify.... <kriebels@nauticom.net>
ioperm() and friends <bullock@toolcity.net>
MultiDimensional array. Simple one <rarun@geocities.com>
New Module List Posted (Andreas Koenig)
Re: Perl not Y2K compliant (Chris Thompson)
Re: Perl not Y2K compliant (I R A Aggie)
Re: PERLIPC - FIFO: parent, child, stalled! <jbattikha@highsynth.com>
Re: redirection using Location <shadowweb@worsdall.demon.co.uk>
Re: UserAgent and POST questions <merlyn@stonehenge.com>
Re: Why stripper not work? Anyone Bar Tom as he seems t <merlyn@stonehenge.com>
Re: Why stripper not work? Anyone Bar Tom as he seems t <shadowweb@worsdall.demon.co.uk>
Re: Why stripper not work? Anyone Bar Tom as he seems t (brian d foy)
Re: www.roth.net (Barry Hoggard)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 04 Jan 1998 14:41:06 GMT
From: cwinters@clark.net (Chris Winters)
Subject: Re: "Excessive Paranoia" using crypt
Message-Id: <34af9f2d.1513500@news.clark.net>
"Edward Morris, Jr." <emorr@fast.net> wrote:
>They don't include crypt in the Win32 version. I guess they don't want
>you to figure out hashing of passwords unless you're a sysadmin, since
>Win32 Perl is usually on a stand-alone platform.
Actually, I think they've included it for a while. I'm using
build 303 (not the latest by about 10 months) and crypt works
great.
Chris Winters
Webmaster
chris@cwinters.com
------------------------------
Date: Sun, 04 Jan 1998 13:33:06 -0500
From: sean@dcdX.net (Sean O'Dwyer)
Subject: CGI Bin Locked????? HAY-ELP!!
Message-Id: <sean-0401981333060001@p13.ts6.newyo.ny.tiac.com>
Hi,
I'm a Perl newbie. I've written some scripts which I want to run from my
CGI bin so that's where I put them. There are several other scripts in
there already which run fine.
When I try to access these scripts (calling them from a web page) I get an
error message saying "403 Forbidden. Your client does not have permission
to get URL /cgi-bin/demo/rndmzr.cgi from this server."
Is there some security option I'm missing? Or does anyone have a clue
what's going on?
Thanks in advance for any wisdom you can throw my way.
Sean
------------------------------
Date: Sun, 4 Jan 1998 09:21:47 -0500
From: vallon@mindspring.com (Justin Vallon)
Subject: Re: Fast Suggestions for this string manipulation problem
Message-Id: <19980104092147421530@user-38lcfdf.dialup.mindspring.com>
Mark Worsdall <shadowweb@worsdall.demon.co.uk> wrote:
> So my problem is deciding what rules to adopt for chopping begginings of
> domain names:-
>
> 1) if ends in .com then chop all off BAR 1 left with worsdall.com
> 2) if ends with .com. then reduce to internet.com.mx or internet.com.au,
> dependening on the original domain name.
> 3) if ends with .demon.co.uk and has only 1 word before the first . then
> leave alone (there maybe other ISP operating like this).
> 4) if ends with .co. but not rule 3 then do a rule 2
> 5) if academic then for now reduce 1st word only (ubless someone knows
> the rules for ac/edu sites?)
> 6) if .org. then rule 2
> 7) if .org then rule 1
> 8) if .mil then reduce to 2 dots
> 9) if .gov rule 8
> 10) if non rules above leave alone, do not know about fridge1.volvo.se
> reducing to volvo.se
>
...
> but about to change to:-
>
>
> # if (/\.demon\.co\.uk$/)
> # {
> # Do demon summoning stuff
> # }
> # elsif (/\.co\./)
> # {
> # National companies -- do something despite the management
> # }
> # elsif (/\.mil/)
> # {
> # US Military -- do something, sir
> # }
>
> # I suggest /\.co\.??$/ and /\.mil$/
Assuming that you are just interested in trimming down the DNS name, and
not doing any special processing for edu vs org vs com:
my @components = split /\./, $name;
my $keep; # How many to keep
if ($name =~ /\.demon\.co\.uk$/) {
$keep = 4;
}
# If .com$|.org$|.edu$, use xyz.com
elsif ($components[-1] eq "com" || $components[-1] eq "org" ||
$components[-1] eq "edu") {
$keep = 2;
}
elsif ($components[-1] =~ /^mil$|^gov$/) {
$keep = 3;
}
elsif ($components[-2] eq "com" ...) {
# xyz.com.uk
#keep = 3;
}
elsif ($components[-2] =~ /^mil$|^gov$/) {
$keep = 4;
}
else {
print STDERR "hmmm: $name\n";
$keep = 3;
}
while (@components > $keep) {
shift @components;
}
$name = join ".", @components;
Or:
local %keepdomains;
map { $keepdomains{$_} = 2; } ("com", "org", "edu", "co");
map { $keepdomains{$_} = 3; } ("mil", "gov");
local %countries;
map { $countries{$_} = 1; } ("uk", "au", "se", ...);
my @components = split /\./, $name;
my $keep; # How many to keep?
if ($name =~ /\.demon\.co\.uk$/) {
$keep = 4;
} elsif ( $keepdomains{$components[-1]} ) {
# .com, .org, .edu, .mil, .gov
$keep = $keepdomains{$components[-1]};
} elsif ( @components >= 2 && $countries{$components[-1]} &&
$keepdomains{$components[-2]} ) {
# .com.uk, .org.au, .co.se
$keep = 1+$keepdomains{$components[-2]};
} else {
# Keep everything?
$keep = @components;
# Or $keep = 2; $keep++ if $countries{$components[-1]}
print STDERR "No match for $name\n";
}
while (@components > $keep) {
shift @components;
}
$name = join ".", @components;
You could alternately have a file that lists domains:
.demon.co.uk 4
.xyz.co.uk 4 # Parent company
.com 2
.org 2
.edu 2
.mil 3
.gov 3
.nasa.gov 4 # Want more info about nasa.gov
.com.uk 3
.co.uk 3
.com.au 3
.com.se 3
.org.uk 3
And so on. That might be a little slower to pattern match (you might be
able to sort the reverse of the string for faster lookup), but would
probably be much simpler to maintain.
--
-Justin
vallon@mindspring.com
------------------------------
Date: Sun, 4 Jan 1998 14:16:08 -0000
From: "agtbjw" <agtbjw@btinternet.com>
Subject: Help im stuck
Message-Id: <68o5jl$5ru$1@uranium.btinternet.com>
Hello I am a first year student and studying perl.
Can anyone help with my problem
I have to write a program which searches for and outputs each word in an
input file. Each word must start with a letter and may include letters
numbers and underline'_'
the space will act as the separator between the words.
It sounds easy but I have no syntax to search for a letter,
I dont know how to get to the input file
Thanks for your help
Belinda
belinda.w@btinternet.com
------------------------------
Date: Sun, 04 Jan 1998 11:29:28 -0600
From: Li Xu <lxu@rice.edu>
Subject: How to install new modules in private dir
Message-Id: <34AFC6F8.5EF4@rice.edu>
The Perl release on my site is as follows:
------------------------------
This is perl, version 5.003 with EMBED
built under solaris at Jun 27 1996 14:44:19
+ suidperl security patch
Copyright 1987-1996, Larry Wall
------------------------------
As I found out there are quite a few most up-to-date
core modules missing in this release such as IO::Socket. I really want
to use some of the newest
modules. However I am just a plain user without
the root privilege. Is it possible to install those
modules in my private directory? If yes, then
how to do it systematically?
Thanks for advice.
(This maybe a naive question, but I cannot figure
it out myself.)
--Li
------------------------------
Date: 4 Jan 98 14:12:02 GMT
From: "Kriebel" <kriebels@nauticom.net>
Subject: I tired to modify....
Message-Id: <01bd1932$ca125460$6a7fabcc@ppp826278>
hello..
I tried to modify a scrip...but It didnt work..
I cannot get this to work.
could someone please help..
this is the part of the script I modified..
if( !/<!-- startOfAds -->/ ){
print FILE;
}else
{ #modify this to suit your format. leave 'singleAd'
comment.
print FILE;
print FILE "<b>Band Name: <a href=\"$DATA{ 'BandURL' }\">$DATA{
'BandName' }\n";
print FILE "</a><table><tr><td>Song Title: $DATA{ 'SongTitle'
}\n";
print FILE "<a href=\"$DATA{ 'URLofRAM' }\"><img
src=\gif\playbutton.gif>\n";
print FILE "</a></tr><td></table><br><hr width="70%"><br>\n";
print FILE "<\!-- singleAd -->\n\n";
}
}
}
is there anything wrong with that..or could it been possibly be the script
whats screwing up also..
please help me..nobody else is.
SK
------------------------------
Date: Sun, 04 Jan 1998 11:50:31 -0500
From: Ben Bullock <bullock@toolcity.net>
Subject: ioperm() and friends
Message-Id: <34AFBDD7.151528F6@toolcity.net>
I have a small project that involves reading sensors attached to an
inexpensive Analog/Digital card. I've written a program in C that does
this, but would also like to write a similiar program in perl. My
question is whether or not there is a perl module available that would
give me the equivalent functionality of C's ioperm(), outb() and inb()
functions for getting access to and using IO ports? If so, where might
I find it?
Thanks in advance for any help you can give me.
Ben Bullock
bullock@toolcity.net
------------------------------
Date: Sun, 04 Jan 1998 13:31:22 -0500
From: Arun <rarun@geocities.com>
Subject: MultiDimensional array. Simple one
Message-Id: <34AFD57A.A7E82AD4@geocities.com>
Hello all,
I am querying the database which returns me multiple records.
I am trying to insert these values into a array, each element of which
contains a record.
while ( ($cs_list[0], $cs_list[1], $cs_list[2],
$cs_list[3], $cs_list[4], $cs_list[5],
$cs_list[6], $cs_list[7], $cs_list[8]) = &ora_fetch($csr))
{
push @cs_array,[@cs_list];
}
My problem is how do I access each element of @cs_array for further
manipulation?
If I do this,
foreach(@cs_array) {
# I need to get the first block of @cs_array here
print;
}
When I print out the elements,all it seems to be giving back is a
address of some sort. I think I need to de-reference it. But how?
HELP!!
I've tried various combinations, but none seem to work. Any help would
be appreciated
------------------------------
Date: 4 Jan 1998 18:28:21 GMT
From: andreas.koenig@franz.ww.tu-berlin.de (Andreas Koenig)
Subject: New Module List Posted
Message-Id: <68okc5$hu0$1@brachio.zrz.TU-Berlin.DE>
Keywords: FAQ, Perl, Module, Software, Reuse, Development, Free
The Perl 5 Module List, v2.46
=============================
Today I posted a new module list to the newsgroups
comp.lang.perl.modules, comp.answers, and news.answers. The HTML
version of the list has been uploaded to CPAN as well:
http://www.perl.com/CPAN/modules/00modlist.long.html
As usual, comments, corrections and suggestions are more than
welcome. Please mail them to
modules@perl.org
I believe that I have taken into account all mails we have received
since the last posting. If this is not the case, please let us know. A
big Thank You to all contributors helping us to keep the document up
to date and apologies to all who didn't get responses as quick as they
should.
Recent Changes in the modules database
--------------------------------------
2) Perl Core Modules, Perl Language Extensions and Documentation Tools
----------------------------------------------------------------------
Taint bdpf Utilities related to tainting PHOENIX !
3) Development Support
----------------------
Rcs adcf Alternate RCS interface (see VCS::RCS) CFRETER +
VCS::
::RCS idpf Interface layer over RCS (See also Rcs) RJRAY !
4) Operating System Interfaces
------------------------------
Mac::Apps::
::Launch RdpO Launch/Quit Mac OS Apps by creator ID CNANDOR +
Schedule::
::At Rd OS independent interface to the at command JOSERODR +
VMS::
::Persona Rdcf Interface to the VMS Persona services DSUGAL +
::Process Rdcf Process management on VMS DSUGAL +
::Queue bdcf Manage queues and entries DSUGAL +
::System Rdcf VMS-specific system calls DSUGAL +
6) Data Types and Data Type Utilities (see also Database Interfaces)
--------------------------------------------------------------------
Math::
::Fraction bdpO Fraction Manipulation KEVINA !
7) Database Interfaces (see also Data Types)
--------------------------------------------
AsciiDB::
::Parse i Generic text database parsing MICB +
DBD::
::mSQL RmcO Msql Driver for DBI JWIED !
::mysql RmcO Mysql Driver for DBI JWIED +
Ingperl ampf Ingperl emulation interface for DBD::Ingres HTOUG !
Pg Rdcf PostgreSQL SQL database interface MERGL !
8) User Interfaces (Character and Graphical)
--------------------------------------------
Emacs::
::Lisp adcO Support for perl embedded in GNU Emacs JTOBEY +
Term::
::ANSIColor Rdpf Color output using ANSI escape sequences RRA !
10) File Names, File Systems and File Locking (see also File Handles)
---------------------------------------------------------------------
File::
::MultiTail adpO Tail multiple files SGMIANO +
::Sort adpf Emulate some functions of sort(1) CNANDOR +
::Tail bdpO A more efficient tail -f MGRABNAR +
11) Text Processing, Parsing and Searching
------------------------------------------
Number::
::Format adpO Package for formatting numbers for display WRW +
SGML::
::SPGrove bd+O Load SGML, XML, and HTML files KMACLEOD +
Text::
::Metaphone adpf Phonetic encoding. A modern Soundex MSCHWERN !
::Vpp bdpO Versatile text pre-processor DDUMONT !
18) Images, Pixmap and Bitmap Manipulation, Drawing and Graphing
----------------------------------------------------------------
GIFgraph RdpO Package to generate GIF graphs, uses GD.pm MVERB !
19) Mail and Usenet News
------------------------
Mail::
::POP3Client RdpO Support for clients of POP3 servers SDOWD !
::UCEResponder i Spamfilter CHSTROSS +
News::
::Article adpO Module for handling Usenet articles AGIERTH +
21) File Handle, Directory Handle and Input/Output Stream Utilities
-------------------------------------------------------------------
IO::
::Stty bdpf POSIX compliant stty interface AUSCHUTZ +
::Wrap adpO Wrap old-style FHs in IO::-like interface ERYQ +
23) Miscellaneous Modules
-------------------------
FAQ::
::Omatic RdpO A CGI-based FAQ/help database maintainer JHOWELL +
Recent Changes in the users database
------------------------------------
AGIERTH Andrew P. J. Gierth <andrew@erlenstar.demon.co.uk>
AUSCHUTZ Austin Schutz <tex@habit.com>
BASKAR Baskar S <baskar@india.ti.com>
BPANNIER Benjamin Pannier <karo@artcom.net>
CEVANS Carey Evans <c.evans@clear.net.nz>
CFRETER Craig Freter <freter@freter.com>
CHSTROSS Charlie Stross <charlie@public.antipope.org>
CLINTDW Clinton Wong <clintdw@netcom.com>
DIONALM Dion Almaer <dion@member.com>
DMEGG David Megginson <dmeggins@microstar.com>
EHOOD Earl Hood <ehood@medusa.acs.uci.edu>
FIMM Dennis Taylor <corbeau@execpc.com>
GBACON Greg Bacon <gbacon@cs.uah.edu>
GFLOHR Guido Flohr <gufl0000@stud.uni-sb.de>
IKETRIS Ilya Ketris <ilya@gde.to>
JHI Jarkko Hietaniemi <jhi@iki.fi>
JHOWELL Jon Howell <jonh@cs.dartmouth.edu>
MAURICE Maurice Aubrey <maurice@hevanet.com>
MSCHWERN Michael G Schwern <schwern@rt1.net>
MSOLOMON Mark Solomon <msolomon@seva.net>
PMH Peter Haworth <pmh@edison.ioppublishing.com>
RAP Ryan Alyn Porter <rap@endymion.com>
RSI Rajappa Iyer <rsi@earthling.net>
SGMIANO Stephen G. Miano <stevem@mindspring.com>
WRW William R Ward <wrw@bayview.com>
--
andreas
------------------------------
Date: 4 Jan 1998 14:15:14 GMT
From: NOSPAM@cam.ac.uk (Chris Thompson)
Subject: Re: Perl not Y2K compliant
Message-Id: <68o5hi$p4i$1@lyra.csx.cam.ac.uk>
In article <68n7bh$okq$1@pulp.ucs.ualberta.ca>,
Michal Jaegermann <michal@gortel.phys.ualberta.ca> wrote:
>Michael J Gebis (gebis@albrecht.ecn.purdue.edu) wrote:
>: michal@gortel.phys.ualberta.ca (Michal Jaegermann) writes:
>: }$ perl -lwe 'print scalar localtime (1 << 55)'
>: }Sat Jun 12 23:26:08 1141709097
>:
>: }Should last for a while.
>:
>: That's the sort of attitude that got us into this mess in the first
>: place.
>
>Oh, I would rather worry that this likely will not be "Sat Jun 12"
>as a slowdown of a globe rotation will cause quite a bit of shift
>by that time.
No problem, as the Unix time(2) values [and hence presumably Perl time values]
are defined to be seconds since 00:00:00 1 Jan 1970 _ignoring leap seconds_.
Of course, the fact that in 1140 My time they will be having to put in
leap seconds every 3 or 4 seconds (back-of-the-envelope guestimate: it
depends on tidal friction, so there's no certainty in such matters) may
be causing them a little trouble...
Chris Thompson
Email: cet1 at cam.ac.uk
------------------------------
Date: Sun, 04 Jan 1998 12:46:43 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl not Y2K compliant
Message-Id: <-0401981246440001@aggie.coaps.fsu.edu>
In article <68mh6u$7hd@mozo.cc.purdue.edu>, gebis@albrecht.ecn.purdue.edu
(Michael J Gebis) wrote:
+ michal@gortel.phys.ualberta.ca (Michal Jaegermann) writes:
+ }$ perl -lwe 'print scalar localtime (1 << 55)'
+ }Sat Jun 12 23:26:08 1141709097
+ }Should last for a while.
Indeed.
+ That's the sort of attitude that got us into this mess in the first
+ place.
Ummm...this planet isn't likely to be inhabited by humans in a billion
years...sometimes "good enough" _is_ good enough.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Sun, 04 Jan 1998 13:32:58 -0500
From: Jihad Battikha <jbattikha@highsynth.com>
To: Justin Vallon <vallon@mindspring.com>
Subject: Re: PERLIPC - FIFO: parent, child, stalled!
Message-Id: <34AFD5DA.1AA9BF2A@highsynth.com>
Justin Vallon wrote:
> According to perl5, "undef == 0", so your test is not correct.
>
> A typical fork call will look something like the following:
>
> my $pid = fork();
>
> if (undef $pid) {
> # Error: $!
> } elsif (!$pid) {
> # Child.
> # Do stuff.
> exit 0;
> }
>
> # Parent goes on. Child pid is $pid.
>
> # Join up with child.
> my $wait_pid = wait;
> die "missing child" if $wait_pid == -1;
> die "unexpected child" if $wait_pid != $pid;
what perlfunc states about fork:
"Does a fork(2) system call. Returns the child pid to the parent process
and 0 to the child process, or undef if the fork is unsuccessful."
Doesn't that mean that 'undef' does not mean "undef == 0", it means
undefined, no data, no return info, etc., so if ($pid == 0) we'd be in
the child, if (defined $pid) we'd be in the parent, if (undef $pid) we'd
have an error. At least that's what I made out. I also found a few
examples in books that ($pid == 0) means we're in the child.
I suppose I could do without the ($pid == 0), but it works for me... we
could also try:
if ($pid) <--parent
if ($pid = fork) <--parent
if (defined($pid = fork)) <-- parent
if (!defined($pid = fork)) <-- error
Anyway, since my child was blocking, I couldn't call wait or the parent
would hang. I ended up using the POSIX module so I could call waitpid
with WNOHANG to make sure the parent didn't get blocked by the child.
> You should probably set '$| = 1' at the top of your script. fork can
> double-flush stdout if you have buffered output.
Yes, I ended up using this. My posts must not be propogating to
MindSpring adequately ;-)
> A word of caution: you might want to put your PID ($$ or $PID) in the
> temp files that you use:
>
> $FIFO = "$ENV{DOCUMENT_ROOT}/temp/cryptpipe.$$.txt";
>
> That way, simultaneous executions will use different file names.
My post was a sample script. My final one (that I'm building on now) is
using a combination of date, time, remote ip, and rand number to
dynamically generate the temp file. I can also include $$ in the name
as you suggest.
> Your FIFO should exist before you fork. With 'sleep(2)', you make the
> assumption that the child will run within the two seconds, and create
> the FIFO. That is a bad style, especially on a machine that may be
> busy, or where the file server is slow.
>
> Rather, create the FIFO up front:
>
> [---snip---]
Sorry to snip your helpful code, but I've already fixed all the problems
you're talking about as you'll be able to see from my most recently
posted code (if it's made through MidSpring's newsfeed yet). I've even
tweaked it some more since then... I'll have to check with my provider
on why my posts aren't showing up on MindSrping adequately.
> Don't use FIFO as the name of a variable and the name of a file handle.
> At best, it's hard to read. At worst, it could confuse perl.
Point well taken. Easy to fix.
> # It looks like you just want to run $pgpcmd. There is no need for the
> # piped open.
Yes, that was later fixed - the open() was left over from my using STDIN
to pipe data into PGP. Technically, it still works, since PGP will just
ignore the pipe command and run as usual. Using Tom's suggestion, I
ended up using system().
> # The child will have exited at this point.
> if (wait != $pid) {
> &error("unexpected pid");
> }
Like I said earlier, I can't call a normal wait here since the child is
blocking (waiting for a READ on the FIFO). I have to make sure the
parent continues without waiting for the child's exit code since the
parent is the process that causes PGP to read from FIFO.
> Dealing with two processes (your pipe writer and pgp) simultaneously
> significantly increases the complexity of the program. For example, if
> the pipe writer process fails to open the pipe (for whatever reason),
> the pgp process will never get EOF on the pipe, and will block.
>
> [---snip---]
Justin, thanks for all that helpful code. Indeed, I was concerned about
PGP blocking if the FIFO child failed for some reason. I'll study your
code & see about testing this stuff some more.
--
_JIHAD_BATTIKHA___________
| jbattikha@highsynth.com `\
| http://www.highsynth.com |
| ====================== __H__
| - graphics | | |
| - 2d/3d animation |__|__|
| - illustration ) |
| - interface design / |
:.. . . . . . . . \_____/
------------------------------
Date: Sun, 4 Jan 1998 13:40:19 +0000
From: Mark Worsdall <shadowweb@worsdall.demon.co.uk>
Subject: Re: redirection using Location
Message-Id: <xfsR3DADF5r0EwGt@worsdall.demon.co.uk>
In article <34AF2B8C.7ACA3399@createyourweb.com>, Neil Trenholm
<webmaster@createyourweb.com> writes
>I am buying web & cgi "space" on a Unix server. My Unix & perl
>knowledge is basic but improving - thanks to many people.
>
>My problem:
>-----------
>I am using perl to redirect users using print "location:$url\n\n" and
>get a 302-Temporarily moved.
>
>My Questions:
>-------------
>What is a 302 and why do I get it ?
>Does this mean redirection is not allowed on my server ?
>
It may mean that your destination held in $url has indeed moved
temporarily. Try the following things first.
1) With you browser check the $url contents (the url address) is
readable by your browser. If it gets the same error then it is not your
program, but it must be the destination.
assuming the URL address is valid:-
2) Replace the $url with the hard address, i.e.:-
$url = "http://www.worsdall.demon.co.uk/wizdom.html";
print "Location: $url\n\n";
replace with:-
print "Location: http://www.worsdall.demon.co.uk/wizdom.html\n\n";
Now if you get the same error then I have no idea.:-)
--
Mark Worsdall (Webmaster) - WEB site:- http://www.shadow.org.uk
Shadow:- webmaster@shadow.org.uk
Home :- shadowweb@worsdall.demon.co.uk
Any opinion given is my own personal belief...
------------------------------
Date: 04 Jan 1998 06:59:04 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: sase@sasezdesyn.com (SasEz! Publications and Design)
Subject: Re: UserAgent and POST questions
Message-Id: <8cd8i8z6fr.fsf@gadget.cscaper.com>
>>>>> "SasEz!" == SasEz! Publications and Design <sase@sasezdesyn.com> writes:
SasEz!> #!/usr/bin/perl
SasEz!> # Create a user agent object
SasEz!> use LWP::UserAgent;
SasEz!> $ua = new LWP::UserAgent;
SasEz!> $ua->agent("AgentName/0.1 " . $ua->agent);
SasEz!> # Create a request
SasEz!> my $req = new HTTP::Request POST =>
SasEz!> 'http://www.sasezdesyn.com/freestuff/links.cgi';
SasEz!> $req->content_type ("application/x-www-form-urlencoded");
SasEz!> $req->content
SasEz!> ("name=title&value=test2;name=url&value=http://www.test.com");
This is much simpler (from "perldoc lwpcook"):
use HTTP::Request::Common qw(POST);
my $req = POST 'http://www.sasezdesyn.com/freestuff/links.cgi',
[ title => 'test2', url => 'http://www.test.com' ];
You had a completely botched content there. That was part of the problem.
It should have just been 'title=test2&url=http://www.test.com'. In fact,
you can add:
print $req->as_string;
To see how it came out. Here's what this shows:
POST http://www.sasezdesyn.com/freestuff/links.cgi
Content-Length: 41
Content-Type: application/x-www-form-urlencoded
title=test2&url=http%3A%2F%2Fwww.test.com
Ahh! Notice that even the ugly-chars in your url needed to be
escaped. Again, relying as much as possible on standard libs is the
*right* way to go.
SasEz!> Now for my other questions.....
SasEz!> ...Req POST=> #can I put a variable in here? @form('url')
Yes, in both yours and mine.
SasEz!> $req->content #can I put a variable or associative array here?
Yes, in both yours and mine. Mine's easier though. :-) Handles all
the necessary escaping.
SasEz!> Can I put the new request section inside of a for/foreach statement?
SasEz!> For instance,
SasEz!> $file = '/etc/passwd';
SasEz!> open(INFO, $file);
SasEz!> for ($i = 0; $i < 100; ++$i)
SasEz!> $" = $i;
SasEz!> @line = <INFO>;
SasEz!> close(INFO);
SasEz!> for $line
SasEz!> {
SasEz!> New User Agent....
SasEz!> }
Yes, but you need create the User Agent only once. Think of the User Agent
as your virtual "browser". You don't need to fire up your browser five
times to visit five different pages. (Well, on some, maybe you do. :-)
You should look at my columns at
http://www.stonehenge.com/merlyn/WebTechniques/
They'd give you more insight on using the LWP library to perform web
operations. And as always, thanks to Miller-Freeman for letting me
put such a valuable resource on the web.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 240 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 04 Jan 1998 06:47:25 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Mark Worsdall <shadowweb@worsdall.demon.co.uk>
Subject: Re: Why stripper not work? Anyone Bar Tom as he seems to answer alot
Message-Id: <8chg7kz6z6.fsf@gadget.cscaper.com>
>>>>> "Mark" == Mark Worsdall <shadowweb@worsdall.demon.co.uk> writes:
Mark> Why does not this strip routine not do the full monty?
Mark> $referer = "http://www.altavista.digital.com/cgi-bin/query?pg=q&stq=50&w
Mark> hat=web&kl=XX&q=building+the+core+mu
Mark> scles+of+the+athalete&navig60.x=7&navig60.y=11";
Mark> @strippers = ("&what",
Mark> "=XX&q",
Mark> "cgi-bin/query?pg",
Mark> "bin/query?p",
Mark> "=XX&q",
Mark> "=web&kl",
Mark> "=q&stq=50", # How make any numbers get stripped?
Mark> "&navig60.x=7&navig60.y=11", # ditto
Mark> "="); # Any = chars left
Mark> foreach (@strippers) {
Mark> $referer =~ s/\$_//;
Mark> print $strip . "\n";
Mark> }
Because some of your patterns have regex special characters, like ? and ".".
This is much easier anyway (don't reinvent the wheel!):
use URI::URL;
$referer = "http://www.altavista.digital.com/cgi-bin/query?pg=q&stq=50".
"&what=web&kl=XX&q=building+the+core+muscles+of+the+athalete".
"&navig60.x=7&navig60.y=11";
$url = url $referer;
@form = $url->query_form; # you can use a hash here, but will lose dups
while (($key, $value) = splice @form, 0, 2) {
print "$key => $value\n";
}
And you know, this gives me an idea to use this in a future
WebTechniques column about parsing my referer log to see why people
are hitting my page. Neat idea, thanks! Prior columns are at
http://www.stonehenge.com/merlyn/WebTechniques/
which you should check out for other examples of URI::URL and the
entire LWP library.
And Tom's not barred. He's selective about what he reads here, and even
more selective about what he answers. Me too.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 240 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Sun, 4 Jan 1998 16:18:50 +0000
From: Mark Worsdall <shadowweb@worsdall.demon.co.uk>
Subject: Re: Why stripper not work? Anyone Bar Tom as he seems to answer alot
Message-Id: <sN22TFAqZ7r0EwkC@worsdall.demon.co.uk>
In article <8chg7kz6z6.fsf@gadget.cscaper.com>, Randal Schwartz
<merlyn@stonehenge.com> writes
>This is much easier anyway (don't reinvent the wheel!):
I cannot use this module:( My ISP won't install it, and I myslef have to
this day never managed to install another module into our own library
successfully.
>
> use URI::URL;
>
[snip]
>
>And you know, this gives me an idea to use this in a future
>WebTechniques column about parsing my referer log to see why people
>are hitting my page. Neat idea, thanks! Prior columns are at
>
Yes I have been doing this now for a year at Shadow, I just wnated to
make perl do all the removing/stripping for me, a daily bind, which it
seems I will still have to do:(
It is very useful cos it gives us an idea on how much the search engines
are takin in of our site.
We also log people who link/bookmark us aswell as the usenet articles
etc.
[snip]
>
>And Tom's not barred. He's selective about what he reads here, and even
>more selective about what he answers. Me too.
What I meant was, he is always answering my query's, so I though it
would be nice for someone else to take the trouble, such as yourself:-)
Mark.
--
Mark Worsdall (Webmaster) - WEB site:- http://www.shadow.org.uk
Shadow:- webmaster@shadow.org.uk
Home :- shadowweb@worsdall.demon.co.uk
Any opinion given is my own personal belief...
------------------------------
Date: Sun, 04 Jan 1998 12:13:27 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Why stripper not work? Anyone Bar Tom as he seems to answer alot
Message-Id: <comdog-0401981213270001@news.panix.com>
Keywords: just another new york perl hacker
In article <sN22TFAqZ7r0EwkC@worsdall.demon.co.uk>, Mark Worsdall <shadowweb@worsdall.demon.co.uk> posted:
> In article <8chg7kz6z6.fsf@gadget.cscaper.com>, Randal Schwartz
> <merlyn@stonehenge.com> writes
> >This is much easier anyway (don't reinvent the wheel!):
> I cannot use this module:( My ISP won't install it, and I myslef have to
> this day never managed to install another module into our own library
> successfully.
> > use URI::URL;
perhaps we can help you install modules in your private directory!
however, i would change ISPs. it's too competitive a market to
deal with admins who don't know how to install perl modules (i've
had to hand hold many ISPs through the process. now i just move
my clients elsewhere - an email to internic is all it takes :)
so, what goes wrong when you try to install modules? (and can
Tom P. answer if he gets here before i come back? :)
> >And you know, this gives me an idea to use this in a future
> >WebTechniques column about parsing my referer log to see why people
> >are hitting my page.
looking at referrer logs? people still do that sort of thing? i
used to do that for clients until i realized that they didn't
care. just like the agent log...
--
brian d foy <http://computerdog.com>
------------------------------
Date: Sun, 04 Jan 1998 17:45:28 GMT
From: hoggardb@panix.com (Barry Hoggard)
Subject: Re: www.roth.net
Message-Id: <34afca6f.1720956@news.panix.com>
On Sun, 04 Jan 1998 17:09:23 +1100, Anthony David
<adavid@netinfo.com.au> wrote:
>
>There are CPAN everywhere. The CPAN multiplexor probably sent youto the
>nearest CPAN to you which seems to be down. Try this -
> http://www.perl.com/CPAN/SITES.html
Actually, I've been to CPAN to get it. My understanding was that the
roth.net site had additional resources and info on the module that I
wanted to see.
Barry Hoggard | my home page - http://www.panix.com/~hoggardb
hoggardb@panix.com | National Association of Investors WebOp
New York, New York | http://www.better-investing.org
------------------------------
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 1578
**************************************