[11453] in Perl-Users-Digest
Perl-Users Digest, Issue: 5053 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 4 13:07:32 1999
Date: Thu, 4 Mar 99 10:01:36 -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 Thu, 4 Mar 1999 Volume: 8 Number: 5053
Today's topics:
Re: Pentium III Chips Released with IDs - Intel won't b <brazee@NOSPAMhome.com>
Re: Pentium III Chips Released with IDs - Intel won't b ()
Re: PERL and mySQL <fty@utk.edu>
Re: PERL and mySQL (Steve Linberg)
Re: Perl comment (George Crissman)
Re: PERL ODBC on LINUX (Dan Wilga)
Perl script for cisco logging <godzila@freemail.nl>
Perl-Browser for controlling scrips? <GWoeste@yahoo.com>
Re: Please, An example of win32::NetResourse. mirak63@my-dejanews.com
printing value of -M "$file" <23_skidoo@geocities.com>
printing value of -M "$file" <23_skidoo@geocities.com>
procmail-ish mail handler in perl? <revjack@radix.net>
Re: q// vs. '' <MBalenger@worldnet.att.net>
Re: Securing files in a password protected area (Dimitri Ostapenko)
Re: split on meta question (Larry Rosler)
Re: split on meta question (M.J.T. Guy)
Re: SSI and Perl script with CGI.pm(Pondering?Hmmm...) dragnovich@my-dejanews.com
Re: swallowing old lady (was Re: URGENT! Where Do You H (Steve Linberg)
Re: The millennium cometh -- eventually evanjohn@my-dejanews.com
THOSE REVISED FAQ-ITEMS FROM TOM C. (David Combs)
Re: Tied hashes and locking (I.J. Garlick)
Undef subr &Treader::get called ??? <brandeda@se.bel.alcatel.be>
Re: URGENT! Where Do You Hide The CGI Cards From The Sp (Larry Rosler)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 04 Mar 1999 07:37:33 -0700
From: Howard Brazee <brazee@NOSPAMhome.com>
Subject: Re: Pentium III Chips Released with IDs - Intel won't budge
Message-Id: <36DE9AAD.47C376CD@NOSPAMhome.com>
Doug Hughes wrote:
>
> On 3 Mar 1999, Jochem Huhmann wrote:
>
> >
> > Who cares about software that requires licences? And how is this
> > related to comp.lang.tcl?
> >
> > BTW: Every ethernet card on this planet has an unique ID. Since
> > ages. That's very useful and nobody has crossposted in this regard
> > over 10 newsgroup all the time.
> >
>
> Not true. Just ask 3com about their fiasco. They had meant to send
> cards with the same MAC to different countries. Turns out that some
> got packages incorrectly and they wen to the same companies in
> some cases!
>
> (moreover, changing the ethernet hardware address is 'required' for
> protocols such as Decnet, and is relatively easy to do)
And Intel's original specs made it easy to turn off the ID. Their
revised one defaults to off. At the level of your "relatively easy",
other means of privacy are easy too. The general population though just
accepts defaults. Anybody who accesses the internet via a NIC (cable
modem users for instance) is sharing his address.
Intel's original design was like the phone company defaulting to put
your phone number in the phone book. It was easy to become unlisted,
but you have to ask for it. After people complained that now vendors
can find out the serial number of your CPU, they changed it so it
defaults to being unlisted.
This serial number says NOTHING of interest to anybody except Intel.
People use different computers to access the internet. Software gets
migrated from one computer to another (kind of difficult with the design
of Windows and internet based upgrades), and CPU's get upgraded in
computers.
------------------------------
Date: 4 Mar 1999 15:01:28 GMT
From: docdwarf@clark.net ()
Subject: Re: Pentium III Chips Released with IDs - Intel won't budge
Message-Id: <7bm788$krd$1@clarknet.clark.net>
In article <36DDC275.12C5C663@aziraphale.demon.co.uk>,
Martin Harvey <martin@aziraphale.demon.co.uk> wrote:
>Bob Butler wrote:
>>
>> The argument that "if you have nothing to hide then you should not object to
>> being searched" has been used many times to take away the basic right to
>> privacy. Sometimes the principle is more important than the specific
>> instance.
>
>I don't know of anyone that has *nothing* to hide. Phrases involving
>people without sin and casting stones come to mind :-)
The tyrant cries 'What have you got to hide?!?'
The freedom-lover replies 'I've not seen sufficient reason to tell you
anything.'
DD
------------------------------
Date: Thu, 04 Mar 1999 07:58:36 -0500
From: Jay Flaherty <fty@utk.edu>
Subject: Re: PERL and mySQL
Message-Id: <36DE837C.54842FC6@utk.edu>
Stewart Eastham wrote:
>
> I am trying to get a list of field names from a mySQL DB using PERL.
>
> The code I am using now is:
>
> $query = "select * from users where ='admin'";
> $sth = $dbh->query($query) || &htmlDie("$Mysql::db_errstr and
> query is $query\n");
>
> #GET LIST OF FIELD NAMES
> @list => $sth->name;
>
first, use the DBI and DBD modules. The Mysql module is no longer
supported. Second, you SQL is wrong. the where clause needs a field and
a string. Heres an example:
#!/usr/local/bin/perl -w
use strict;
use DBI;
my $dbh = DBI->connect("DBI:mysql:userDB", "user", "password") or
die "unable to connect to the userDB database: $DBI::errstr\n";
my $query = qq(select * from users where user='admin');
my $sth = $dbh->prepare($query);
$sth->execute or die "unable to execute $query: $dbh->errstr\n";
my $name = $sth->{NAME};
print "@$name\n";
$sth->finish;
$dbh->disconnect;
exit;
__END__
Good luck...jay
------------------------------
Date: Thu, 04 Mar 1999 10:25:02 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: PERL and mySQL
Message-Id: <linberg-0403991025020001@ltl1.literacy.upenn.edu>
In article <36DE837C.54842FC6@utk.edu>, Jay Flaherty <fty@utk.edu> wrote:
A couple of questions about this, just because the way I do it with
DBI/MySQL differs from yours a little:
> #!/usr/local/bin/perl -w
> use strict;
> use DBI;
> my $dbh = DBI->connect("DBI:mysql:userDB", "user", "password") or
> die "unable to connect to the userDB database: $DBI::errstr\n";
> my $query = qq(select * from users where user='admin');
> my $sth = $dbh->prepare($query);
$dbh->prepare can fail too, so you should check for errors here as well.
> $sth->execute or die "unable to execute $query: $dbh->errstr\n";
What's the difference between $dbh->errstr and $DBI::errstr? I use the
latter everywhere.
> my $name = $sth->{NAME};
Don't you have to fetch data first? As in:
while (my @sql_data = $sth->fetchrow_array) {
print join(", ", @sql_data); # or whatever
}
...and you can use fetchrow_hashref as well, to allow the
$sth->{$fieldname} access, but it is documented to be much slower in
mysql.info.
> print "@$name\n";
Why the @?
> $sth->finish;
> $dbh->disconnect;
Cheers!
--
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>
------------------------------
Date: Thu, 04 Mar 1999 15:29:18 GMT
From: strads@tmisnet.com (George Crissman)
Subject: Re: Perl comment
Message-Id: <36dea0fd.2121879@news2.tmisnet.com>
On Mon, 01 Mar 1999 12:07:06 +0100, Philip Newton wrote:
>KC wrote:
>> dubing wrote:
>> > Is there any easy way to comment out a block of Perl code (like how
>> > /*....*/
>> > is used in C) instead of putting '#' at the beginning of each line
>> > line by line?
>> Nope. The pound sign is it.
>...and the advantage over C comments is that Perl comments can be
>"nested" ... if a line begins with '#' and you add another one, it's
>still a comment, whereas /* /* ... */ */ will usually cause problems :)
...unless you set the "allow nested comments" flag in the compiler ...
-- George Crissman
-- strads@tmisnet.com
------------------------------
Date: Thu, 04 Mar 1999 09:48:31 -0500
From: dwilgaREMOVE@mtholyoke.edu (Dan Wilga)
Subject: Re: PERL ODBC on LINUX
Message-Id: <dwilgaREMOVE-0403990948310001@wilga.mtholyoke.edu>
In article <36DD960B.4635A866@wash.inmet.com>, Steven Parker
<sparker@wash.inmet.com> wrote:
> Does anybody know if there exists a PERL ODBC module for use on Linux?
>
> Any help is much appreciated.
>
> -steve
I use DBI and DBD::ODBC. You can get these from perl.org. You'll also need
a driver for the database you are connecting to.
Dan Wilga dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply **
------------------------------
Date: Thu, 04 Mar 1999 18:16:14 +0100
From: peter <godzila@freemail.nl>
Subject: Perl script for cisco logging
Message-Id: <36DEBFDE.2B60D8B6@freemail.nl>
Did someone got a script or a util's to measure the ISDN call, I have
logging on and have a bunch of log files but how to order it. I know
there are some perl scripts but I can't find them...
Any suggestions.
Thank you in advance,
Peter
------------------------------
Date: Thu, 04 Mar 1999 15:04:47 +0000
From: "G.B. Woeste" <GWoeste@yahoo.com>
Subject: Perl-Browser for controlling scrips?
Message-Id: <36DEA10F.41C67EA6@yahoo.com>
Hi everyone,
the problem:
I want to control via a GUI (build with Perl/Tk) on computer A
perlscripts on computer B and especially their in- and output.
Both computers are connected by TCP/IP, so normal
internet connection.
Controlling perlscripts on computer B means, input for these
perlscrips from the GUI at computer A.
I also want to examine some files on computer B (via perlscripts of
course) and want the results presented in the GUI of computer A.
I know, what I would have to do, if computer A = B, so I ask,
because I have not much knowledge about these network things.
Something like this would help for execution of the scripts, I think:
execute_on_computer_B(UserID, Passwd, perlscript $1 $2 $3)
For puting and getting the data I have only the highly unelegant
solution of
system(ftp onA)
Any suggestions?
Thank you!!
Regards,
Georg Woeste
------------------------------
Date: Thu, 04 Mar 1999 15:43:29 GMT
From: mirak63@my-dejanews.com
Subject: Re: Please, An example of win32::NetResourse.
Message-Id: <7bm9mu$h1g$1@nnrp1.dejanews.com>
That's correct for Windows networking. However, if you need to attach to a
Netware 3.XX system you indeed need to add values to the password / id
fields. I found out that using the Guest ID to attach with didn't work to
well. I can't figure out how to enter no password for a password. When:
if (Win32::NetResource::AddConnection(\%NetResource,$passwd,$id))
If the $id = guest, how do you insert <enter> as the password.
Thanks,
Karim
In article <36e9813a.9448812@news.demon.co.uk>,
gareth@ibis.demon.co.uk (Gareth Jones) wrote:
> "Dave Roth" <xrxoxtxhxdx@xrxoxtxhx.xnxextx> wrote:
>
> >RemoteName.
> >There really is no need to use the other fields. If you wanted to specify a
> >userid
> >and password you would fill out both the Password and User parameters.
> >Typically
> >these parameters are left as empty strings so the connection is made using
> >the current user's id and password.
>
> Dave,
>
> Do you happen to know why AddConnection is implemented like this? If
> you call it with zero length strings for the password / username, it
> translates them to nulls before invoking the api call. This seems to
> me to be unnecessary (without the translation, I could just give nulls
> for the username and password), and it prevents the use of
> AddConnection for creating a null session.
>
> Gareth
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 04 Mar 1999 15:07:45 +0000
From: 23_skidoo <23_skidoo@geocities.com>
Subject: printing value of -M "$file"
Message-Id: <36DEA1B1.16BB@geocities.com>
i'm trying to write a cgi script which looks at a directory full of
files and makes a list splitting files by their modification date. i
have tried the perlfaq but it suggested a more comprehensive way to get
a datestamp. i just wanted something simple more as a learning excercise
at the moment than as a practical consideration.
the split works fine, i can detect which files are older than
$time_limit and which are newer, however i'm now trying to get a
printout of the modification value so i can see how many days have
passed since last modification. here's the relevant part of a larger
script. the file that outputs looks like this:
Kill - 8247 -
Kill - 8248 -
Kill - 8249 -
Keep - 8070 -
Keep - 8071 -
Keep - 8085 -
i was hoping for this given that $time_limit = 5
Kill - 8247 - 6
Kill - 8248 - 6
Kill - 8249 - 7
Keep - 8070 - 1
Keep - 8071 - 2
Keep - 8085 - 3
here's the code
#read filenames into @filenames, exclude . & ..
opendir(MSGDIR,"$messages") || print "CO $messages - " . __LINE__ .
"<BR>\n";
@filenames = grep (!/^\.\.?$/, readdir (MSGDIR));
closedir MSGDIR;
#check modification dates against $time_limit.
#remove extension ".$ext" from file names, add modification date & make
2 arrays
foreach $file (@filenames) {
if (-M "$messages/$file" > $time_limit) {
$file =~ s/\.$ext//;
$moddate = -M "$messages/$file";
push (@oldfiles, "$file - $moddate");
} else {
$file =~ s/\.$ext//;
$moddate = -M "$messages/$file";
push (@notold, "$file - $moddate");
}
}
#print contents of @oldfiles & @notold to data file.
open(TEMP,">$basedir/files.dat") || print "CO $basedir/files.dat - " .
__LINE__ . "<BR>\n";
foreach $killer (@oldfiles) {
print TEMP "Kill - $killer\n";
}
foreach $keeper (@notold) {
print TEMP "Keep - $keeper\n";
}
close(TEMP);
i'm using || print not || die on my file opens because i want to, not
because i don't know any better.
------------------------------
Date: Thu, 04 Mar 1999 15:08:27 +0000
From: 23_skidoo <23_skidoo@geocities.com>
Subject: printing value of -M "$file"
Message-Id: <36DEA1DC.145D@geocities.com>
i'm trying to write a cgi script which looks at a directory full of
files and makes a list splitting files by their modification date. i
have tried the perlfaq but it suggested a more comprehensive way to get
a datestamp. i just wanted something simple more as a learning excercise
at the moment than as a practical consideration.
the split works fine, i can detect which files are older than
$time_limit and which are newer, however i'm now trying to get a
printout of the modification value so i can see how many days have
passed since last modification. here's the relevant part of a larger
script. the file that outputs looks like this:
Kill - 8247 -
Kill - 8248 -
Kill - 8249 -
Keep - 8070 -
Keep - 8071 -
Keep - 8085 -
i was hoping for this given that $time_limit = 5
Kill - 8247 - 6
Kill - 8248 - 6
Kill - 8249 - 7
Keep - 8070 - 1
Keep - 8071 - 2
Keep - 8085 - 3
here's the code
#read filenames into @filenames, exclude . & ..
opendir(MSGDIR,"$messages") || print "CO $messages - " . __LINE__ .
"<BR>\n";
@filenames = grep (!/^\.\.?$/, readdir (MSGDIR));
closedir MSGDIR;
#check modification dates against $time_limit.
#remove extension ".$ext" from file names, add modification date & make
2 arrays
foreach $file (@filenames) {
if (-M "$messages/$file" > $time_limit) {
$file =~ s/\.$ext//;
$moddate = -M "$messages/$file";
push (@oldfiles, "$file - $moddate");
} else {
$file =~ s/\.$ext//;
$moddate = -M "$messages/$file";
push (@notold, "$file - $moddate");
}
}
#print contents of @oldfiles & @notold to data file.
open(TEMP,">$basedir/files.dat") || print "CO $basedir/files.dat - " .
__LINE__ . "<BR>\n";
foreach $killer (@oldfiles) {
print TEMP "Kill - $killer\n";
}
foreach $keeper (@notold) {
print TEMP "Keep - $keeper\n";
}
close(TEMP);
i'm using || print not || die on my file opens because i want to, not
because i don't know any better. can anyone tell me what's going wrong
here?
thanks
-23
------------------------------
Date: 4 Mar 1999 17:29:36 GMT
From: Lindbergh Loomis <revjack@radix.net>
Subject: procmail-ish mail handler in perl?
Message-Id: <7bmfu0$hru$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight
Has anyone here taken the plunge and authored their own e-mail handler
application, in lieu of procmail or 3rd-party spamgards? Any success or
failure stories?
--
/~\ fifteen mainline uprise headstone administrate snug Istvan leat
C oo enforcible ascription Mouton cryptanalyst affiance crane Finn p
_( ^) 1 , 0 0 0 , 0 0 0 m o n k e y s c a n ' t b e w r o n g
/___~\ http://3509641275/~revjack 03/04/99 12:27:02 revjack@radix.net
------------------------------
Date: 4 Mar 1999 16:59:38 GMT
From: "Michael Balenger" <MBalenger@worldnet.att.net>
Subject: Re: q// vs. ''
Message-Id: <7bme5q$nis@bgtnsc01.worldnet.att.net>
My vote for qw() instead of ""
I use qw a lot to prevent me from having to put double quotes around my
words and commas between them. I write a lot of code that keeps lists of
"keywords". The lists need maintenance every once (or thrice) in a while.
The following format makes it easy to type, maintain, understand, and edit.
@days = qw(
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
)
My vote for qq() instead of ""
There are lots of rules for single- and double-quotes for shell scripts.
Combine those with the perl rules, and it's very difficult to figure where
to put the backslashes. Are they for perl or shell. When I build a perl
script that does a system command, I build up the script in as a perl scalar
string, then pass that to system.
$cmd = qq(unix_command -d "argument string protected by double qoutes" -l
arg);
system $cmd == 0
or die "a terrible death"
I really fell in love with perl (like any good relationship, you can fall in
love every day) when I got to pick my own delimiting characters -- the
script I needed to submit had single- and double-quotes and parens and
pipes. I forget, but it was like this:
(Note that I used bang as my delimiter to avoid the other *special*
characters).
$cmd = qq! cmd1 -d "double quotes" -s 'single-quotes' | cmd2 | (cmd3; cmd4
| cmd5) | cmd6 !
For the shell-shy, cmd1...cmd6 is a long pipeline. A sub-shell is created
for cmd3...cmd5. The idea was that cmd3 would process a bit of STDIN, then
cmd4 would take the rest, passing its output to cmd5. The *combined* output
of cmd3 followed by cmd5 would be passed as one STDIN into cmd6. Ugly?
Crafty? Inspired? Helpful!!!
The pipe was difficult enough to construct. It was really great to have
perl *help* me with the quoting mechanisms, rather than *hinder* me. I
could write it into my perl script just like I typed it into the shell
prompt!!!
otis@my-dejanews.com wrote in message <7bkak6$rfr$1@nnrp1.dejanews.com>...
>Hello,
>
>I was reading perlop man page and I was wondering if anyone could tell me
if
>there is any benefit from doing something like this:
>
>$a = q/a/;
>vs.
>$a = 'a';
>
>Also, what about this:
>@words = qw( one two three four );
>vs.
>@words = ('one','two','three','four');
>
>Or are q// and qw// just cool shortcuts(?) to use?
>
>Thanks,
>
>Otis
>--
>eZines Db - 3,000+ magazines, newspapers, journals, e-zines...
>http://www.dominis.com/Zines/?dn
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 04 Mar 1999 17:46:45 GMT
From: euclid@fantom.com (Dimitri Ostapenko)
Subject: Re: Securing files in a password protected area
Message-Id: <9GzD2.109$mt5.18@198.235.216.4>
Oh, man, I did it again. Sorry folks.
------------------------------
Date: Thu, 4 Mar 1999 07:20:14 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: split on meta question
Message-Id: <MPG.11484483684107929896d3@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <36DE68DE.53525FC5@mihy.mot.com> on Thu, 04 Mar 1999 16:35:02
+0530, Ramanujam Parthasarathi <partha@mihy.mot.com >says...
> George Collins wrote:
>
> > I need to split some text delineated with the "|" and "." characters.
...
> > ... I'm trying do something like:
> >
> > ($a, $b, $c)=split( "\.", "a.b.c" ) or
> > ($a, $b, $c)=split( "\|", "a|b|c" )
>
> You already have some answers. Just to add to them, it looks good using
> ($a, $b, $c) = split(/[\.\|]/, "any-string");
The request and examples are 'to split some text delineated with the "|"
and "." characters', but this code splits on "|" *or* ".".
Also, the backslashes in your character class are pure superstition.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 4 Mar 1999 14:46:09 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: split on meta question
Message-Id: <7bm6bh$a8u$1@pegasus.csx.cam.ac.uk>
Ramanujam Parthasarathi <rpsarathi@usa.net> wrote:
>
> You already have some answers. Just to add to them, it looks good using
>($a, $b, $c) = split(/[\.\|]/, "any-string");
And it looks even better if you omit the redundant backslashes:
($a, $b, $c) = split(/[.|]/, "any-string");
Mike Guy
------------------------------
Date: Thu, 04 Mar 1999 15:50:22 GMT
From: dragnovich@my-dejanews.com
To: sunny.boyle@slip.net
Subject: Re: SSI and Perl script with CGI.pm(Pondering?Hmmm...)
Message-Id: <7bma3q$hg8$1@nnrp1.dejanews.com>
No, no, no... you are getting all the Idea wrong! (answers bellow this mail)
Question...
> <HTML code snipped>
> <!--#exec cgi='/cgi-bin/myscript.pl'-->
> <HTML code snipped>
>
> The script-myscript.pl-utilizes CGI.pm heavily to generate the necessary HTML
> stuff and at this point of time I need to have the statement "print header;"
> before the script could spit out all the dynamically generated content to the
> browser through the above index.shtml. Looking at the source of the final
> page displayed on the browser reveals that the HTTP header generated as a
> result of "print header;" which is "Content-Type: text/html" does not exist
> in the source. BUT running myscript.pl on the command line(thus ignoring the
> SSI) reveals the HTTP header "Content-Type: text/html" as the first line of
> the output. Hmmm... Ain't this strange or am I missing something?
>
> I tried eliminating the "print header;" statement from my script and the
> result is that the dynamically generated content fails to appear in the
> browser. The only stuff displayed are those specified in index.shtml.
>
> QUESTIONS PONDERING ON AND REQUESTING FOR ENLIGHTENMENT
> ------------------------------------------------------- 1)Why is this
> happening? My understanding is that the browser gets the HTTP header from the
> .shtml page which is automatically generated by the web server. It should not
> need another HTTP header by the script. Seems like the browser eats up the
> latter HTTP header too as it does not show in the HTML source of the final
> page.
Yes and if you quit this header the server (well depending of the server)
will send you an error messaje! why?? Because you are getting all the idea
wrong, one thing is a CGI program (Common Gateway Interface), one thing is a
SSI (Server Side Include) and other thing are the server proceses!.
Well, when you send a print "Content-Type: text/html\n\n"; in a program, you
are telling to the "SERVER" that the final content of your script is a Text
on html format! (that's a mime type) or if you say Content-type: image/gif
you will tell the server that you will send a gif data (That's the way that
many graphical web counters works) from your program, well...
This is the process you're making ... you make your URL request /index.shtml
the server go and find the page, then it says HEY! this's an SHTML! well let's
process it!! it reads your page and say hey! here's a program!! well let's
execute it! ones the program finish the server sends you the results depending
of the shtml file and the cgi script.
So concluding, when you're telling the server that directive, you are really
telling the server, what kind of data you are submiting by your programs. Is
for that reason the server "EATS" that line! but if you dont send it, in some
servers it can make an error. And that's the reason that if you run the
program from de command line you see this line! and is because the script is
not procesed by the server.
> 2)Is the statement "print header:" mandatory when using CGI.pm. I do not
> think so and hope not. Looking into the source for CGI.pm does not indicate
> that either.
O yes is mandatory, because maybe the server ingnores this directive if it
cant understand it, but, when de page arrives to the browser THERE WILL BE
PROBLEMS MEN!! and you will not see nothing on your browser and it will try
to save the data to your computer.
> 3)How can I eliminate this redundancy of returning a HTTP header? I guess I
> call it redundant based on my theory as explained above.
Is not a redundancy is a server process keep it! it will not reduce your
program responce! =-)
See you!
------------------------
Juan Carlos Lopez
QDesigns President & CEO
http://www.qdesigns.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 04 Mar 1999 10:48:49 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: swallowing old lady (was Re: URGENT! Where Do You Hide The CGI Cards From The Spiders?)
Message-Id: <linberg-0403991048490001@ltl1.literacy.upenn.edu>
With just a slight tweak to Abigail's version (and a couple of minor word
changes), here's the way my mother used to sing it to me (what fun!):
#!/usr/local/bin/perl -w
use strict;
my @animals = (
[fly => "I don't know why she swallowed a fly.\n" .
"Perhaps she'll die."],
[spider => "That wiggled and jiggled and tickled inside 'er."],
[bird => "How absurd to swallow a bird!"],
[cat => "Imagine that! She swallowed a cat!"],
[dog => "What a hog to swallow a dog!"],
[goat => "She opened 'er throat and swallowed a goat."],
['horse...' => "She died, of course."],
);
my @swallowed;
$" = "\n";
while (my $animal = shift @animals) {
print "I knew an old lady who swallowed a @$animal\n";
last unless @animals;
my $bigger = $animal;
foreach my $smaller (@swallowed) {
print "She swallowed the $bigger->[0] to catch the $smaller->[0]\n";
print "$smaller->[1]\n" if ($smaller->[0] =~ /^(spider|fly)$/);
$bigger = $smaller;
}
unshift @swallowed => $animal;
print "\n";
}
__END__
--
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>
------------------------------
Date: Thu, 04 Mar 1999 16:55:55 GMT
From: evanjohn@my-dejanews.com
Subject: Re: The millennium cometh -- eventually
Message-Id: <7bmdul$l2v$1@nnrp1.dejanews.com>
In article <comdog-ya02408000R0303992012290001@news.panix.com>,
comdog@computerdog.com (brian d foy) wrote:
> In article <7bkfkv$3g$1@nnrp1.dejanews.com>, evanjohn@my-dejanews.com posted:
>
> > In article <comdog-ya02408000R0303991405050001@news.panix.com>,
> > comdog@computerdog.com (brian d foy) wrote:
>
[snip]
> you define the millenium as the set of numbers
> with a common thousands digit.
[snip]
> you think there is one absolute answer.
[snip]
I agree with everything you've written except what I've left unsnipped.
I've stated several times that I think the 3rd Millennium starts 1/1/2001 and
the 2000s start 1/1/2000.
My whole point was to find out which one people are talking about before
telling them they are wrong.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 4 Mar 1999 14:25:47 GMT
From: dkcombs@netcom.com (David Combs)
Subject: THOSE REVISED FAQ-ITEMS FROM TOM C.
Message-Id: <dkcombsF82qqz.2J9@netcom.com>
: comp.lang.perl.misc:
Here is a response to him that bounced from his doc-addr (a send-only-from
addr?)
He's been posting lots of individual revised-faq-ITEMS, eg:
Subject: Re: FAQ 6.19: What good is C<\G> in a regular expression?
X-Newsgroups: comp.lang.perl.misc
...
I ask this:
QUESTION: what faqs have been revised enough to
download them and print them out?
That is, are you STILL working on this, item
by item, throughout the faqs?
Or have you FINISHED the revisions of some (which
ones?) or all of them -- at least for a while --
thus it being a good time to download them.
----
By the way, the page .../newdocs/pod shows THESE dates:
[15]perlfaq1
General Questions About Perl ($Revision: 1.15 $, $Date:
1998/08/05 11:52:24 $)
[16]perlfaq2
Obtaining and Learning about Perl ($Revision: 1.25 $, $Date:
1998/08/05 11:47:25 $)
[17]perlfaq3
Programming Tools ($Revision: 1.29 $, $Date: 1998/08/05
11:57:04 $)
[18]perlfaq4
Data Manipulation ($Revision: 1.26 $, $Date: 1998/08/05
12:04:00 $)
[19]perlfaq5
Files and Formats ($Revision: 1.24 $, $Date: 1998/07/05
15:07:20 $)
[20]perlfaq6
Regexps ($Revision: 1.22 $, $Date: 1998/07/16 14:01:07 $)
[21]perlfaq7
Perl Language Issues ($Revision: 1.21 $, $Date: 1998/06/22
15:20:07 $)
[22]perlfaq8
System Interaction ($Revision: 1.26 $, $Date: 1998/08/05
12:20:28 $)
[23]perlfaq9
Networking ($Revision: 1.20 $, $Date: 1998/06/22 18:31:09 $)
[24]perlfaq
frequently asked questions about Perl ($Date: 1998/08/05
12:09:32 $)
[25]perlform
P
Whereas the FILES THEMSELVES says jan 99.
---
One thing that would be very nice to know is
what PERCENTAGE of the items in the various faqs have been
changed.
Clearly, one changed 80% is worth reprinting, rereading, whereas
one changed 2% would not be.
Guidance would be helpful -- not to avoid the downloading time,
but to avoid the RE-READING time.
Thanks!
David Combs
PS: What would be REALLY nice would be for you to take ALL these
REVISED faq-items, and tar.gz them in ONE file, and let us download
it. Of course posting that fact EACH FEW DAYS on comp.lang.perl.misc,
for a month or so.
And adding that fact to the the main perl www-page.
------------------------------
Date: Thu, 4 Mar 1999 15:44:28 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: Tied hashes and locking
Message-Id: <F82uE4.9B7@csc.liv.ac.uk>
In article <m34so6xwxt.fsf@joshua.panix.com>,
Jonathan Feinberg <jdf@pobox.com> writes:
> "Juho Cederstrvm" <cederstrom@removethis.kolumbus.fi> writes:
>
>> Do I have to lock a file when I'm using tie or dbmopen ? In other
>> words, do those functions have automatic locking or something like
>> that ?
>
> If you have the cash, you might seriously consider buying the Ram
> book, _Perl Cookbook_, published by O'Reilly. Section 14.5 is
> entitled "Locking DBM Files", and relates to your question. I believe
> that all of the code from the book is available here:
>
> ftp://ftp.oreilly.com/published/oreilly/perl/cookbook/
>
> In general, you must devise your own locking scheme using an extra
> lockfile.
I once did the following:-
In the constructor of the Tie Hash open the file for reading and then
flock it with and exclusive blocking lock.
I then stored the file pointer(?) in the newly created object.
I could then read in/ change/ delete the dat to my hearts content.
When the Tie hash was DESTROYed I simply closed the saved file pointer.
I was very dubious as to wheather this would work (TBH I expected to crash
and burn) but to my great suprise it seams to work. (At least on the HP-UX
and Linux sytems I have access to, wouldn't like to try it on an NFS
mounted file system though.)
I tested it by running a script that tried to get a lock on the same file.
It would then print a message saying that it had obtained the lock before
closing said file and looping around continously. A second test script did
the tie which waited until the user told it to continue before releasing
it's lock.
When I ran this the first script paused very soon after the second
started and then continued after the second was told to continue.
Ok I realise this isn't very rigourous and there maybe/are holes in the
test I haven't thought about but what amazed me most was that it worked.
So what are the pitfalls I have failed to address with this technique?
There are bound to be many :-)
I won't show the code here as this is going on a bit and if it is wrong I
wouldn't like anyone to use it.
--
Ian J. Garlick
<ijg@csc.liv.ac.uk>
New systems generate new problems.
------------------------------
Date: Thu, 04 Mar 1999 16:08:47 +0100
From: David Van den Brande <brandeda@se.bel.alcatel.be>
Subject: Undef subr &Treader::get called ???
Message-Id: <36DEA1FE.EA6F5FA2@se.bel.alcatel.be>
Can anyone help me with this error?
Undefined subroutine &Treader::get called at aanvraag2.cgi line 19.
Here is the code:
#!/usr/local/bin/perl5.003 -w
use LWP::Simple;
package Treader;
require HTML::Parser;
@ISA='HTML::Parser';
print "Content-type: text/html\n\n"; # Script tells server what is
comming.
# The server will pass the contents of further
# print statements back tot the browser.
&ReadParse; # subroutine declaration
foreach $key (keys %in) # Perl's built-in function "keys" returns a
list of all keywords
{ # in a assosiative array: keyword($key)=value($in{$key}).
$url=$in{$key}
}
my $table = get($url); #
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
my ($in_table,$in_td,$txtbuf,$colcnt,@columns);
# called for each start tag
sub start {
my ($p,$tag,$attr,$attrseq,$orig)=@_;
if ($tag eq 'table') {
$in_table=1;
} elsif ($tag eq 'tr') {
$colcnt=0;
} elsif ($tag eq 'td') {
$in_td=1;
$txtbuf='';
}
}
# called when text seen
# text may be split up into multiple calls
sub text {
my ($p,$t)=@_;
$txtbuf.=$t if ($in_table && $in_td);
}
#called when closing tag seen
sub end {
my ($p,$tag,$orig)=@_;
if ($tag eq 'td') {
push @{$columns[$colcnt++]}, $txtbuf;
$in_td=0;
} elsif ($tag eq 'table') {
$in_table=0;
}
}
my $p=new Treader; #
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$p->parse($table); #
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$p->eof(); # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# yes, I know this prints unnecessary trailing commas
foreach my $col (@columns) {
foreach my $row (@$col) {
print "$row,";
}
print "\n";
}
sub ReadParse # Reads all the form data from the user and puts them in
the right format
{ # (an associative array: name=value) into %in en %ENV.
local(*in) = @_ if @_; # Declaration of global variables to locally
scoped values within this subroutine.
local ($i, $key, $val);
if ($ENV{'REQUEST_METHOD'} eq "GET") # The form data is in the
query_string, an appendage of the URL of the script
{ # (everything qafter the "?" in the script URL).
$in = $ENV{'QUERY_STRING'};
}
elsif ($ENV{'REQUEST_METHOD'} eq "POST") # form data -> STDIN
{
read (STDIN, $in, $ENV{'CONTENT_LENGTH'}); # Reads "LENGTH(
$ENV{'CONTENT_LENGHT'})" bytes of data into a
} # scalar variable "$in" from the specified filehandle "STDIN".
@in = split(/&/,$in); # Split the string($in) every time there is a
"&".
# As a result we get an associative array: name1=value1
# name2=value2
# ...
foreach $i (0 .. $#in) # foreach name=value pair do:
{
# Convert plus's to spaces (for method GET).
$in[$i] =~ s/\+/ /g;
# Split into key and value on the first =
($key, $val) = split(/=/,$in[$i],2);
# Convert %XX from hex numbers to alphanumeric
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
# Associate key and value. \0 is the multiple separator
$in{$key} .= "\0" if (defined($in{$key}));
$in{$key} .= $val;
}
return length($in);
}
--
V David Van den Brande, Trainee at
----------------- Alcatel Switching VE27
| A L C A T E L | Fr. Wellesplein 1 - 2018 Antwerp - Belgium
----------------- mailto:David.Van_den_Brande@alcatel.be
------------------------------
Date: Thu, 4 Mar 1999 06:54:12 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: URGENT! Where Do You Hide The CGI Cards From The Spiders?
Message-Id: <MPG.11483e61936c720c9896d1@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <36de6200.4250206@news.skynet.be> on Thu, 04 Mar 1999
11:05:35 GMT, Bart Lateur <bart.lateur@skynet.be >says...
...
> print $user,crypt($pwd,'zx');
>
>
> You'll have to do this on the server, because crypt() can give different
> results on different machines, and you need the version as used by that
> machine. ...
Do you have any evidence to support that assertion -- either
experimental or in documentation? I just verified that crypt() gives
the same result on HP-UX (big-endian) and Windows 95 (little-endian),
and I thought that was the expected behavior.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
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 5053
**************************************