[19299] in Perl-Users-Digest
Perl-Users Digest, Issue: 1494 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 11 03:06:48 2001
Date: Sat, 11 Aug 2001 00:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <997513508-v10-i1494@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 11 Aug 2001 Volume: 10 Number: 1494
Today's topics:
<frames> & CGIWRAP <jtjohnston@courrier.usherb.ca>
Re: <frames> & CGIWRAP <godzilla@stomp.stomp.tokyo>
Re: [Q] Trying to streamline a simple comparison <goldbb2@earthlink.net>
Re: ASCII-Code in perl (J.B. Moreno)
avoiding caching in gethostbyname / gethostbyaddr <rlogsdon@io.com>
Re: avoiding caching in gethostbyname / gethostbyaddr <godzilla@stomp.stomp.tokyo>
Re: avoiding caching in gethostbyname / gethostbyaddr <godzilla@stomp.stomp.tokyo>
Re: avoiding caching in gethostbyname / gethostbyaddr (noident)
Cropping blank space in images. <ten.stm@egreborj>
Re: Cropping blank space in images. <godzilla@stomp.stomp.tokyo>
Re: DBI:CSV SQL 'order by' problem <neisius@earthlink.net>
Re: DBI:CSV SQL 'order by' problem (Eric Bohlman)
Re: DBI:CSV SQL 'order by' problem <goldbb2@earthlink.net>
FAQ: How can I manipulate fixed-record-length files? <faq@denver.pm.org>
Re: MIME::Lite::HTML <bart.lateur@skynet.be>
Re: Perl and Charts <bwalton@rochester.rr.com>
Re: Replying to posts (Chas Friedman)
stat() in W98SE (A. Rodriguez)
Re: stat() in W98SE <godzilla@stomp.stomp.tokyo>
Writing to a file in another directory (sowbug)
Re: Writing to a file in another directory (Eric Bohlman)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 11 Aug 2001 02:06:34 GMT
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: <frames> & CGIWRAP
Message-Id: <3B74916E.58DC46EA@courrier.usherb.ca>
I'm using one of the "/@# cgiwrap servers for Perl.
My html files are in obscure places on the server
$file1="/home/obscureplace/me/html/file1.html"
$file2="/home/obscureplace/me/html/file2.html"
I want to do someting like:
open(HTML,"$path_to_html/$startreadingtask1") or die "can't open
$path_to_html/$startreadingtask1: $!\n";
#flock(HTML, 2);
@HTMLData = <HTML>;
close(HTML);
foreach $HTMLDataLine (@HTMLData)
{
$HTMLDataLine
=~s/\<\!\-\-healthframeset\.html\-\-\>/$insertstartreadingtask1/go;
}
and then do something like:
print EOT
<html>
<head>
<title>Reading Comprehension: Task 1</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<frameset rows="197,197">
<frame src="/me/healthtext.html" name="Healthy Choice Text">
<frame src="@HTMLData" name="Healthy Choice Questions">
</frameset>
<noframes>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</noframes>
</html>
EOT;
Not that I expect to do this, but would anyone have any suggestions on
how to display @HTMLData (dynamically changed html) in frames?
------------------------------
Date: Fri, 10 Aug 2001 19:41:45 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: <frames> & CGIWRAP
Message-Id: <3B749B69.2A5DED5C@stomp.stomp.tokyo>
jtjohnston wrote:
> I'm using one of the "/@# cgiwrap servers for Perl.
(snipped frames topic)
Use of cgi-wrap is unrelated to whatever it is you
want to do. A cgi-wrap program only limits any damage
done via a cgi program to the current user's account,
nothing else; it is a firewall between individual
accounts and the primary server's guts. A cgi wrapper
is not a server as you believe.
In what way is use of frames related to a cgi wrapper?
I am curious why you are locking a filehandle opened
for read only.
Godzilla!
------------------------------
Date: Sat, 11 Aug 2001 00:57:44 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: [Q] Trying to streamline a simple comparison
Message-Id: <3B74BB48.528C7158@earthlink.net>
Robert wrote:
>
> I have a small script where someone can enter up to 2 search terms,
> then I see if they match two values in my script. Here's how
> I'm doing it:
>
> - - - - - - -
> if ($term1 =~ /$myterm1/ && $term2 =~ /$myterm2/) {
> blah blah;
> }
> - - - - - - -
>
> If $term1 or $term2 are null, the above does not work as
> desired. I can do this:
>
> - - - - - - -
> if ($term1 eq "" ) {
> if ($term2 =~ /$myterm2/) {
> blah blah;
> }
> elsif ($term2 eq "" ) {
> if ($term1 =~ /$myterm1/) {
> blah blah;
> }
> else {
> if ($term1 =~ /$myterm1/ && $term2 =~ /$myterm2/) {
> blah blah;
> }
> }
> - - - - - - -
>
> This basically says "If term 1 is null, then only compare
> term2."
>
> This is obviously not very streamlined ... I was hoping to do
> something like:
>
> - - - - - - -
> if ($term1 eq "" ) {
> $term=".*";
> }
> if ($term2 eq "" ) {
> $term=".*";
> }
> if ($term1 =~ /$myterm1/ && $term2 =~ /$myterm2/) {
> blah blah;
> }
> - - - - - - -
>
> This way, if a term is null, it will match anything. The above
> doesn't work, though. I'm sure there's an easy way to do this
> ... can anyone point me in the right direction?
How about:
my $t1 = ($term1 eq "") || ($term1 =~ /$myterm1/);
my $t2 = ($term2 eq "") || ($term2 =~ /$myterm2/);
if( $t1 && $t2 ) {
blah blah;
}
--
I need more taglines. This one is getting old.
------------------------------
Date: Sat, 11 Aug 2001 00:31:09 -0400
From: planb@newsreaders.com (J.B. Moreno)
Subject: Re: ASCII-Code in perl
Message-Id: <1exy7j0.1x36lqe1hnldo4N%planb@newsreaders.com>
Manuel Kφrner <manuel.koerner@rexroth.de> wrote:
> Hi to all,
>
> i want to know how i can get the ASCII-Code
> from a letter.
> eg.:
> $value = 0;
> $char = 'a';
>
> $value = function($char); # or something in that way
$value=sprintf "%x", ord($char);
print $value;
--
JBM
"Your depression will be added to my own" -- Marvin of Borg
------------------------------
Date: Fri, 10 Aug 2001 20:48:54 -0500
From: Reuben Logsdon <rlogsdon@io.com>
Subject: avoiding caching in gethostbyname / gethostbyaddr
Message-Id: <Pine.LNX.4.33.0108102034510.22800-100000@bermuda.io.com>
Hello all,
I have a Perl CGI script which I want to react in a special way to visits
by a certian client, who will be identified by DNS. Basically, if the
script is visited by a client from "enforcer.myhost.com", then the CGI
script will share it's registered/not-registered status, and will accept a
self-destruct command if my enforcer bot chooses to send one. It will not
share that kind of privileged data with any other visitor.
What worries me is that some person could configure reverse DNS on an IP
they control such that its claims its name is "enforcer.myhost.com" (in a
non-authorative way). So I will have my CGI script do gethostbyaddr on
the visitor IP, and then do a double-check gethostbyname on the privileged
name to make sure its IP matches the visitor. Will gethostbyname always
do a round trip back to the authorative nameserver of "myhost.com", or
will it possibly use a cached (fraudulent) IP from some internal table?
Is there some flag that I can pass to gethostbyname or another function to
require a full DNS lookup without caching? Does anyone have any
experiences to share with these types of authentication issues?
Regards,
Reuben Logsdon
------------------------------
Date: Fri, 10 Aug 2001 20:11:01 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: avoiding caching in gethostbyname / gethostbyaddr
Message-Id: <3B74A245.EE2591FD@stomp.stomp.tokyo>
Reuben Logsdon wrote:
> I have a Perl CGI script which I want to react in a special way to visits
> by a certian client, who will be identified by DNS. Basically, if the
> script is visited by a client from "enforcer.myhost.com", then the CGI
> script will share it's registered/not-registered status, and will accept a
> self-destruct command if my enforcer bot chooses to send one. It will not
> share that kind of privileged data with any other visitor.
You must be the Last Starfighter.
Highly illogical. How will you self-destruct a backup copy of
an unregistered script? More illogical, what would prevent a
person from denying your host access to this script? Most
illogical, what prevents hacking in a registration? Absolutely
illogical, what prevents removal of your registration coding?
Have you considered destruction of files within an account
other than your own is a criminal offense? Your appropriate
and expected response is civil ligitigation. Calamity Jane
took the Wild West days with her to the grave.
Are you criminally minded?
> What worries me is that some person could configure reverse DNS....
What you describe is technologically impossible. Classic IP spoofing
can only be attained by a trusted handshake between two machines,
with the victim machine being yours. Do you plan to allow a person
to commandeer your machine? I know of no hacker willing to run risks
simply to destroy an unregistered script for whatever thrill.
Are your associates Script Kiddies?
A highly logical choice would be to make use of a user agent
containing very specific information known only to you. This
eliminates any need for DNS checking and eliminates any need
for IP checking. However, this will not protect you from
retribution nor being criminally charged, as should be.
* ponders for a split second how easy it would be defeat his concept *
It's a no-brainer.
There is only one effective method of script self-destruction.
Tell me what is this method?
I would suggest you work on more logical thinking lest someone
like me, Godzilla, snatches your starfighter out of the sky,
then stomps both you and your Tinker Toy rocketship into a
one cubic foot chunk of hot smoking scrap metal.
Godzilla! Queen Of Tinker Toys.
------------------------------
Date: Fri, 10 Aug 2001 20:22:34 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: avoiding caching in gethostbyname / gethostbyaddr
Message-Id: <3B74A4FA.7A8A3C59@stomp.stomp.tokyo>
Godzilla! wrote:
> ligitigation.
Sure Kira!
* laughs *
Godzilla! Queen Of Mach 3 Typing.
------------------------------
Date: 10 Aug 2001 23:42:06 -0700
From: noident@my-deja.com (noident)
Subject: Re: avoiding caching in gethostbyname / gethostbyaddr
Message-Id: <66fba11b.0108102242.27557475@posting.google.com>
Reuben Logsdon <rlogsdon@io.com> wrote in message news:<Pine.LNX.4.33.0108102034510.22800-100000@bermuda.io.com>...
> Hello all,
>
> I have a Perl CGI script which I want to react in a special way to visits
> by a certian client, who will be identified by DNS. Basically, if the
> script is visited by a client from "enforcer.myhost.com", then the CGI
> script will share it's registered/not-registered status, and will accept a
> self-destruct command if my enforcer bot chooses to send one. It will not
> share that kind of privileged data with any other visitor.
>
> What worries me is that some person could configure reverse DNS on an IP
> they control such that its claims its name is "enforcer.myhost.com" (in a
> non-authorative way).
OK, suppose a bad guy has configured his reverse DNS tables to resolve
his numeric IP address 6.6.6.6 to enforcer.myhost.com
> So I will have my CGI script do gethostbyaddr on
> the visitor IP, and then do a double-check gethostbyname on the privileged
> name to make sure its IP matches the visitor. Will gethostbyname always
> do a round trip back to the authorative nameserver of "myhost.com", or
> will it possibly use a cached (fraudulent) IP from some internal table?
Now the bad guy has made a connection to your script. Your environment
is:
$ENV{REMOTE_ADDR} is '6.6.6.6'.
At this point the server (usually) would do a reverse DNS query and
resolve it to enforcer.myhost.com. However, as per the DNS RFC, the
results of a reverse lookup must never be cached. At this stage a call
to gethostbyname('enforcer.myhost.com') will return your address, and
not the bad guy's. This is also the stage at which the result of the
forward lookup you've just made is cached by your DNS server.
> Is there some flag that I can pass to gethostbyname or another function to
> require a full DNS lookup without caching?
I doubt.
>Does anyone have any
> experiences to share with these types of authentication issues?
>
> Regards,
> Reuben Logsdon
cheers
------------------------------
Date: Sat, 11 Aug 2001 03:23:20 GMT
From: "James Roberge" <ten.stm@egreborj>
Subject: Cropping blank space in images.
Message-Id: <Iy1d7.52$KoS1.2293815@tomcat.sk.sympatico.ca>
Hi, I am working on a web site with a perl back end, and one of the features
of this site is that users may upload pictures. Well that is all fine and
dandy, but one problem... some of the users dont know how to work their
scanners and instead of scanning just a picture, they scan the picture as
well as the back of the whole scanner cover. So i end up with pictures that
have a picture up in the corner, and a big black area everywhere. Another
thing they doo is scan the picture at too high of resolution which makes for
a HUGE picture. As you can imagine this makes some pretty big files, and
alot of wasted space.
I can handle the resizing of pictures, but is there an easy way that i could
get perl to check an image for a large black area (or a large area of all
one or similar colour) and then crop that off? What kinda cpu power are we
talking about here cropping and resizing pictures? Or, would i be better
off just just limiting the file size to about 100k jpegs?
Thanks.
James Roberge
------------------------------
Date: Fri, 10 Aug 2001 20:40:00 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Cropping blank space in images.
Message-Id: <3B74A910.3207C519@stomp.stomp.tokyo>
James Roberge wrote:
(snipped)
> I can handle the resizing of pictures, but is there an easy way that i could
> get perl to check an image for a large black area (or a large area of all
> one or similar colour) and then crop that off? What kinda cpu power are we
> talking about here cropping and resizing pictures? Or, would i be better
> off just just limiting the file size to about 100k jpegs?
Your subject topic is blank areas. Would you
bank on black being blank?
* slips on her Dunce What If Cap *
Don't you just adore What If people?
If this large black area is beautiful surrounding
starry night sky?
Wait! This large black area is a stage curtain behind
a classic nineteen-sixties Sailor's Tijuana Dream Date
taking a donkey for a ride.
Why are you not personally inspecting pictures uploaded
to your server? I certainly do. If uploaded pictures
are not Triple-X Rated, forget it; circular file time.
Paint Shop Pro and Photoshop are very effective tools
for your task.
Godzilla!
--
$_="47855853557555
515
0";
tr/
873514/975318642abcdef/;
s/([0-9A-Fa-f]{2})/sprintf("%c",hex($1))/ge;
tr/
/ H-OV-ZP-UA-G/;
print$_=reverse$_;exit;
------------------------------
Date: Sat, 11 Aug 2001 03:39:40 GMT
From: "Bill Neisius" <neisius@earthlink.net>
Subject: Re: DBI:CSV SQL 'order by' problem
Message-Id: <0O1d7.1556$ZM2.109047@newsread2.prod.itd.earthlink.net>
"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3B747059.B15A5A9A@earthlink.net...
> Which package are you using to make your CSV file act as an SQL
> database? DBD::AnyData, or DBD::CSV ?
>
> I don't think it matters much at the moment, since neither seems to
> support a way of specifying column types. Try changing the CSV file so
> that the first column is always quoted, even if it doesn't contain
> commas, spaces, etc.
It's DBD::CSV, which uses DBI, SQL::Statement, and Text::CSV_XS.
Nope, didn't help putting quotes on the column...
I found the offending code in SQL::Statement, in Statement.pm:
my $sortFunc = sub {
...
} elsif ($c =~ /^\s*[+-]?\s*\.?\s*\d/ &&
$d =~ /^\s*[+-]?\s*\.?\s*\d/) {
$result = ($c <=> $d);
} else {
$result = $c cmp $d;
}
...
Basically, it does a numeric compare if the column value STARTS with
a numeric. Values like '123ABC' or '5.13.2' would naturally not be
handled properly...
The simple solution would be to change "<=>" to "cmp" and always do
string sorts. That works for me, as I don't intend to do any numeric
sorting on this project... It really should have a better pattern check for
numerics... something that goes all the way to the end ($) of the column
value.
The main problem now is that I don't want to use a 'local' copy of
Statement.pm. Guess I've got to lobby the SQL maintainers for an update...
------------------------------
Date: 11 Aug 2001 04:45:36 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: DBI:CSV SQL 'order by' problem
Message-Id: <9l2d9g$kft$4@bob.news.rcn.net>
Bill Neisius <neisius@earthlink.net> wrote:
> The simple solution would be to change "<=>" to "cmp" and always do
> string sorts. That works for me, as I don't intend to do any numeric
> sorting on this project... It really should have a better pattern check for
> numerics... something that goes all the way to the end ($) of the column
> value.
> The main problem now is that I don't want to use a 'local' copy of
> Statement.pm. Guess I've got to lobby the SQL maintainers for an update...
You might want to see how big a job it would be to create your own
subclass of SQL::Statement that does the comparison correctly. That
would, at least to my mind, be a lot better than creating a private
version (which naturally could get out of sync with the official version).
It's the sort of thing you're *supposed* to use OOP for :)
------------------------------
Date: Sat, 11 Aug 2001 02:23:24 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: DBI:CSV SQL 'order by' problem
Message-Id: <3B74CF5C.5A3265F4@earthlink.net>
Bill Neisius wrote:
>
> "Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
> news:3B747059.B15A5A9A@earthlink.net...
>
> > Which package are you using to make your CSV file act as an SQL
> > database? DBD::AnyData, or DBD::CSV ?
> >
> > I don't think it matters much at the moment, since neither seems to
> > support a way of specifying column types. Try changing the CSV file
> > so that the first column is always quoted, even if it doesn't
> > contain commas, spaces, etc.
>
> It's DBD::CSV, which uses DBI, SQL::Statement, and Text::CSV_XS.
>
> Nope, didn't help putting quotes on the column...
>
> I found the offending code in SQL::Statement, in Statement.pm:
>
> my $sortFunc = sub {
> ...
> } elsif ($c =~ /^\s*[+-]?\s*\.?\s*\d/ &&
> $d =~ /^\s*[+-]?\s*\.?\s*\d/) {
> $result = ($c <=> $d);
> } else {
> $result = $c cmp $d;
> }
> ...
>
> Basically, it does a numeric compare if the column value STARTS with
> a numeric. Values like '123ABC' or '5.13.2' would naturally not be
> handled properly...
For that matter, neither would " - 12" since this string gets treated
like a number, but it becomes the value 0. In other words, those \s*
things should NOT be there (except the one just after the anchor).
> The simple solution would be to change "<=>" to "cmp" and always do
> string sorts. That works for me, as I don't intend to do any numeric
> sorting on this project... It really should have a better pattern
> check for numerics... something that goes all the way to the end ($)
> of the column value.
Indeed. There will be times when you want to do numeric comparison, and
saying 'always use cmp' is just a bad solution.
my $number = qr[\A
(?>\s*) # leading whitespace ok when numerifying a string.
(?>[-+]?) # optional plus/minus.
(?>\d+\.\d*|\.\d+) # required mantissa
(?>[eE][-+]?\d+)? # optional exponent
(?>\s*) # trailing whitespace ok, too
\z]x;
# the anti-backtracking (> ... ) should speed it up for some strings.
...
} elsif ($c =~ /$number/ && $d =~ /$number/) {
#putting the re litterally here, rather than via a variable, might be
#faster.
$result = ($c <=> $d);
} else {
$result = $c cmp $d;
}
> The main problem now is that I don't want to use a 'local' copy of
> Statement.pm. Guess I've got to lobby the SQL maintainers for an
> update...
It'll probably get fixed faster if you give them a patch, rather than
telling them what's wrong and where and asking them fix it.
--
I need more taglines. This one is getting old.
------------------------------
Date: Sat, 11 Aug 2001 06:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How can I manipulate fixed-record-length files?
Message-Id: <x54d7.38$V3.171043840@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How can I manipulate fixed-record-length files?
The most efficient way is using pack() and unpack(). This is faster than
using substr() when taking many, many strings. It is slower for just a
few.
Here is a sample chunk of code to break up and put back together again
some fixed-format input lines, in this case from the output of a normal,
Berkeley-style ps:
# sample input line:
# 15158 p5 T 0:00 perl /home/tchrist/scripts/now-what
$PS_T = 'A6 A4 A7 A5 A*';
open(PS, "ps|");
print scalar <PS>;
while (<PS>) {
($pid, $tt, $stat, $time, $command) = unpack($PS_T, $_);
for $var (qw!pid tt stat time command!) {
print "$var: <$$var>\n";
}
print 'line=', pack($PS_T, $pid, $tt, $stat, $time, $command),
"\n";
}
We've used "$$var" in a way that forbidden by "use strict 'refs'". That
is, we've promoted a string to a scalar variable reference using
symbolic references. This is ok in small programs, but doesn't scale
well. It also only works on global variables, not lexicals.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
05.05
--
This space intentionally left blank
------------------------------
Date: Sat, 11 Aug 2001 01:54:39 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: MIME::Lite::HTML
Message-Id: <p549nt4rmbjtiudaapohbak934kg62ma14@4ax.com>
Aaron wrote:
> To => 'alian@saturne', --------------- as it is below, I would like
>to use
>
>To => '$emailAddy',
Remove the quotes. You might use double quotes, but the single quotes
make perl take the string literally.
--
Bart.
------------------------------
Date: Sat, 11 Aug 2001 01:04:48 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Perl and Charts
Message-Id: <3B7484F5.D9206251@rochester.rr.com>
Mark Riehl wrote:
>
> All - We're going to be working on a project using CGI to build a front-end
> to a Web-based application built on top of a MySQL database.
>
> We'd like to be able to generate a few charts based on the data. Would it
> be possible to generate the charts, and be able to download or save them
> (maybe as a jpg or png)?
Yes, see sample code below.
>
> Our initial platform was Win2k. I looked through the CPAN and saw that most
> of the charting modules seemed to be more geared towards Unix. Is this
> correct?
No, this is Perl, so it is geared toward programmers and users, not
OSes.
>
> Questions:
>
> 1. Is there a way to do this under Windows?
What platform you do it on doesn't matter. This is Perl.
> 2. Would I be better off doing this under Linux?
Of course you would. Too much blue hurts the eyes.
...
> Mark
Here is code for a simple example:
use CGI qw(:standard);
use GD;
if(param('image')){
print "Content-type: image/png\n\n";
binmode STDOUT;
$im = new GD::Image(100,100);
$lightpurple=$im->colorAllocate(255,200,255);
$black=$im->colorAllocate(0,0,0);
$im->interlaced('true');
$im->line(param('n1'),param('n2'),param('n3'),
param('n4'),$black);
print $im->png;
exit;
}
print header,
start_html('GD Example'),
h1('GD Example'),
start_form,
textfield('n1'),p,
textfield('n2'),p,
textfield('n3'),p,
textfield('n4'),p,
"Enter four numbers from 0 to 100 and submit",p,
submit,
end_form,
hr;
if(param()){
print img{src=>'GDtest.pl?n1='.param('n1').
'&n2='.param('n2').'&n3='.param('n3').
'&n4='.param('n4').'&image=yes',width=>100,height=>100};
}
print end_html;
Put that up as a CGI script under a Perl-enabled web server which has
the GD module installed. The browser used must support png images.
"Save image as..." works with this method (right-click the image [at
least in some browsers]).
--
Bob Walton
------------------------------
Date: Sat, 11 Aug 2001 05:45:10 GMT
From: friedman@math.utexas.edu (Chas Friedman)
Subject: Re: Replying to posts
Message-Id: <3b74c657.3863857@news.itouch.net>
On Fri, 10 Aug 2001 17:34:29 -0500, "Chas Friedman"
<friedman@math.utexas.edu> wrote:
>
>Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
>news:3B7458E8.225A7A27@stomp.stomp.tokyo...
>> If you try to include more quoted text than your own comments,
>> more than three times, my hack trick will suck-up your hard drive
>> and email it to steve.case@aol.com for his own use.
>>
> Thanks for the warning; I hate it when that happens!
>>
>> Godzilla!
>> --
>> $_="47?85.58535?575-5-5.?"515.0";
>> tr/.??873514".-T>/975318642abcdef/;
>> s/([0-9A-Fa-f]{2})/sprintf("%c",hex($1))/ge;
>> tr/"".--~Ts>o,f".??^?S > print$_=reverse$_;exit;
>
> Note: The above code doesn't seem to be executable; I think it doesn't
>appear correctly in the newsreader window (Outlook Express or Netscape).
>(The other "signature" code I've run all seems OK.) Is there embedded
>binary?
>
>
------------------------------
Date: 10 Aug 2001 20:33:25 -0700
From: stuff@mail.chiriqui.com (A. Rodriguez)
Subject: stat() in W98SE
Message-Id: <ae07ec28.0108101933.4a355282@posting.google.com>
Hi,
Does stat() return anything in Windows 98 SE.
I have tried everything I can think of with no results. What I want
is the $mtime for a file
The line below prints nothing
print join('|', stat($files));
any help appreciated.
Angel
------------------------------
Date: Fri, 10 Aug 2001 20:55:41 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: stat() in W98SE
Message-Id: <3B74ACBD.7FE26081@stomp.stomp.tokyo>
A. Rodriguez wrote:
> Does stat() return anything in Windows 98 SE.
(snipped)
#!perl
$filename = "c:/apache/users/test/test1.pl";
$last_modified = (stat ($filename)) [9];
print "Last Modified Epoch Seconds: $last_modified";
exit;
PRINTED RESULTS:
_______________
Last Modified Epoch Seconds: 997501838
Godzilla!
--
stat
stat file
Returns a 13-element list giving the statistics for a file,
indicated by either a filehandle or an expression that gives
its name.
It's typically used as follows:
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = stat $filename;
Not all fields are supported on all filesystem types.
Here are the meanings of the fields:
Field Meaning
________________
dev Device number of filesystem
ino Inode number
mode File mode (type and permissions)
nlink Number of (hard) links to the file
uid Numeric user ID of file's owner
gid Numeric group ID of file's owner
rdev The device identifier (special files only)
size Total size of file, in bytes
atime Last access time since the epoch
mtime Last modification time since the epoch
ctime Inode change time (not creation time!) since the epoch
blksize Preferred blocksize for file system I/O
blocks Actual number of blocks allocated
$dev and $ino, taken together, uniquely identify a file.
The $blksize and $blocks are likely defined only on BSD-derived
filesystems. The $blocks field (if defined) is reported in 512-byte
blocks. Note that $blocks*512 can differ greatly from $size for
files containing unallocated blocks, or "holes," which aren't
counted in $blocks.
If stat is passed the special filehandle consisting of an underline,
no actual stat is done, but the current contents of the stat
structure from the last stat or stat-based file test (the -x operators)
is returned.
Source: Perl In A Nutshell
Chapter Five
Copyright © 2001 O'Reilly & Associates.
------------------------------
Date: 10 Aug 2001 22:37:18 -0700
From: brianwharris@hotmail.com (sowbug)
Subject: Writing to a file in another directory
Message-Id: <c5d7d22b.0108102137.6274c6dd@posting.google.com>
Does anybody know the correct syntax for writing to a file in another
directory besides the one you are currently in. Using a Unix server
with apache. I'm trying to write to a html file that's in htdocs from
the script which is in the cgi-bin directory. Do the forward slashes
have to be escaped? I've tryed almost every thing I can think of.
Thanx in advance.
------------------------------
Date: 11 Aug 2001 06:56:08 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Writing to a file in another directory
Message-Id: <9l2ku8$hhe$4@bob.news.rcn.net>
sowbug <brianwharris@hotmail.com> wrote:
> Does anybody know the correct syntax for writing to a file in another
> directory besides the one you are currently in. Using a Unix server
> with apache. I'm trying to write to a html file that's in htdocs from
> the script which is in the cgi-bin directory. Do the forward slashes
> have to be escaped? I've tryed almost every thing I can think of.
You just include the *filesystem* path (*not* the *URL* path) to the file
as part of its name when you open() it. Of course you test the success of
your open() and die with an error message that includes $! when it fails,
so you can tell why it failed. No, you don't need to escape forward
slashes.
I've got a hunch that when you see that error message, it will tell you
that the user that Apache is running as doesn't have permission to write
to your htdocs directory, but that's just a guess.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1494
***************************************