[11646] in Perl-Users-Digest
Perl-Users Digest, Issue: 5246 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 28 21:03:06 1999
Date: Sun, 28 Mar 99 18:00:20 -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, 28 Mar 1999 Volume: 8 Number: 5246
Today's topics:
Re: [AJM] Need assistance with sockets and Perl (Ronald J Kimball)
A script (Solder182)
Re: Adding an $ENV variable? (brian d foy)
Anyone please help with a script? freehtmlhelp@softhome.net
Re: Calcultor CGI <cassell@mail.cor.epa.gov>
Re: dividing with perl <jamesht@idt.net>
Re: Easy ?... why doesn't this script run on NT? (Ronald J Kimball)
Re: File isn't locked, but Perl says it is? (Ronald J Kimball)
Re: file sunroutines (Ronald J Kimball)
Re: IIS4 and Perl <jamesht@idt.net>
Re: Initializing an array with STDIN (newbie) <fairfiel@dundee.net>
Re: internal server error <larsplessmann@gmx.de>
Re: internal server error (Abigail)
Re: Need automatic forwarding perl script (Abigail)
Re: Need automatic forwarding perl script (Abigail)
Re: Need automatic forwarding perl script (Abigail)
Re: perl port for 16-bit MSDOS? (Ronald J Kimball)
Re: Problem importing multiple values using "strict" (Ronald J Kimball)
Re: Q on procmail piped to perl (Ronald J Kimball)
Re: Q: redefined subroutines (Ronald J Kimball)
Re: Require Question (Abigail)
Re: Split with + , but no %2B (brian d foy)
Re: Split with + , but no %2B (brian d foy)
verbose 'make test' to explain t/ftp 'Error 29'? <jamesht@idt.net>
Re: Why do we like Perl? (the jackal)
Re: Writing isn't working, and the mode is set, Help! <wflanagan@msn.com>
Re: Writing isn't working, and the mode is set, Help! <wflanagan@msn.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 28 Mar 1999 19:17:59 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: [AJM] Need assistance with sockets and Perl
Message-Id: <1dpe1h5.iodzti1qcqnh5N@p125.tc3.state.ma.tiac.com>
Murphy <jt45@tir.com> wrote:
> Here are the errors: The first is when I try to access the server by
> name, and the second when I try to use it's IP address directly.
> ---
> M:\Apache BEMS Server\PerlTest>perl client1.pl bems test
> getservbyname: cannot get test : Unknown error at client1.pl line 19.
> ---
I don't know that 'test' is a valid service name. Can't you just
specify the port by number?
> M:\Apache BEMS Server\PerlTest>perl client1.pl 152.116.112.166 test
> gethostbyname: cannot locate host: Unknown error at client1.pl line
> 17.
> ---
'152.116.112.166' is not a valid argument to gethostbyname() - it's an
unpacked adress, not a hostname. If you want to accept that format as
well, you'll need to detect numeric addresses and handle them
appropriately.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 29 Mar 1999 01:40:27 GMT
From: solder182@aol.com (Solder182)
Subject: A script
Message-Id: <19990328204027.23487.00002262@ng-ch1.aol.com>
I am looking for a script that, when I as an admin give a database some URL's
visitors from my web site can search through (spidering) contents on those
sites. I have looked everywhere for a script that does this and I know there
out there but i don't know what to look for it as. Wether it is classified as a
Link indexer, search engine, etc. Please let me know where I can find this
script (Preferably free)Thanks
Digital Explorer
ICQ-5989580
AIM-DigitalEx1
http://members.tripod.com/nzhero/
"Knowldege Is Power"
------------------------------
Date: Sun, 28 Mar 1999 19:24:20 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Adding an $ENV variable?
Message-Id: <comdog-ya02408000R2803991924200001@news.panix.com>
In article <OdUdTsWe#GA.316@nih2naaa.prod2.compuserve.com>, "Mike Watkins" <mwatkins@promotion4free.com> posted:
> I was just wondering, is there anyway to add a variable into the hash %ENV?
> What I want to do is what the .htaccess Authentication does, when it adds a
> $ENV{'REMOTE_USER'} variable to each person who logs in.
add keys just like you do any other hash
> I need the variable to "stick" though, after the script has finished running
> its process.
you're going to have to play with files to save state. once the process
is gone so is all of it's changes to the environment.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 28 Mar 1999 23:03:46 GMT
From: freehtmlhelp@softhome.net
Subject: Anyone please help with a script?
Message-Id: <7dmcge$q95$1@nnrp1.dejanews.com>
Hi, I am self-teaching myself Perl. I am working on an overly simple
Bulletin Board script, it works fine. I am also writing an admin script to
go with that, thats not working. When you write a new post to the script it
writes to the data file:
5 #number of posts
#post number:post url:post subject:poster:posters email
5:url_to_5.html:This is post 5:Bob:some@where.com
4:url_to_4.html:This is post 4:Bob:some@where.com
3:url_to_3.html:..............
2:......
1:......
My admin script is set up (abbreviated) like so.
open (OPEN_FILE, "$data");
@remove = <OPEN_FILE>;
close (OPEN_FILE);
open (EDIT, ">$data"); print EDIT "$remove[0]\n"; foreach $line (@remove){
chop $line; @data = split (/:/,$line); if ($data[0] ==
$FORM{'number'}) { #do nothing, meaning don't print out $line 'cause $data[0]
equals the user input } else { print FILE
"$line\n"; } }
So say if I type in 4 to my form and hit submit, it does nothing, no lines
deleted, nothing. Could someone help me figure out why? You can find text
versions of the scripts at
http://freehtmlhelp.hypermart.net/test/bb/bboard.txt and
http://freehtmlhelp.hypermart.net/test/bb/admin.txt.
Could you please respond VIA email (freehtmlhelp@softhome.net). Thanks for
any and all help.
Beau C
freehtmlhelp@softhome.net
close (EDIT);
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sun, 28 Mar 1999 15:04:16 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Calcultor CGI
Message-Id: <36FEB570.DD5A61C0@mail.cor.epa.gov>
Jason wrote:
>
> Does anyone have a CGI example of a simple Calculator that will use the
> input from a web page and run the variables there an equation and post the
> answer. If so can you post it here or e-mail me. I want to use it as an
> example so I can put some other calculator scripts together. One other
> question does it mater what version of perl my service provider is using?
I think that a good starting point might be the PerlScript RPN calculator
example that ActiveState distributes with its builds of Perl. It's in the
html docs under 'PerlScript Examples', oddly enough. :-)
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Sun, 28 Mar 1999 19:42:18 -0500
From: James Tolley <jamesht@idt.net>
To: "Mark P." <mag@imchat.com>
Subject: Re: dividing with perl
Message-Id: <36FECC6A.8122BF26@idt.net>
perl -e "print 5/2"
Works for me...
James
------------------------------
Date: Sun, 28 Mar 1999 19:18:00 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Easy ?... why doesn't this script run on NT?
Message-Id: <1dpe2m9.tvf4yr1in3htiN@p125.tc3.state.ma.tiac.com>
[posted and mailed]
Larry Rosler <lr@hpl.hp.com> wrote:
> In article <oQ3L2.13574$DM5.3797@news.rdc1.ct.home.com> on Sat, 27 Mar
> 1999 12:05:40 GMT, Allan M. Due <All@n.due.net >says...
> ...
> > perl -e 'print qq(hello, world!);' #*NIX
> > perl -e "print qq(hello, world!);" #DOS
> >
> > All I need to change is the type of quote at the beginning and end. Just
> > makes it easier for me when I switch back and forth. Of course we don't
> > need double quotes here anyway, but just for future reference.
>
> Why don't you try the second command on Unix as well? You may be
> pleasantly surprised!
Because with code any more complicated than that, you will be
unpleasantly surprised.
csh:
% perl -e "$a = 'foo'; print qq{$a\n}"
a - Undefined variable
%
sh:
$ perl -e "$a = 'foo'; print qq{$a\n}"
syntax error at -e line 1, near "="
Execution of -e aborted due to compilation errors.
$
Unix shells interpolate variables in double-quoted strings just like
Perl does. You need to use single-quotes to hide the variable names
from the shell.
--
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
perl -e'for(sort keys%main::){print if $$_ eq 1}
' -s -- -' Just' -' another ' -'Perl ' -'hacker
' http://www.tiac.net/users/chipmunk/ [rjk@linguist.dartmouth.edu]
------------------------------
Date: Sun, 28 Mar 1999 19:18:01 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: File isn't locked, but Perl says it is?
Message-Id: <1dpe2wt.ezwnsrkq04ajN@p125.tc3.state.ma.tiac.com>
<sstarre@my-dejanews.com> wrote:
> User 1 locks the file, copies it to a temp file minus his record, then copies
> it back..
>
> User 2 gets a message that says "you cant lock this file".
>
> Instead, some concurrent update takes place that clobbers the file. The lockF
> and lockT procedures should have errored if a lock wasn't possible, so
> apparently Perl is allowing 2 users to "exclusively" lock this file.
> if ($_[0])
> {$r=flock(F, LOCK_SH) ||
> pmessage::SayError("file", "lock- could not shlock F, try again");}
> else
> {$r=flock(F, LOCK_EX) ||
> pmessage::SayError("file", "lock- could not exlock F, try again");
> }
Does pmessage::SayError() exit the program after outputting the error
message?
If not, the script will continue even though the locking failed. File
locking in Perl is advisory rather than mandatory.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 28 Mar 1999 19:18:04 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: file sunroutines
Message-Id: <1dpe2zx.1uh8do71xyghh9N@p125.tc3.state.ma.tiac.com>
Aaron Walker <amwalker@gate.net> wrote:
> are there subroutines in perl that do chmod, copy and move?
chmod() and rename() for chmod and move. For copy, you can use the
File::Copy module.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
perl -e 'for(@ARGV){require $_;print "$_\n $INC{$_}\n"}' File/Copy.pm
------------------------------
Date: Sun, 28 Mar 1999 19:59:01 -0500
From: James Tolley <jamesht@idt.net>
To: pfridlen@rec.unicen.edu.ar
Subject: Re: IIS4 and Perl
Message-Id: <36FED055.92B7ABE1@idt.net>
This configuration is pretty straightforward, I think, except for one thing:
You've got to type this in as the executable to use for your CGI extension:
C:\perl5\bin\perl.exe %s %s
One space only between tokens - or so I've heard that it's important. And dont
forget to reboot the machine - or at least restart that service, I can't remember
which...
Let me know if this doesn't solve the problem, and we'll see what else there
might be...
James
------------------------------
Date: Sun, 28 Mar 1999 19:27:28 -0500
From: Sender <fairfiel@dundee.net>
Subject: Re: Initializing an array with STDIN (newbie)
Message-Id: <36FEC8F0.5EEF9A38@dundee.net>
Bob Trieger wrote:
>
> Sender <fairfiel@dundee.net> wrote:
> >Hello
> >
> > If the answer to my question is anywhere in the llama book, just say
> >where!
> >
> > I've been trying to place an input file into an array, and then split()
> >that array. I get messages indicating that the array is not initialized:
> >"Use of implicit split to @_ is deprecated," and "Use of uninitialized
> >value at line xxx, <INFILE> chunk xxx."
> >
> >
> >I've tried a few approaches:
> >
> >1. Use a loop to read each line from the text file into the array. Use
> >the split() function after each line is read in, or after the whole
> >array has been (supposedly) filled.
> >
> >2. Put the data file directly into the array:
> > @order = <INFILE>; (With variations in syntax).
>
> You posted 1 line of code and it is valid.
>
> Try posting the 5lines before and the 5 lines after this line or the all of
> your code if it is not too long (less than 20 lines).
>
> Bob Trieger
> sowmaster@juicepigs.com
-----------------------------------------------
OK.....here's two ways I tried:
#!/usr/bin/perl -w
open (INFILE, "/home/bb/docs/list/book");
@order = INFILE;
split(/^$/, INFILE);
print "\n", $order[442];
close (INFILE);
I also tried this:
while (INFILE){
$line = <INFILE>;
chomp $line;
@order = $line;
}
split(/^$/,$line);
print "\n", $order[500];
close(INFILE);
Thanks again for the help.
------------------------------
Date: 28 Mar 1999 23:00:08 GMT
From: Lars Plessmann <larsplessmann@gmx.de>
Subject: Re: internal server error
Message-Id: <36FEB54D.14F06722@gmx.de>
thx for all your answers.
I know what I did wrong!
When I write textes in windows, the ENTER hast code 013
this char is not accepted in perl! It needs to be 010
So I changed the pl - files in Linux. It's working works :-)
Now, I just have to change the attributes to 755.
So, if anyone has the same problem, write these files in linux, that's it!
Tony Kenny schrieb:
> Couldn't it be something as simple as an error in the script causing the
> 'internal server error' (assuming 500 error)
> ...
>
> Tony
------------------------------
Date: 29 Mar 1999 00:34:28 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: internal server error
Message-Id: <7dmhqk$ckp$1@client2.news.psi.net>
Lars Plessmann (larsplessmann@gmx.de) wrote on MMXXXIV September MCMXCIII
in <URL:news:36FD43F8.D6E954A9@gmx.de>:
// I create my perl scripts in windows. The are running without any problem
// on my Sambar Server 4.1
// When I trie to execute them on Linux, there is an error message
// "internal server error". What's wrong with my perl script?
There's a bug on line 17.
Abigail
--
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
for (s;s;s;s;s;s;s;s;s;s;s;s)
{s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'
------------------------------
Date: 29 Mar 1999 00:37:58 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Need automatic forwarding perl script
Message-Id: <7dmi16$ckp$2@client2.news.psi.net>
Beny Spensieri (bernardino.spensieri@utoronto.ca) wrote on MMXXXIV
September MCMXCIII in <URL:news:36FD1EE7.D2C0F627@utoronto.ca>:
## I need a script that will forward a user to another page after a
## few seconds. This is commonly used to send web serfers to the
## new location of a web page that has moved.
That answer can be found in the HTTP RFCs. It's not a Perl question,
unless you don't know how to use "print". But that's found in the
manual.
Abigail
--
perl -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
print chr 0x$& and q
qq}*excess********}'
------------------------------
Date: 29 Mar 1999 00:41:45 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Need automatic forwarding perl script
Message-Id: <7dmi89$ckp$3@client2.news.psi.net>
Karen J. Cravens (silver+web@wirebird.com) wrote on MMXXXIV September
MCMXCIII in <URL:news:8D96A9754phoenyx@news.southwind.net>:
,, "Beny Spensieri" bernardino.spensieri@utoronto.ca wrote in
,, <36FD1EE7.D2C0F627@utoronto.ca>:
,,
,, > I need a script that will forward a user to another page after a
,, > few seconds. This is commonly used to send web serfers to the
,, > new location of a web page that has moved.
,,
,, Scripts aren't needed for that; simply put
,,
,, <META HTTP-EQUIV="refresh" CONTENT="5; URL=http://newurl">
,,
,, in the HTML, somewhere between <HEAD> and </HEAD>. (Replace the 5 with
,, the number of seconds you want to delay.)
,,
,, Doesn't work with all browsers, hence the usual "If your browser doesn't
,, automatically take you, click here" link also found on such pages.
This has nothing to do with Perl. Besides, it's a hack (not part of
the HTML standard) and a hack that only works with certain browsers,
and certain document types. Furthermore, it's slow, because the browser
has to parse the page. On top of that, your browsers/proxies have to do
the same exercise over and over again, each time when going to said URL.
It's better not to use hacks invented by incompetent browers vendors
(like Netscape). Instead, use the HTTP standard.
Followups set.
Abigail
--
perl -we '$_ = q ?4a75737420616e6f74686572205065726c204861636b65720as?;??;
for (??;(??)x??;??)
{??;s;(..)s?;qq ?print chr 0x$1 and \161 ss?;excess;??}'
------------------------------
Date: 29 Mar 1999 00:43:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Need automatic forwarding perl script
Message-Id: <7dmiaq$ckp$4@client2.news.psi.net>
J. Parsons (gsx97@usa.net) wrote on MMXXXV September MCMXCIII in
<URL:news:7djs3n$kdu@news1.snet.net>:
\\
\\ To answer your question, you don't need a script to do what you're asking.
\\ Put this in your page:
\\
\\ <meta http-equiv="REFRESH" content="1; url=http://www.new-site.com">
This is bad. Very bad. A sign of an incompetent author.
See my other posting on this subject.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Sun, 28 Mar 1999 19:18:06 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: perl port for 16-bit MSDOS?
Message-Id: <1dpe3yx.14qdhh310cd3z7N@p125.tc3.state.ma.tiac.com>
Hans Olav Husum <nbhoh1@moa.norges-bank.no> wrote:
> Please don't laugh: I would like to get hold of a binary dostribution of a
> perl port that runs under MSDOS 3.3 on an 8086. Going back to version 3 or 4
> is OK (and probably necessary).
>
> Can anyone point me in the right direction?
Have you looked at http://www.perl.com/CPAN-local/ports/ ?
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
perl -le 'print "Just another \u$^X hacker"'
------------------------------
Date: Sun, 28 Mar 1999 19:18:07 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Problem importing multiple values using "strict"
Message-Id: <1dpe45m.1wv8ytwllg5hpN@p125.tc3.state.ma.tiac.com>
<melLA@west.net> wrote:
> Setup: Init file contains combination of 42 non-changing strings and
> arrays that I'm trying to import into $main using a require statement
> that points to the init file (and most of those constants will be used
> in subroutines of $main, so I see additional scoping problems ahead).
Try importing the initialization file at compile-time instead of
run-time:
BEGIN {
require "whatever";
}
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 28 Mar 1999 19:18:09 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Q on procmail piped to perl
Message-Id: <1dpe4c7.1ggst6rppy3c2N@p125.tc3.state.ma.tiac.com>
tavi <tavi367@ibm.net> wrote:
> * ^TO()perl@tscinternet\.com
> | $HOME/vmail/perl/test.pl
Try specifying the perl executable explicitly:
:0
* ^TO()perl@tscinternet\.com
| perl $HOME/vmail/perl/test.pl
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 28 Mar 1999 19:18:10 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Q: redefined subroutines
Message-Id: <1dpe4gy.1wa3hthi0g2fnN@p125.tc3.state.ma.tiac.com>
Peter John Acklam <jacklam@math.uio.no> wrote:
> Thanks for the reply, but the code I gave was actually all there was.
> And I get the same even when I use just an EMPTY one-liner:
>
> c:\> perl -MFile::Spec -MDirhandle -we ""
> Subroutine new redefined at E:\PERL\lib/Dirhandle.pm line 32.
> Subroutine DESTROY redefined at E:\PERL\lib/Dirhandle.pm line 43.
> (...)
Looks like File::Spec and DirHandle are defining sub new and sub DESTROY
in the same package. A bug in one or both modules?
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
perl -e 'for(@ARGV){require $_;print "$_\n $INC{$_}\n"}' File/Spec.pm
------------------------------
Date: 29 Mar 1999 00:47:26 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Require Question
Message-Id: <7dmiiu$ckp$5@client2.news.psi.net>
Mike Watkins (mwatkins@promotion4free.com) wrote on MMXXXV September
MCMXCIII in <URL:news:uizZqdMe#GA.51@nih2naaa.prod2.compuserve.com>:
** Hi there,
**
** Why is it, on some UNIX web servers out there, the 'require' function won't
** work in perl. Instead, it just gives off a 500 Internal Server Error?
That's a error from the server. Configure your server to log any errors
it gets. Go to the appropriate server group to find out how. This group
is not the place.
Abigail
--
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
-> define ("foldoc", "perl")) [0] -> print'
------------------------------
Date: Sun, 28 Mar 1999 19:19:15 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Split with + , but no %2B
Message-Id: <comdog-ya02408000R2803991919150001@news.panix.com>
In article <36FE2B2C.EE4DE6E5@xs4all.nl>, Frank de Bot <debot@xs4all.nl> posted:
> Ok, here it is:
> This is the Query string: q=Free+%2BPerl+Scripts
i don't think that is the string that you are splitting.
> @array = split (/\+/, $in{'q'});
>
> The arrays are:
> $array[0] = Free
> $array[1] = (empty)
> $array[2] = Perl
> $array[3] = Scripts
that is what you would get is the string were 'Free++Perl+Scripts'
> But I want it to be this way:
>
> $array[0] = Free
> $array[1] = +Perl
> $array[2] = Scripts
you would need to de-url-encode after splitting to get that.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 28 Mar 1999 19:20:47 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Split with + , but no %2B
Message-Id: <comdog-ya02408000R2803991920470001@news.panix.com>
In article <83bthdjsyz.fsf@vcpc.univie.ac.at>, Tony Curtis <Tony.Curtis@vcpc.univie.ac.at> posted:
> Re: Split with + , but no %2B, Frank
> <debot@xs4all.nl> said:
>
> Frank> I know what i've done wrong. You must split a
> Frank> query string with a space not with a + . Now
>
> You cannot have spaces in a QUERY_STRING. That is
> precisely why "strange" characters are %-encoded and
> so this approach is doomed to failure.
he's talking about the un-url-encoded query string. the +
turns into a space, and the %2B turns into a +, so splitting
on a space would do the trick.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 28 Mar 1999 19:37:27 -0500
From: James Tolley <jamesht@idt.net>
Subject: verbose 'make test' to explain t/ftp 'Error 29'?
Message-Id: <36FECB47.C05F9B1E@idt.net>
Hello,
I'm trying to install Net::FTP on a Linux machine, but 'make test'
always fails while testing t/ftp.
All of the other tests return 'ok'. I get an 'Error 29' message as an
explanation for why the test
failed, but that's it. I see that when I run 'make test',
Test::Harness's $verbose is set to '0'.
Can I set $verbose = 1? Will this even help me diagnose the problem?
Does anyone
know what 'Error 29' means? Is there an FAQ of module installation flags
where I can look it
up myself?
ANY help would be greatly appreciated.
Thanks in advance,
James
------------------------------
Date: 29 Mar 1999 00:07:18 GMT
From: hdiwan@diwanh.stu.rpi.edu (the jackal)
Subject: Re: Why do we like Perl?
Message-Id: <slrn7fth24.lnj.hdiwan@diwanh.stu.rpi.edu>
INTJ here
--
Hasan Diwan
------------------------------
Date: Sun, 28 Mar 1999 20:25:33 -0500
From: "William Flanagan" <wflanagan@msn.com>
Subject: Re: Writing isn't working, and the mode is set, Help!
Message-Id: <922670753.903.60@news.remarQ.com>
Thanks! I got the problem fixed with writing, I was writing to OUTFILE when
I had defined the handle as OUTPUT.
Wf
Ala Qumsieh <aqumsieh@matrox.com> wrote in message
news:x3yk8w2vcjk.fsf@tigre.matrox.com...
>
> "William Flanagan" <wflanagan@msn.com> writes:
>
> > #!c:\progra~1\perl\bin\perl
>
> You definitely need a '-w' up there, especially that you are having
> problems writing the code. It will trigger a lot of warnings I'm sure.
>
> > # This is my first attempt at writing a program that will convert my
Notes
> > database to a comma delimited
> > # file. This takes any structured text file and converts it to comma
> > delimited.
> > # Function: Reverse each line of a file
> >
> > #-------
> > # Step Number 1: Get command line values:
> > #-------
> >
> > if ($#ARGV !=1) {
> > die "Structured Text to Comma Delimiter, 1999 William Flanagan\n
Usage:
> > $0 inputfile outputfile\n";
> > }
> > ($infile,$outfile) = @ARGV;
> > if (! -r $infile) {
> > die "Can't read input $infile\n";
> > }
> > if (! -f $infile) {
>
> I would use a '_' (underscore) instead of $infile here. It's a shred
> faster (nothing significant though in your case).
>
> > die "Input $infile is not a plain text, please use a structured
plain
> > text file\n";
> > }
> >
> > #-------
> > # Step Number 2: Validate files
> > #-------
> >
> > $mode='+<';
> > open(INPUT,"+<$infile") ||
>
> This allows you to read from and write to the file.
>
> > die "Can't open $infile successfully, ensure $infile is plain text
$!";
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> This can't be the problem since you check for that already.
>
> > if ( -e $outfile) {
> > print STDERR "Output file $outfile exists!\n";
> > until ($ans eq 'r' || $ans eq 'a' || $ans eq 'e' ) {
>
> '-w' will warn you here about the use of the uninitialized variable
> $ans.
>
> > print STDERR "replace, append, or exit? ";
> > $ans = getc(STDIN);
>
> Any good reason for using getc() here instead of the usual
> chomp($ans = <STDIN>);
>
> ??
>
> > }
> > if ($ans eq 'e') {exit}
> > }
> > if ($ans eq 'a') {$mode='>>'}
> >
> > else {$mode='>'}
> >
> > open(OUTPUT,"$mode$outfile") ||
> > die "Can't create $outfile file, ensure that it does not exist $!";
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Again, this is a useless piece of advice. You shouldn't care if the
> output file exists or not. It will be created if it doesn't exist.
>
> >
> >
> > $ccount = 0;
> >
> > #------
> > # Step Number 3: Read input, preprocess, and add to first line arguments
for
> > output
> > #------
> >
> > while ($line = <INPUT>) {
>
> If you are using an older Perl (pre 5.005), you should test this with
> defined():
>
> while (defined($line = <INPUT>)) {
>
> > ($fieldname, $fieldvalue) = split(":", $line);
> > if ($fieldname eq '') {
> > next;}
>
> Is the above meant to skip empty lines? If it does, then the usual:
>
> next if $line =~ /^\s*$/;
>
> is a better choice.
>
> > chomp($fieldvalue);
> > chomp($fieldname);
>
> This is not necessary since $fieldname should NEVER have a $/ at its
> end (unless ":" never appears in the line). I would say, just
> chomp $line;
>
> before you split it.
>
> > $foundfield='n';
> > for ( $a=0; $a <= $ccount; $a++) {
> > if ($columnlist[$a][1] eq $fieldname) {
> > $foundfield='Y';
> > last; }
> > }
> > if ($foundfield eq 'n') {
> > $columnlist[$ccount] = ["$ccount", "$fieldname"];
>
> I really think it's useless to store $ccount in the anonymous hash,
> since it's always the same as the array index. But hey, it's your
> program.
>
> > print STDOUT "Adding $fieldname to record list.\n";
>
> Does the above line show up as expected?
> Also, what about $fieldvalue? You never use it. Are you sure you want to
> discard it like that?
>
> > $ccount++;
> > }
> > }
> >
> > print STDOUT "\n\nTotal ccount is $ccount.\n";
>
> Obviously, you are worried about multiple entries in your file. You
> don't want them. You want only one copy. So, just use a hash. Instead
> of the big mess you have, simple do something like:
>
> while (<INPUT) {
> next if /^\s$/;
> chomp;
> ($fieldname, $fieldvalue) = split /:/;
> $columnlist{$fieldname} = $fieldvalue;
> }
>
> > #------
> > # Step Number 4: Gather outputfile information
> > #------
> >
> > close INPUT;
>
> Check the return value of your close() the way you do for open().
>
> > open(INPUT,"<$infile") ||
> > die "Can't open $infile successfully, ensure $infile was not deleted
or
> > moved $!";
>
> Hmmm... you close INPUT and re-open it. Did you do this to simply
> start over from the beginning of the file?
> If so, a simpler (and faster) approach would be:
>
> seek INPUT, 0, 0;
>
> But, the above might be a typo. I think you need $outfile instead of
$infile.
>
> > $j=0;
> > while ($line = <INPUT>) {
>
> again .. test with defined()
>
> > ($fieldname, $fieldvalue) = split(":", $line);
> > chomp($fieldvalue);
> > chomp($fieldname);
>
> same as above.
>
> > $foundfield='n';
> > if ($fieldname eq '') {
> > $eorcount++;
> > print STDOUT "\nEnd of Record count number $eorcount.\n\n";
> > if ($eorcount eq 3) {
> > for ($k=0;$k<=$#recorddata;$k++) {
> > select OUTFILE;
>
> what is OUTFILE? It is not an open filehandle. Did you check your
> program yourself? Did you write it? Is this the complete thing?
>
> > print "$recorddata[$k]", ", ";
> > select STDOUT;
> > print "$recorddata[$k]", ", ";
> > }
> >
> > select OUTFILE;
> > print "\n";
> > select STDOUT;
> > print STDOUT "\n";
> > @recorddata = ();
> > $eorcount = 0;
> > next;
> > }
> > }
> > for ( $a=0; $a <= $ccount-1; $a++) {
> > print STDOUT "Comparing $fieldname to $columnlist[$a][1].\n";
> > if ($columnlist[$a][1] eq $fieldname) {
> > @recorddata[$a] = $fieldvalue;
>
> The above will generate a warning under '-w'.
>
> > print STDOUT "Found $fieldname in record, adding
@recorddata[$a]
> > to record.\n";
> > $foundfield='Y';
> > $eorcount = 0;
> > last;
> > }
> > }
> > if ($foundfield eq 'n') {
> > $eorcount++;
> > }
> > print STDOUT "Moving onto record $j\n\n";
> > $j++;
> > }
> >
> >
> > #-------
> > # 4: Done!
> > #-------
> >
> > close INPUT,OUTPUT;
> > exit;
>
> There are way too many errors in your program. You seem to be
> confused and your strategy is weird (for me at least :).
> Maybe you should try with something a bit simpler
> first, like reading from a file, reformatting, and writing to another
> file. No need to check for any duplication of data at the moment. Once
> you figured out how to do that, you can add various types of sanity
> checks into your program.
>
> Try again, and let us know.
>
> HTH,
> Ala
>
------------------------------
Date: Sun, 28 Mar 1999 20:37:13 -0500
From: "William Flanagan" <wflanagan@msn.com>
Subject: Re: Writing isn't working, and the mode is set, Help!
Message-Id: <922671455.113.57@news.remarQ.com>
All-
This helped tremendously. The printing problem was related to the incorrect
naming of a file handle. (OUTFILE, OUTPUT).
The point of the program was to do something that I needed to have done in
Perl, so that I could learn the language. My programming language of choice
would have taken me about 10 minutes, but I wouldn't have learned so much!
The program is to convert a Lotus Notes structured text file into a comma
delimited file, not knowing the fieldnames and fully expecting that the
fieldnames will increase over time. So, that's why all the jumping about.
I learned a lot from this, and here's the program as it stands now. Now,
it's completing and printing, but I'm looking for optimization.
Thanks,
WF
#!c:\progra~1\perl\bin\perl
# This is my first attempt at writing a program that will convert my Notes
database to a comma delimited
# file. This takes any structured text file and converts it to comma
delimited.
# Function: Reverse each line of a file
#-------
# Step Number 1: Get command line values:
#-------
if ($#ARGV !=1) {
die "Structured Text to Comma Delimiter, 1999 William Flanagan\n Usage:
$0 inputfile outputfile\n";
}
($infile,$outfile) = @ARGV;
if (! -r $infile) {
die "Can't read input $infile\n";
}
if (! -f $infile) {
die "Input $infile is not a plain text, please use a structured plain
text file\n";
}
#-------
# Step Number 2: Validate files
#-------
$mode='>';
open(INPUT,"+<$infile") ||
die "Can't open $infile successfully, ensure $infile is plain text $!";
if ( -e $outfile) {
print STDERR "Output file $outfile exists!\n";
until ($ans eq 'r' || $ans eq 'a' || $ans eq 'e' ) {
print STDERR "replace, append, or exit? ";
$ans = getc(STDIN);
}
if ($ans eq 'e') {exit}
}
if ($ans eq 'a') {$mode='>>'}
else {$mode='>'}
open(OUTPUT,">$outfile") ||
die "Can't create $outfile file, ensure that it does not exist $!";
$ccount = 0;
#------
# Step Number 3: Read input, preprocess, and add to first line arguments for
output
#------
print STDOUT "\nStructured text to comma separated file converter.\n";
print STDOUT "Copyright 1999 William Flanagan, All rights reserved.\n";
print STDOUT "\nPreprocessing $infile...\n";
while ($line = <INPUT>) {
($fieldname, $fieldvalue) = split(":", $line);
if ($fieldname eq '') {
next;}
$foundfield='n';
for ( $a=0; $a <= $ccount; $a++) {
if ($columnlist[$a][1] eq $fieldname) {
$foundfield='Y';
last; }
}
if ($foundfield eq 'n') {
$columnlist[$ccount] = ["$ccount", "$fieldname"];
$ccount++;
}
}
#------
# Step Number 4a: Write first line of file.
#------
print STDOUT "Writing first line of comma delimited file...\n";
for ($m=0;$m<=$ccount;$m++) {
print OUTPUT "$columnlist[$m][1]", ",";
}
print OUTPUT "\n";
#------
# Step Number 4: Gather outputfile information
#------
print STDOUT "Starting writing of file... the longest part, please wait.\n";
seek(INPUT,0,0);
$j=0;
$r=0;
while ($line = <INPUT>) {
chomp($line);
($fieldname, $fieldvalue) = split(":", $line);
$fieldvalue=~s/^\s+//;
$fieldvalue=~s/,/./;
$foundfield='n';
if ($fieldname eq '') {
$eorcount++;
if ($eorcount eq 3) {
for ($k=0;$k<=$#recorddata;$k++) {
print OUTPUT "$recorddata[$k]", ",";
}
print OUTPUT "\n";
@recorddata = ();
$eorcount = 0;
$r++;
next;
}
}
for ( $a=0; $a <= $ccount-1; $a++) {
if ($columnlist[$a][1] eq $fieldname) {
@recorddata[$a] = $fieldvalue;
$foundfield='Y';
$eorcount = 0;
last;
}
}
if ($foundfield eq 'n') {
$eorcount++;
}
$j++;
}
#-------
# 4: Done!
#-------
print STDOUT "\nCompleted. Results are in $outfile.\n";
close INPUT,OUTPUT;
exit;
Ala Qumsieh <aqumsieh@matrox.com> wrote in message
news:x3yk8w2vcjk.fsf@tigre.matrox.com...
>
> "William Flanagan" <wflanagan@msn.com> writes:
>
> > #!c:\progra~1\perl\bin\perl
>
> You definitely need a '-w' up there, especially that you are having
> problems writing the code. It will trigger a lot of warnings I'm sure.
>
>
> I would use a '_' (underscore) instead of $infile here. It's a shred
> faster (nothing significant though in your case).
>
{{{{SNIPPING}}}}}
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5246
**************************************