[10238] in Perl-Users-Digest
Perl-Users Digest, Issue: 3831 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 26 12:07:30 1998
Date: Sat, 26 Sep 98 09:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 26 Sep 1998 Volume: 8 Number: 3831
Today's topics:
Re: Best inexpensive database? (Mark-Jason Dominus)
Re: capturing html to variable or file (David A. Black)
Re: copy a file? <bcgrafx@sprynet.com>
Re: faxing in perl? <jerryp.usenet@connected.demon.co.uk>
Re: help with removing leading zeros with reg-exp (Bart Lateur)
Re: help with removing leading zeros with reg-exp (Larry Rosler)
Re: How do I implement perl with javascript or vice ver <ralrei@wave.home.com>
How do I work with perl in javascript? <poohba@io.com>
Re: How do I work with perl in javascript? <samwang@freewwweb.com>
how to code: iterate through x statements but stop if c vicuna@my-dejanews.com
Re: how to code: iterate through x statements but stop (Mark-Jason Dominus)
Re: how to code: iterate through x statements but stop (Larry Rosler)
I hate it when I do that. <jdf@pobox.com>
Re: Internal Server Error (Premature end of script head (SKotha)
Re: Internal Server Error (Premature end of script head (Allan M. Due)
Re: NT 4 + PWS 4 vs PERL 5 + CGI <new_email@see.web.page>
pattern match problem <awenzelh@atpibm6000.tuwien.ac.at>
Re: pattern match problem (Larry Rosler)
Perl 5 an GD - saving images - Win 32 <cablegp@the-snakepit.com>
perl tutorial chaitra@my-dejanews.com
Re: Perl version compatability <zenin@bawdycaste.org>
Re: Poll: How Did You Learn Perl? (Matthew Bafford)
Re: printing a two column sorted HTML table <rick.delaney@shaw.wave.ca>
Re: Programmierer gesucht! birgitt@my-dejanews.com
Re:help with removing leading zeros with reg-exp <stackhou@execpc.com>
Read out Data <marco.jaeger@dwm.ch>
retaining user id <bcgrafx@sprynet.com>
Re: Returning a "near" hash key. (David A. Black)
Re: Returning a "near" hash key. (Mark-Jason Dominus)
terminal & printer output qustions <karl@NOSPAMproline.at>
Re: terminal & printer output qustions <jdf@pobox.com>
Re: Where to put cgi-lib.pl (Patrick Timmins)
Re: Where to put cgi-lib.pl (Bart Lateur)
Re: Where to put cgi-lib.pl <zenin@bawdycaste.org>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Sep 1998 11:18:01 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Best inexpensive database?
Message-Id: <6uj0j9$emf$1@monet.op.net>
In article <360c07df.368445716@nntp.cts.com>,
Garrett Casey <nospamno_adms1@cts.com> wrote:
>I have heard of mySQL and mSQL.
Unless mSQL has advanced significantly in the 18 months since I last
used it, MySQL is much better on all fronts. I quit using mSQL
because it returned erroneous answers to queries, and switched to
MySQL. I discovered that MySQL was faster, cheaper, and had many more
features.
>Are they good? Do you have any other suggestions?
The well-known commercial databases like Oracle may not be as
expensive as you think. You should investiagte them before ruling
them out.
------------------------------
Date: Sat, 26 Sep 1998 07:30:56 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: capturing html to variable or file
Message-Id: <6uij9g$9kl$1@earth.superlink.net>
Hello -
mnb@ornl.gov (Mike Burnett) writes:
>I'm am using perl on a Windows NT Server.
>Could someone please provide the perl code to do the following:
> open a URL, but instead of displaying the web page, capture the
> HTML code in a variable or file
perl -MLWP::Simple -e 'getprint("http://whatever...")' > filename
David Black
dblack@saturn.superlink.net
------------------------------
Date: Sat, 26 Sep 1998 06:24:38 -0400
From: bc <bcgrafx@sprynet.com>
To: "Aleksey A. Pavlov" <paaa@uic.nnov.ru>
Subject: Re: copy a file?
Message-Id: <360CC0E5.97F2AC9B@sprynet.com>
I use this as well.
system cp command
system mv works if you don't want the duplicates.
I have a problem with this in that when I cross over nodes, the ownership is
lost.
eg. a file with owner 'bill' and group 'user' becomes nobody and nobody on the
second node of the network. Anybody know how to fix this?
Aleksey A. Pavlov wrote:
> Eva-Lena wrote:
> >
> > Hi!
> >
> > I have been looking for how to copy a file in a perl 5.0 script, but
> > haven't successed. Have tried to guess some commands like
> >
> > copy("$existingfile", "$newfile");
> > copy $existingfile $newfile; or
> > cp $existingfile $newfile;
> >
> > etc, but it doesn't work and I can't find out the proper one. Maybe one
> > can't do this? (I want to use a standard file (existing one) and write into
> > its copy when it has been created)
> >
> > Thanks a lot in advance for some tips! :=)
> > Eva-Lena, eva-lena@geocities.com
>
> system 'cp' ," $oldfile $newfile";
> is shortest way...:) i use it.
------------------------------
Date: Sat, 26 Sep 1998 06:55:44 +0100
From: Jerry Pank <jerryp.usenet@connected.demon.co.uk>
Subject: Re: faxing in perl?
Message-Id: <JqidfPAgHID2Ewa2@connected.demon.co.uk>
In <comp.lang.perl.misc>
Dennis P. <fsi001@gate.net>, writes:
>does anyone know how i can use perl to fax a complete form to 2-3 locations?
Not a Perl answer but IMHO, maybe a better one.
Use the [free] TCP email to fax gateway.
It's free to fax anywhere in the world (where a gateway exists)
will email you confirmation status and retry if engaged etc.
Search the web for tcp.int or just try it:
knock off leading 0, add country code end send as email
remote-printer.LOOT_FAX@441322290000.iddd.tpc.int
faxes to [UK] 01322 290000 with a fax header of LOOT_FAX.
--
Jerry Pank mailto:jerryp.usenet@netconnected.com
At many levels, Perl is a "diagonal" language.
-- Larry Wall in <199709021854.LAA12794@wall.org>
------------------------------
Date: Sat, 26 Sep 1998 09:41:34 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: help with removing leading zeros with reg-exp
Message-Id: <360db000.2359138@news.ping.be>
Craig Berry wrote:
>Abigail (abigail@fnx.com) wrote:
>
>: map {s/^0+//} @line_element [0 .. 5];
>
>Evil! Evil! Map in void context! Danger, Will Robinson! :)
For some odd reason, Abigail prefers map in a void context over foreach,
as being "more readable". See recent threads about that. I for one can't
see it like that.
foreach (@line_element[0 .. 5]) { s/^0+// }
What is so bad about this? Apart for the fact that its strips "0000"
down to "". :-) Retry:
foreach (@line_element[0 .. 5]) { s/^0+(\d)/$1/ }
Bart.
------------------------------
Date: Sat, 26 Sep 1998 08:08:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: help with removing leading zeros with reg-exp
Message-Id: <MPG.1076a353bd83f2e6989881@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <360db000.2359138@news.ping.be> on Sat, 26 Sep 1998 09:41:34
GMT, Bart Lateur <bart.mediamind@ping.be> says...
...
> foreach (@line_element[0 .. 5]) { s/^0+(\d)/$1/ }
#!/usr/local/bin/perl -w
use Benchmark;
@a = qw( 000 001 002 003 004 005 006 007 );
timethese (16384 , {
Control => sub { my @b = @a; },
Peek => sub { my @b = @a; foreach (@b[0 .. 5]) { s/^0+(?=\d)// } },
Replace => sub { my @b = @a; foreach (@b[0 .. 5]) { s/^0+(\d)/$1/ } },
Sum => sub { my @b = @a; foreach (@b[0 .. 5]) { $_ += 0 } },
} );
Benchmark: timing 16384 iterations of Control, Peek, Replace, Sum...
Control: 2 wallclock secs ( 1.53 usr + 0.00 sys = 1.53 CPU)
Peek: 5 wallclock secs ( 5.00 usr + 0.00 sys = 5.00 CPU)
Replace: 11 wallclock secs (10.77 usr + 0.00 sys = 10.77 CPU)
Sum: 5 wallclock secs ( 5.17 usr + 0.00 sys = 5.17 CPU)
On this architecture Peek and Sum are about the same. On any
architecture, Replace is a big loser compared to Peek.
Think how many CPU cycles I just saved the world in the future!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 26 Sep 1998 06:30:15 GMT
From: "R. Reiter" <ralrei@wave.home.com>
Subject: Re: How do I implement perl with javascript or vice versa?
Message-Id: <XR%O1.8265$I72.3258455@news.rdc1.on.wave.home.com>
There are two things I'd try before starting to write client-side CGI code
in javascript (since you know perl):
1) handle the onUnload in the client by changing location.href="logout.cgi"
and make logout.cgi a non-parsed header script that returns No Content
You should be able to do that from a hidden frame.
2) Modify the cookie expiry using javascript onUnload and modify the server
side
to scan the server list periodically and eliminate dead names - ignore
outdated
cookies rcvd on subsequent logons.
I hope either of these becomes feasible.
R. Reiter
>
------------------------------
Date: Sat, 26 Sep 1998 09:00:08 -0500
From: Chocolate <poohba@io.com>
Subject: How do I work with perl in javascript?
Message-Id: <Pine.BSF.4.02A.9809260855580.29626-100000@schultz.io.com>
I have this perl script that unsets a cookie that logs you out of a web
page. This is done by clicking on a button. The problem is when a person
just leaves and goes to another page then that person is not really logged
out. I would like to do something like onUnload and i have tried that but
it doesn't work correctly. What is the proper way to do this. This is
what I have now.
<script language="JavaScript">
<!--
function logout() {
logoutWin = window.open("bye.cgi",
"logout","toolbar=no,status=no,location=no");
}
//-->
</script>
<body onUnload="bye.cgi">
Suggestions Please!
* Web Page Designs *
< poohba@io.com | www.io.com/~poohba >
* (919)599-5543 *
------------------------------
Date: Sat, 26 Sep 1998 09:49:38 -0500
From: Sam Wang <samwang@freewwweb.com>
Subject: Re: How do I work with perl in javascript?
Message-Id: <360CFF01.1DE1476A@freewwweb.com>
> <script language="JavaScript">
>
> <!--
> function logout() {
> logoutWin = window.open("bye.cgi",
> "logout","toolbar=no,status=no,location=no");
> }
> //-->
>
> </script>
>
> <body onUnload="logout();"> <!-- changed to function name.
------------------------------
Date: Sat, 26 Sep 1998 13:16:07 GMT
From: vicuna@my-dejanews.com
Subject: how to code: iterate through x statements but stop if condition is true
Message-Id: <6uipen$njv$1@nnrp1.dejanews.com>
Hi,
<Warning semi-long post that is really an algorithm question>
First let me apologize for my ugly post on ugly ifs earlier. I never meant
for it to be so ugly. Something went horribly wrong when I tried to cut and
paste using an friends computer. Anyway. I still am bothered by nested if
statements. (For example, I currently need to make multiple guesses as to
what the name of a file might be because in the past people named them
ideosyncratically but based on common information.) One of things that I
think is really cool about Perl is that it seems to mirror the english
language so well. If I can say something clearly and concisely in english,
you can usually say something similar in Perl. Now, you can easily instruct
someone: "Here, try these things in order until one of them works, then
stop". Or: "If any of these things works you can stop". And the intent is
clear. But I am having a hard time writing clear code that does the same
thing. I want to be able to only evaluate the if statement if I need to, not
every time. I have tried using nested ifs.
try_one();
if (!success) {
try_two(); {
if (!success) {
try_three();
if (!success) {nothing_worked()}
}
}
But if you have many of these it looks ugly, and it is hard to add and
remove the procedures. And if you don't use procedures the code gets really
hard to read.
I have also tried things like
$outcome = try_one();
$outcome = try_two() if ($outcome ne success);
$outcome = try_three() if ($outcome ne success);
nothing_worked() if ($outcome ne success);
which is easier to read and change, but each if has to be evaluated every
time the program is run, which seems inefficient.
It just seems to me that there must be some general way say in Perl: If a
condition is false, step through each one of these things until the condition
is true, then stop and continue with the rest of the program (or we could
reverse true and false above). What am I missing?
Bob
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 26 Sep 1998 11:08:23 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: how to code: iterate through x statements but stop if condition is true
Message-Id: <6uj017$eln$1@monet.op.net>
In article <6uipen$njv$1@nnrp1.dejanews.com>, <vicuna@my-dejanews.com> wrote:
> I have also tried things like
>
> $outcome = try_one();
> $outcome = try_two() if ($outcome ne success);
> $outcome = try_three() if ($outcome ne success);
> nothing_worked() if ($outcome ne success);
If they're all function calls, you should put them in an array,
because arrays of for expressing aggregation in sequence, which is
what you're doing here:
@functions = (\&try_one, \&try_two, \&try_three, \¬hing_worked);
foreach $f (@functions) {
last if $f->();
}
If it's more generic code, you should turn it into function calls and
do the same thing:
@functions = (\&try_one,
sub { print "Nope, try_one did not work.\n"; return 0 },
sub { $hostname = qx{hostname};
return $hostname ne '';
},
sub { $hostname = qx{uname -n};
return $hostname ne '';
},
sub { local *U;
open U, "/etc/uuname" or return 0;
my $success = 0;
$success = 1 if defined($hostname = <U>);
$success = 0 if defined(<U>);
close U;
chomp $hostname if $success;
return $status;
},
);
foreach $f (@functions) {
last if $f->();
}
> which is easier to read and change, but each if has to be evaluated every
>time the program is run, which seems inefficient.
This is actually the silliest example of performance anxiety that I
have ever seen. How long do you think it is going to take to evaluate
a truth condition and decide a branch? And how are you going to
decide that the function returned a true value without doing that?
I seriously suggest that you review your priorities.
Fortunately, there is a code readability issue here as well, which is
why I wrote an answer.
------------------------------
Date: Sat, 26 Sep 1998 08:18:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how to code: iterate through x statements but stop if condition is true
Message-Id: <MPG.1076a586c6621d70989882@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <6uipen$njv$1@nnrp1.dejanews.com> on Sat, 26 Sep 1998 13:16:07
GMT, vicuna@my-dejanews.com <vicuna@my-dejanews.com> says...
...
> It just seems to me that there must be some general way say in Perl: If a
> condition is false, step through each one of these things until the condition
> is true, then stop and continue with the rest of the program (or we could
> reverse true and false above). What am I missing?
perlfaq7: "How do I create a switch or case statement?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 26 Sep 1998 15:04:50 +0200
From: Jonathan Feinberg <jdf@pobox.com>
Subject: I hate it when I do that.
Message-Id: <m3g1df58jx.fsf@joshua.panix.com>
Perl's flexibility and expressiveness makes it possible to write a
code phrase that compiles and runs without warning, but is not at all
what you meant.
I'd say that once a day, on average, I write this:
$foo = s/something/something else/;
when I meant to bind the regex to $foo. This results in minutes of
frustration while I fail to see what could *possibly* be wrong with
such a simple subroutine, or one-liner, what have you.
I hate it when I do that.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 26 Sep 1998 05:52:08 GMT
From: skotha@aol.commail (SKotha)
Subject: Re: Internal Server Error (Premature end of script headers)
Message-Id: <19980926015208.10403.00002050@ng146.aol.com>
> #!/usr/bin/perl
> &PrintHeader
> sub PrintHeader {
> print "Content-type: text/html\n\n";
> print "test";
> }
>
The missing semi-colon after the call to PrintHeader couldn't have caused the
problem as the script worked "previously."
What about adding "\r\n" instead of "\n\n" after "text/html"?
Vasu
NB: Please use my email address after deleting the word 'mail' from it
--------------------------------------------------------------------------
--------
"Always complete your actions." --Deng Ming-Dao
------------------------------
Date: 26 Sep 1998 14:52:18 GMT
From: Allan@Due.net (Allan M. Due)
Subject: Re: Internal Server Error (Premature end of script headers)
Message-Id: <6uiv32$2jk$0@206.165.146.37>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <98EAA94897203E01.377606EE6CA09818.BC8ED5F2EA6964C7@library-
proxy.airnews.net>, JD Lampard (lampard@ticnet.com) posted...
|When my script executes, or attempts to I am returned the following error:
|
|Internal Server Error
|Premature end of script headers
||
| &PrintHeader
| sub PrintHeader {
| print "Content-type: text/html\n\n";
| print "test";
| }
|
| -Did it work??? Same f@#%ing error!!!
|
Works for me if you add the necessary ; after PrintHeader. Not really
related but it is probably a good idea to use
#/usr/bin/perl -w
use strict
also
CGI::Carp qw(fatalsToBrowser);
can be very helpful.
__
Allan M. Due
Allan@Due.net
The beginning of wisdom is the definitions of terms.
- Socrates
------------------------------
Date: 25 Sep 1998 23:17:10 PDT
From: "Phlip" <new_email@see.web.page>
Subject: Re: NT 4 + PWS 4 vs PERL 5 + CGI
Message-Id: <6ui0t6$m2p@chronicle.concentric.net>
>I'm set to reinstall PWS right now then I'l be set to retest all these
>options...
For posterity, here's the fix.
MS slip-streams all their patches and bug fixes into the CDs that have
the same titles and version numbers as they used to. Try to appear
shocked about this. If I installed PWS last year and since then have
been installing various upgrades and service packs, the install gets
kinda hoary. I got the latest WinNT 4.0 Option Pack, un-installed it,
installed it all again, ran PERLw32-install.BAT, and then added this
line to the registry (the one I started with):
...\w3svc\Script Map\.pl=d:\perl\bin\perl.exe
Finally I added Web Sharing Execute permission to the directory where
the pl file is, and it worked
The experience has left me just thrilled enough to want to switch to
O'Rielly WebPro Server...
> -- Phlip (no replies - address munged)
>======= http://users.deltanet.com/~tegan/home.html =======
> -- Have a :-) Day --
>
>
------------------------------
Date: Sat, 26 Sep 1998 15:37:16 +0200
From: Tony Wenzelhuemer <awenzelh@atpibm6000.tuwien.ac.at>
Subject: pattern match problem
Message-Id: <360CEE0C.7B13101B@atpibm6000.tuwien.ac.at>
--------------EB3BF6EF248D3FFB5D5637D0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi there!
Just learning perl, I wonder why the following construct always leads to
-errormessage- even when the input data is valid:
...
foreach $bchk (@buchk) {
if(($bchk!~/[^0-9]/) || ($bchk=~/[^0-9]/ && $1=~/\./)) {
-accept $bchk-
}
else {
-print errormessage-
}
}
...
I would read that as
"if $bchk does not contain anything else but 0...9 (i.e.does only
contain 0...9)
or if $bchk does contain anything but 0...9 and this anything is a
.(dot)then
accept $bchk, else shout ERROR."
What did I do wrong? (regular newlines have been skipped before)
My guess is that the respective return values might not be TRUE or
FALSE...
Thanks for helping a beginner to look through
Tony
--------------EB3BF6EF248D3FFB5D5637D0
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
Hi there!
<P>Just learning perl, I wonder why the following construct always leads
to -errormessage- even when the input data is valid:
<P>...
<BR><TT>foreach $bchk (@buchk) {</TT>
<BR><TT> if(($bchk!~/[^0-9]/) || ($bchk=~/[^0-9]/ && $1=~/\./))
{</TT>
<BR> -accept $bchk-
<BR><TT> }</TT>
<BR><TT> else {</TT>
<BR> -print errormessage-
<BR><TT> }</TT>
<BR><TT>}</TT>
<BR><TT>...</TT>
<BR><TT>I would read that as</TT>
<BR><TT>"if $bchk does not contain anything else but 0...9 (i.e.does only
contain 0...9)</TT>
<BR><TT> or if $bchk does contain anything but 0...9 and this anything
is a .(dot)then</TT>
<BR><TT> accept $bchk, else shout ERROR."</TT><TT></TT>
<P><TT>What did I do wrong? (regular newlines have been skipped before)</TT>
<BR><TT>My guess is that the respective return values might not be TRUE
or FALSE...</TT><TT></TT>
<P><TT>Thanks for helping a beginner to look through</TT>
<BR><TT>Tony</TT>
<BR> </HTML>
--------------EB3BF6EF248D3FFB5D5637D0--
------------------------------
Date: Sat, 26 Sep 1998 08:39:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: pattern match problem
Message-Id: <MPG.1076aa94b0c9c770989883@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <360CEE0C.7B13101B@atpibm6000.tuwien.ac.at> on Sat, 26 Sep
1998 15:37:16 +0200, Tony Wenzelhuemer <awenzelh@atpibm6000.tuwien.ac.at>
says...
...
> foreach $bchk (@buchk) {
> if(($bchk!~/[^0-9]/) || ($bchk=~/[^0-9]/ && $1=~/\./)) {
> -accept $bchk-
> }
> else {
> -print errormessage-
> }
> }
> ...
> I would read that as
> "if $bchk does not contain anything else but 0...9 (i.e.does only
> contain 0...9)
> or if $bchk does contain anything but 0...9 and this anything is a
> .(dot)then
> accept $bchk, else shout ERROR."
You are referring to a captured value $1 without having any capturing
parentheses.
This is the direct fix (with superfluous parens removed and space added
for legibility) [WARNING: snippets not tested]:
if ($bchk !~ /[^0-9]/ || $bchk =~ /([^0-9])/ && $1 =~ /\./) {
This is equivalent (\D means 'char that is not a digit'):
if ($bchk !~ /\D/ || $bchk =~ /\./) {
And this avoids "double negatives":
if ($bchk =~ /^\d*$/ || $bchk =~ /\./) {
And this rolls the 'or' into the regex:
if ($bchk =~ /^\d*$|\./) {
Aren't regexes wonderful?
Having said all that, I wonder if this isn't a FAQ:
perlfaq4: "How do I determine whether a scalar is
a number/whole/integer/float?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 26 Sep 1998 10:31:34 -0400
From: Gregory P Cable <cablegp@the-snakepit.com>
Subject: Perl 5 an GD - saving images - Win 32
Message-Id: <360CFAC6.E0B77FCC@the-snakepit.com>
I am able to produce the image on screen (verified with a cgi script on
a web server), but cannot seem to save the image to the disk.
I have tried doing a print to a open file handle as suggested in the
docs as such:
method 1:
$imageData = $image->gif;
binmode WRITE;
print WRITE $imageData;
method 2:
binmode WRITE;
print WRITE $image->gif;
Have also tried wrapping the $image->gif in parens and quotes thinking
it may be assigning the value 1 to $imageData (or printing 1 to the file
as well) because it was returning 1 aas successful.
Any suggestions would be appreciated !
Thanks,
Greg
------------------------------
Date: Sat, 26 Sep 1998 05:53:12 GMT
From: chaitra@my-dejanews.com
Subject: perl tutorial
Message-Id: <6uhvg8$sp3$1@nnrp1.dejanews.com>
Hi,
can anyone help me in finding some good perl tutorial on the web.
bye
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 26 Sep 1998 15:32:25 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl version compatability
Message-Id: <906823951.413799@thrush.omix.com>
Ian Wilkinson <ian@no-spam.4site.co.uk> wrote:
: When asked recently about upgrading to a more recent version of Perl, a
: representative replied - "It has not been upgraded to avoid possible problems
: with existing scripts". I'm not in a position to argue about the merits of
: that statement (having only completed the first two chapters of the 'camel'
: book :), so I would like to ask this group whether or not (and what) problems
: would, in fact, exist. Isn't Perl 5 backwardly compatible?
>snip<
Yes, it is backwardly compatible, mostly. Most of the problems are
going from perl4 to perl5 however, not between 5.* releases. The
newest 5.005 release is guaranteed to cause problems if you've been
using a lesser version extensively and don't read the *entire* readme
file and do what it says to/warns about. Up to 5.00404 however, should
be fine for most uses.
: Also, is it possible for two or more flavours (sic) of Perl 5 to co-exist on
: the same server - with scripts just 'requiring' the desired version? Or could
: this be handled in the shebang line? Or am I being completely niaive?
It's handled in the shebang line. If you've got 5.001 installed,
you should be able to do this:
#!/usr/local/bin/perl5.001
And thus guarantee that the version used is maintained even if you
upgrade perl.
If all your scripts name the exact version they want like this,
upgrading to 5.005* won't cause any problems.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Sat, 26 Sep 1998 08:26:28 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Poll: How Did You Learn Perl?
Message-Id: <MPG.1075d771dc85aac39896b8@news.south-carolina.net>
In article <MPG.10730d06c758f81e9896b3@news.south-carolina.net>
on Wed, 23 Sep 1998 17:53:09 -0400, Matthew Bafford
(dragons@scescape.net) pounded in the following text:
=> In article <360923EC.8E9919D0@min.net> on Wed, 23 Sep 1998
=> 12:38:04 -0400, John Porter (jdporter@min.net) pounded in the
=> following text:
=> => Matt Knecht wrote:
=>
=> => . Other book (give name)
Forgot:
Mastering Regular Expresions
And as of yesterday(!):
Perl Cookbook
Barnes took forever to get it, but it looks like it _was_ worth
the wait. :) Thanks for a another great book, Tom (and Nathan)!
--Matthew
------------------------------
Date: Sat, 26 Sep 1998 15:27:56 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: printing a two column sorted HTML table
Message-Id: <360D097D.882A9870@shaw.wave.ca>
[posted & mailed]
Tom Tingdale wrote:
>
> Has anyone formatted a sorted list into a two column HTML table?
Here's a snippet from an old script of mine that formats to 3 columns.
Changing the 3's to 2's should work for you.
WARNING: I haven't re-tested this code. The script is "in production",
though and I haven't heard any complaints.
# begin snippet
@categories = sort keys %link;
$col_size = int(@categories / 3);
$col_size++ if @categories % 3;
$count = 0;
print "<TABLE BORDER WIDTH="100%">\n";
print "<TR><TD>\n";
for $category (@categories) {
if(++$count > $col_size){
$count = 1;
print "</TD>\n<TD>\n";
}
print "$link{$category}\n";
}
print "</TD></TR>\n";
print "</TABLE>\n";
# end snippet
HTH
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Sat, 26 Sep 1998 10:55:00 GMT
From: birgitt@my-dejanews.com
Subject: Re: Programmierer gesucht!
Message-Id: <6uih64$fa3$1@nnrp1.dejanews.com>
In article <19980925135413.15635.00001767@ng43.aol.com>,
chrija@aol.com (ChriJa) wrote:
>
> Wir suchen Programmierer f|r die Weiterentwicklung von Acses, unserer
> Buchpreis-Suchmaschine auf http://www.acses.com !
>
I don't think most of clpm readers like to see job openings here
and if most of them are kind enough not to protest, you should at least
translate into English. Otherwise post to de.clp.
B. F.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Sat, 26 Sep 1998 08:16:08 -0500
From: Mark Stackhouse <stackhou@execpc.com>
Subject: Re:help with removing leading zeros with reg-exp
Message-Id: <6uipqv$9jp@newsops.execpc.com>
Thanks to all who responded to my post. And a special thanks to David,
Joe, Andrew, Uri, RJ, Larry, Dave, and Lee who responded personally via
E-mail! Your code and especially your explanations were VERY
enlightening. Rest assured, I've filled a whole page in my Perl notes
for future applications.
I have chosen a solution suggested by Dave Wolfe. His explanation was
clear, concise, and understandable! I only wish he had responded
to the group as well :( Other part time Perlers would certainly be
benefited. And yes, Dave, I will revisit the FAQ's as you suggested.
Thanks again to all who invested their valuable time.
--
Mark Stackhouse
***********************************************************************
homepage: http://www.execpc.com/~stackhou
"The best things in life aren't things."
--Art Buchwald
***********************************************************************
------------------------------
Date: Sat, 26 Sep 1998 10:17:53 +0200
From: Marco =?iso-8859-1?Q?J=E4ger?= <marco.jaeger@dwm.ch>
Subject: Read out Data
Message-Id: <360CA330.79E0ECC6@dwm.ch>
Hi everyone
Did anyone ever read out data from a Microsoft Access *.mdb File to post
it on a HTML-Page ?
Thanks for any answers
Marco Jdger
Digitale Werbemedien AG
Switzerland
------------------------------
Date: Sat, 26 Sep 1998 06:40:19 -0400
From: bc <bcgrafx@sprynet.com>
Subject: retaining user id
Message-Id: <360CC493.33F6EF33@sprynet.com>
I have written a Perl Database that requires backwards compatiblity to
our previous database on OpenVMS. The data files are just plain text
files. The Perl CGI server is running IRIX 6.3 and uses an nfs mounting
system to mount the database server.
Now my problem. The files created by the Irix system won't transfer over
to the OpenVMS system without losing their user id. The protections are
maintained as created.
The protections are RW for user,group,and other. The userid becomes
ucx$nobody and the group becomes ucx$nobody. Both systems have logins
that correspond.
'chown' from the Perl CGI has no effect. In contrast 'chmod' works as
expected.
Is it possible to get Perl to transfer the file and maintain the id and
group?
------------------------------
Date: Fri, 25 Sep 1998 21:31:55 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: Returning a "near" hash key.
Message-Id: <6uhg6b$k6s$1@earth.superlink.net>
Hello -
nospamno_adms1@cts.com (Garrett Casey) writes:
>My code goes like this:
>Populate hash with many random generated strings as keys.
>Generate random_search_string.
>$f = getKey($hash{$random_search_string));
>If $random_search_string is not a key, $f should equal the closest
>find. So, is there something like getKey() available?
I'm posting this in the hope of flushing out a truly slender and
idiomatic version. This one has that not-quite-there feel.... but
it might suit your needs, if adapted.
#!/usr/local/bin/perl -w
use strict;
my %h = map { $_, uc } qw(apple banana kiwi orange);
for my $w ( qw( orangutan applutan kiwutan bananutan ) ) {
print "Closest to $w: ", $h{closekey(\%h, $w)}, "\n";
}
sub closekey { closeidx([%{shift()}], shift) }
sub closeidx {
my ($l, $w) = @_;
my @sl = sort(@$l, $w);
my ($n, $p);
do { $n = $p; $p = shift @sl } until $p eq $w;
shift @sl || $n;
}
David Black
dblack@saturn.superlink.net
------------------------------
Date: 26 Sep 1998 11:27:42 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Returning a "near" hash key.
Message-Id: <6uj15e$en6$1@monet.op.net>
In article <6uhg6b$k6s$1@earth.superlink.net>,
David A. Black <dblack@saturn.superlink.net> wrote:
>I'm posting this in the hope of flushing out a truly slender and
>idiomatic version.
Unless the hash is very small, it is probably better to do binary
search than linear search.
At first I thought that it was bizarre that there is no CPAN module
for that. But I suppose that what that shows is that most binary
searching problems can be solved better in Perl with a hash. This one
is an exception.
------------------------------
Date: Sat, 26 Sep 1998 12:27:07 +0100
From: "Karl" <karl@NOSPAMproline.at>
Subject: terminal & printer output qustions
Message-Id: <6uifut$s5f$1@orudios.magnet.at>
hi all,
i have to make 2 programms,
1 where the people can enter data via telnet in the sql database. this
should be a full screen programm with funktion keys if possible. the SWL
connection from perl already works fine using MySql.
2 a programm printing lists from this data including GIF files.
now i am looking for moduls handling the screen I/O and the printer I/O if
something is available. especially handling b/w and color terminals. i am
running FreeBSD 2.2.6 on all servers.
any help would be appreziated.
many thanks
Karl
AUSTRIA
------------------------------
Date: 26 Sep 1998 14:47:54 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: "Karl" <karl@proline.at>
Subject: Re: terminal & printer output qustions
Message-Id: <m3iuib59c5.fsf@joshua.panix.com>
"Karl" <karl@NOSPAMproline.at> writes:
> now i am looking for moduls handling the screen I/O and the printer
> I/O if something is available. especially handling b/w and color
> terminals.
The standard place to look for modules:
http://www.perl.com/CPAN-local/CPAN.html
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Sat, 26 Sep 1998 10:39:57 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Where to put cgi-lib.pl
Message-Id: <6uig9t$eg6$1@nnrp1.dejanews.com>
In article <906771860.693065@thrush.omix.com>,
Byron Brummer "Zenin" <zenin@bawdycaste.org> harped (twice):
> And my point, quite simply, is that you are wrong. Stop harping on
> people for issues that you do not understand.
and
> Please make sure you know what you are talking about before you
> start harping on others for legitimate questions that you do not
> understand.
Between his harpings he also tried to bury this :
> If this isn't a Perl question, it's a systems programming question.
So he agrees with me that "I want to know where to put the cgi-lib.pl file",
(verbatim - from the original post) is not a perl question. Now I
just have to convince him that the best place to find the information is
"probably in a cgi news group" (verbatim - from my response to the
original post).
I honestly believe the original poster would have more luck with figuring
out what he is trying to accomplish by looking in some other newsgroup,
say comp.infosystems.www.authoring.cgi , rather than some systems
programming newsgroup.
Twice a week, Nathan Torkington makes a post to c.l.p.m. titled:
*** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
In which he recommends:
[snip]
2. comp.lang.perl.misc is for questions on the Perl language. Try
comp.infosystems.www.authoring.cgi for questions on the CGI part of
CGI scripts. The two leading blocks of reusable code for CGI purposes
are CGI.pm, at
http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
and cgi-lib.pl, at
http://www.bio.cam.ac.uk/cgi-lib/
[snip]
If you take a look at the link shown for cgi-lib.pl, you'll see that the
creator of cgi-lib.pl, Steven Brenner, puts cgi-lib.pl in the cgi-bin (just
as I recommended in this thread), and then uses:
require "./cgi-lib.pl";
to call it from the original script. Why is it "harping" for me to point
this out, and try to make sure the original poster understands this? You
*don't* want him to use cgi-lib.pl in the way it was intended by its'
creator?
Well, you've convinced me. Here is the original post in its' entirety:
----
I know this sounds stupid, but I'm entirely new to PERL
programming in general. I want to know where to put the cgi-lib.pl file ...
----
>From now on, bring any and all questions like this to c.l.p.m.
This kind of post is just the sort of thing we need more of here.
Got an in-house Perl application you've inherited and want to know
where to store it on your system? Post to c.l.p.m. - Zenin knows ...
Got a system administration tool you've designed, but don't know
where to put it? Post to c.l.p.m. - Zenin knows ...
Got a perl module or library that comes complete with documentation right
on your system, as well as its' own website dedicated to its' support?
Don't read it! Post to c.l.p.m. - Zenin knows ...
Getting '500' errors from your web server whenever you try to run your
Perl cgi's? Don't check your server docs! Post to c.l.p.m. - Zenin knows ...
I could go on and on with this, but I'm laughing so hard I actually
blew snot all over my keyboard ... Yuck !
Patrick Timmins
$monger{Omaha}[0]
Hey! How do I get snot off my keyboard? Post to c.l.p.m. - Zenin knows ...
ha ha ha he :) ... yuck! not again!
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Sat, 26 Sep 1998 12:42:18 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: Where to put cgi-lib.pl
Message-Id: <360ce06a.317850@news.ping.be>
Patrick Timmins wrote:
>I honestly believe the original poster would have more luck with figuring
>out what he is trying to accomplish by looking in some other newsgroup,
>say comp.infosystems.www.authoring.cgi , rather than some systems
>programming newsgroup.
>
>Twice a week, Nathan Torkington makes a post to c.l.p.m. titled:
>
>*** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
>
>In which he recommends:
>[snip]
>2. comp.lang.perl.misc is for questions on the Perl language. Try
>comp.infosystems.www.authoring.cgi for questions on the CGI part of
>CGI scripts.
Note that the question is NOT about the CGI part of CGI scripts.
It's about where to put your library files and how Perl (NOT the CGI
server!) can find it.
Besides, I think the question has been answered properly in the
meantime.
Bart.
------------------------------
Date: 26 Sep 1998 15:54:25 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Where to put cgi-lib.pl
Message-Id: <906825271.6407@thrush.omix.com>
Patrick Timmins <ptimmins@netserv.unmc.edu> wrote:
: In article <906771860.693065@thrush.omix.com>,
: Byron Brummer "Zenin" <zenin@bawdycaste.org> harped (twice):
>snip<
: Between his harpings he also tried to bury this :
: > If this isn't a Perl question, it's a systems programming question.
:
: So he agrees with me that "I want to know where to put the cgi-lib.pl file",
: (verbatim - from the original post) is not a perl question.
No, he doesn't. The only reason he mention systems programming is
the fact that the location of an executable and the current working
directory at the time that executable is run are unrelated is a
systems issue. It is Perl issue as well, as these systems issues
directly affect how you use perl.
Change that quote you have above to, "I want to know where to put
the chat.pl file". Would you still think it is a CGI question?
: Now I
: just have to convince him that the best place to find the information is
: "probably in a cgi news group" (verbatim - from my response to the
: original post).
Not likely. The question about where to put a *perl* library file,
regardless of its use, is singally related to perl. This issue
has nothing to do with the CGI protocol in the slightest. It is a
lie to say it does.
>snip<
: Twice a week, Nathan Torkington makes a post to c.l.p.m. titled:
: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
:
: In which he recommends:
: [snip]
: 2. comp.lang.perl.misc is for questions on the Perl language.
This *IS* a perl question...
: Try
: comp.infosystems.www.authoring.cgi for questions on the CGI part of
: CGI scripts. ^^^^^^^^^^^^
Note the "the CGI part" of that quote. This is not "the CGI part",
this is the "where the hell can I put a perl library file of any
type what so ever such that perl can find it" part.
>snip<
: If you take a look at the link shown for cgi-lib.pl, you'll see that the
: creator of cgi-lib.pl, Steven Brenner, puts cgi-lib.pl in the cgi-bin (just
: as I recommended in this thread), and then uses:
:
: require "./cgi-lib.pl";
Which, as has been noted by myself and others in this thread, is
not reliable, portable, or recommend in any form.
: to call it from the original script. Why is it "harping" for me to point
: this out, and try to make sure the original poster understands this? You
: *don't* want him to use cgi-lib.pl in the way it was intended by its'
: creator?
The creator is wrong. This isn't his fault however, as I'm sure the
particular web server he worked on actively did a chdir() to the
script's dirname() before running it. Many, many servers however
are not so friendly. More over, it is not part of any spec that
they do this, nore should they *ever* be expected to.
: From now on, bring any and all questions like this to c.l.p.m.
Yes, if the standard docs haven't fully helped solve the problem
of course.
: Got an in-house Perl application you've inherited and want to know
: where to store it on your system? Post to c.l.p.m. - Zenin knows ...
If you're wondering why it can't seem to find its own private
libraries, sure.
: Got a perl module or library that comes complete with documentation right
: on your system, as well as its' own website dedicated to its' support?
: Don't read it! Post to c.l.p.m. - Zenin knows ...
The web site is wrong. Since when does having your own web site
guarantee that you are right?
: Getting '500' errors from your web server whenever you try to run your
: Perl cgi's? Don't check your server docs! Post to c.l.p.m. - Zenin knows ...
This would be a CGI/server question, unrelated to perl. It would belong
in the *.cgi groups. The question asked however, was not this.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3831
**************************************