[19690] in Perl-Users-Digest
Perl-Users Digest, Issue: 1885 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 6 21:05:35 2001
Date: Sat, 6 Oct 2001 18: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: <1002416709-v10-i1885@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 6 Oct 2001 Volume: 10 Number: 1885
Today's topics:
Re: activeperl, windows 98 & apache (bal)
Re: Am I asking too much ??? (Tana)
Re: Am I asking too much ??? <jeff@vpservices.com>
ANNOUNCE: Graphics::ColorNames v0.30 <wlkngowl@unix.asb.com>
Bug in s/\B.//g and s/\b.//g (was: Re: Goedel JAPH) <bart.lateur@skynet.be>
Re: Bug in s/\B.//g and s/\b.//g (was: Re: Goedel JAPH) <nospam-abuse@ilyaz.org>
Converting graphic formats (CodePilot)
Re: Converting graphic formats <comdog@panix.com>
Re: Converting graphic formats <codepilot@canada.com>
Re: Converting graphic formats <goldbb2@earthlink.net>
Re: Finding the difference between arrays... (JR)
Re: Goedel JAPH (Martien Verbruggen)
Re: How to change date of a file <comdog@panix.com>
Re: How to change date of a file <comdog@panix.com>
Re: Open Test Failed (David Efflandt)
Perl to set cookie <peter.cch@mailexcite.com>
Re: Perl to set cookie (David Efflandt)
Re: Perl via metasend <bart.lateur@skynet.be>
Re: quasi xml to xml (Alan Barclay)
Re: resetting variables <goldbb2@earthlink.net>
tainted Perl on CGI question... <bogus@mail.address.com>
Re: tainted Perl on CGI question... <jeff@vpservices.com>
Re: tainted Perl on CGI question... <bogus@mail.address.com>
time transformation <yah00204052@yahoo.com>
Re: time transformation (Tim Hammerquist)
Re: time transformation <dtweed@acm.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Oct 2001 16:34:23 -0700
From: balsellathurai@hotmail.com (bal)
Subject: Re: activeperl, windows 98 & apache
Message-Id: <58504532.0110061534.5910f14d@posting.google.com>
Cheers bart, adding :
print "Content-type: text/html\n\n";
made it work
Bal
------------------------------
Date: 6 Oct 2001 13:59:37 -0700
From: tana@acedsl.com (Tana)
Subject: Re: Am I asking too much ???
Message-Id: <4294f74d.0110061259.67c337a0@posting.google.com>
Jon Ericson <Jon.Ericson@jpl.nasa.gov> wrote in message news:<86itducbrg.fsf@jon_ericson.jpl.nasa.gov>...
> tana@acedsl.com (Tana) writes:
>
> > I have the following code in PERL:
>
> [snip code]
>
> > My question is:
> > Could someone give me the equivalent PHP code for this PERL code above?
> > Am I asking too much ???
>
> Frankly, yes. This is a newsgroup for discussion of *perl*. Honestly,
> you'd be better off finding a group discussing *PHP*.
>
> Jon
To All,
Sorry people, but no reason to be rude.
I was just hoping that someone would know both languages.
Such a person would be able to give me a straight answer in 5 seconds.
thanks anyway
Tana
------------------------------
Date: Sat, 06 Oct 2001 14:32:10 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Am I asking too much ???
Message-Id: <3BBF785A.578AE47B@vpservices.com>
Tana wrote:
>
> Jon Ericson <Jon.Ericson@jpl.nasa.gov> wrote in message news:<86itducbrg.fsf@jon_ericson.jpl.nasa.gov>...
> > tana@acedsl.com (Tana) writes:
> >
> > > I have the following code in PERL:
> >
> > [snip code]
> >
> > > My question is:
> > > Could someone give me the equivalent PHP code for this PERL code above?
> > > Am I asking too much ???
> >
> > Frankly, yes. This is a newsgroup for discussion of *perl*. Honestly,
> > you'd be better off finding a group discussing *PHP*.
> >
> > Jon
>
> To All,
> Sorry people, but no reason to be rude.
In what way is Jon's answer rude? You asked if you were asking too much
and he (and everyone else) replied that yes you were. If you walked
into a face-to-face meeting about fish and asked how to repair your
bicycle, it would not be rude to say, "We are discussing fish here" and
in fact it would be polite (and accurate) to say "you'd be better off
finding a place discussing bicycles".
> I was just hoping that someone would know both languages.
The possibility that there are some people in the meeting who know about
both fish and bicycles is not really relevant to whether bicylces are
the topic of the meeting.
--
Jeff
------------------------------
Date: Sat, 06 Oct 2001 00:05:57 -0400
From: Robert Rothenburg <wlkngowl@unix.asb.com>
Subject: ANNOUNCE: Graphics::ColorNames v0.30
Message-Id: <truqhroia2ff40@corp.supernews.com>
I've uploaded the latest version of Graphics::ColorNames to CPAN. So it
should show up soon in a CPAN mirror near you in something like
$CPAN//authors/id/R/RR/RRWO/Graphics-ColorNames-0.30.tar.gz
The README is below:
NAME
Graphics::ColorNames - defines RGB values for common color names
REQUIREMENTS
`Graphics::ColorNames' should work on Perl 5.005.
It uses only standard modules.
Installation
Installation is pretty standard:
perl Makefile.PL
make
make test
make install
HISTORY
Revision history since v0.24:
0.30 4 Oct 2001
- fixed bug with non-existent color names
- corrected some typos in and updated the documentation
- added multiple color naming schemes
- when passed a value in the form of '#000000', returns that value
SYNOPSIS
use Graphics::ColorNames qw( hex2tuple tuple2hex );
tie %NameTable, 'Graphics::ColorNames', 'X';
my $rgbhex1 = $NameTable{'green'}; # returns '00ff00'
my $rgbhex2 = tuple2hex( 0, 255, 0 ); # returns '00ff00'
my @rgbtup = hex2tuple( $rgbhex ); # returns (0, 255, 0)
my $rgbhex3 = $NameTable{'#123abc'}; # returns '123abc'
my $rgbhex4 = $NameTable{'123abc'}; # returns '123abc'
DESCRIPTION
This module defines RGB values for common color names. The intention
is
to (1) provide a common module that authors can use with other
modules
to specify colors; and (2) free module authors from having to
"re-invent
the wheel" whenever they decide to give the users the option of
specifying a color by name rather than RGB value.
A more detailed description with documentation can be found in the
module's POD.
AUTHOR
Robert Rothenberg <rrwo@cpan.org>
LICENSE
Copyright (c) 2001 Robert Rothenberg. All rights reserved. This
program
is free software; you can redistribute it and/or modify it under the
same terms as Perl itself.
------------------------------
Date: Sat, 06 Oct 2001 23:14:28 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Bug in s/\B.//g and s/\b.//g (was: Re: Goedel JAPH)
Message-Id: <833vrtcabs7mh9d8v9hqlkhdpn28p8ohg0@4ax.com>
[Posted and mailed (because of the change in the subject line)]
Leopold Toetsch wrote:
>Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>> "prInT"JuSt anOtHeR PeRl HaCkEr""
>
>The program uses AFAIK just basic Perl instructions, so this is strange.
>It works for me with 5.00503 and 5.00502 on two different Linux
>machines. Do you know, what is different in 5.6, that breaks it?
Executing it line by line reveals this transition, converts the string
that contains:
$_='PRINT"JUST ANOTHER PERL HACKER"'
into
$_='PrInT"JuSt AnOtHeR PeRl HaCkEr"'
by executing the line
s/\B./lc$MATCH/eg;
(with, of course, "use English" in effect).
The reasoning is that every character not following a word boundary
should be lower case. That looks like a big bug in 5.6.0 and 5.6.1.
$_ = 'ABCD EFG';
s/\B(.)/\L$1/g;
print;
-->
AbCd EfG
s/\B([A-Z])/\L$1/g;
-->
AbCd EfG
while(s/\B([A-Z])/\L$1/) {}
-->
Abcd Efg
It seems like the non-boundary isn't recognized right after a
substitution. Hmm... Would /\b/ exhibit the same behaviour?
$_ = 'A+B+C+D+E+F';
s/\b(.)/X/g;
print;
-->
X+X+X+X+X+X
Oh yeah. Note that there is a word boundary between all characters in my
string, so every character should be replaced.
--
Bart.
------------------------------
Date: Sat, 6 Oct 2001 23:40:30 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Bug in s/\B.//g and s/\b.//g (was: Re: Goedel JAPH)
Message-Id: <9po4pe$1tk$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Bart Lateur
<bart.lateur@skynet.be>], who wrote in article <833vrtcabs7mh9d8v9hqlkhdpn28p8ohg0@4ax.com>:
> substitution. Hmm... Would /\b/ exhibit the same behaviour?
>
> $_ = 'A+B+C+D+E+F';
> s/\b(.)/X/g;
> print;
> -->
> X+X+X+X+X+X
This may be a *very different* problem. This guy is optimized (the
string is modified "in place"), *and* the boundaries change during the
substitution.
Ilya
------------------------------
Date: 6 Oct 2001 13:54:24 -0700
From: codepilot@canada.com (CodePilot)
Subject: Converting graphic formats
Message-Id: <55b7d4d6.0110061254.443bc298@posting.google.com>
I'm looking for a way to convert graphic formats around using perl.
(eg. convert TIFF to JPG, etc). I'm pretty new to perl, and have
fumbled around the CPAN archive to no avail. This would seem like a
pretty common task, and I don't want to reinvent the wheel.
My most pressing conversion is to go from WFX (Winfax documents) to
TIFF. Any ideas?
CP
------------------------------
Date: Sat, 06 Oct 2001 17:12:34 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Converting graphic formats
Message-Id: <comdog-38EBAC.17123406102001@news.panix.com>
In article <55b7d4d6.0110061254.443bc298@posting.google.com>,
codepilot@canada.com (CodePilot) wrote:
> I'm looking for a way to convert graphic formats around using perl.
> (eg. convert TIFF to JPG, etc).
does PerlMagick work for you?
http://search.cpan.org/search?dist=PerlMagick
--
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Sat, 06 Oct 2001 23:48:35 GMT
From: "Code Pilot" <codepilot@canada.com>
Subject: Re: Converting graphic formats
Message-Id: <nLMv7.53826$L8.14970783@news2.rdc1.bc.home.com>
In article <comdog-38EBAC.17123406102001@news.panix.com>, "brian d foy"
<comdog@panix.com> wrote:
> In article <55b7d4d6.0110061254.443bc298@posting.google.com>,
> codepilot@canada.com (CodePilot) wrote:
>
>> I'm looking for a way to convert graphic formats around using perl.
>> (eg. convert TIFF to JPG, etc).
>
> does PerlMagick work for you?
>
> http://search.cpan.org/search?dist=PerlMagick
>
Partially. It will convert TIF to JPG, etc, but it doesn't understand
WFX files (Winfax). I've read that the SDK for Winfax has the ability
to program Winfax to convert to other formats, but I don't do Windows.
CP
------------------------------
Date: Sat, 06 Oct 2001 21:00:03 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Converting graphic formats
Message-Id: <3BBFA913.D7969AED@earthlink.net>
Code Pilot wrote:
>
> brian d foy" <comdog@panix.com> wrote:
>
> > codepilot@canada.com (CodePilot) wrote:
> >
> >> I'm looking for a way to convert graphic formats around using perl.
> >> (eg. convert TIFF to JPG, etc).
> >
> > does PerlMagick work for you?
> >
> > http://search.cpan.org/search?dist=PerlMagick
>
> Partially. It will convert TIF to JPG, etc, but it doesn't understand
> WFX files (Winfax). I've read that the SDK for Winfax has the ability
> to program Winfax to convert to other formats, but I don't do Windows.
This isn't a perl solution, but a google search:
http://www.google.com/search?q=WFX+winfax+convert
lists a number of programs which are able to understand wfx files, and
convert them to other formats.
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
Date: 6 Oct 2001 11:05:03 -0700
From: tommyumuc@aol.com (JR)
Subject: Re: Finding the difference between arrays...
Message-Id: <319333f5.0110061005.48863f07@posting.google.com>
mjd@plover.com (Mark Jason Dominus) wrote in message news:<3bbdd875.558$28a@news.op.net>...
> In article <319333f5.0110050602.5c0c210e@posting.google.com>,
> JR <tommyumuc@aol.com> wrote:
> >For the following array examples, how is it possible to determine the
> >difference? I can't use hashes, because in the actual arrays there
> >would be many duplicate keys, which aren't allowed in hashes.
>
> You can use the hashes to keep track of the number of times each item
> appears:
>
> for (@arrayOne) {
> ++$diff{$_};
> }
> for (@arrayTwo) {
> --$diff{$_};
> }
>
> # %diff now contains
> # ('01,001,000,0002' => 1,
> # '01,001,000,0003' => 1,
> # )
>
> for (sort keys %diff) {
> push @fallOut, ($_) x abs($diff{$_});
> }
>
> # @fallOut now contains:
> # ('01,001,000,0002', '01,001,000,0003');
> #
> # which is what you said you wanted
>
>
> If the arrays are both sorted, you can use the 'comm' procedure.
> 'comm' finds the lines in common and uses less memory than the hash
> technique above:
>
> my ($a1, $a2) = (0, 0);
> my @fallOut;
>
> while ($a1 < @arrayOne and $a2 < @arrayTwo) {
> my ($line1, $line2) = ($arrayOne[$a1], $arrayTwo[$a2]);
> if ($line1 lt $line2) {
> push @fallOut, $line1;
> ++$a1;
> } elsif ($line1 gt $line2) {
> push @fallOut, $line2;
> ++$a2;
> } else {
> ++$a1; ++$a2;
> }
> }
> while ($a1 < @arrayOne) {
> push @fallOut, $arrayOne[$a1++];
> }
> while ($a2 < @arrayTwo) {
> push @fallOut, $arrayTwo[$a2++];
> }
>
>
> Neither of these techniques destroys the original array.
>
> >I hope I've explained this problem reasonably well. I would
> >appreciate any help anyone may have.
>
> If you need more a more sophisticated view of the differences, you may
> want to look at the Algorithm::Diff module from CPAN.
Yes, both arrys will be sorted, so the 'comm' procedure should work
nicely. Thanks very much.
------------------------------
Date: Sun, 7 Oct 2001 08:14:28 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Goedel JAPH
Message-Id: <slrn9rv0i4.d6o.mgjv@martien.heliotrope.home>
On Sat, 6 Oct 2001 15:49:46 +0200,
Leopold Toetsch <lt@toetsch.at> wrote:
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>
>>> perl -l emits a newline. But nethertheless, without a newline, still
>>> the output would be printed on program termination.
>
>> Depends on the shell, terminal, and some other things. Anything that is
>> printed without a newline is not guaranteed to be visible.
>
> Ok I see, but you didn't give the -l switch, when testing the program.
> First line in my source was:
>
> #!/usr/bin/perl -lw
Whoops :}
Martien
--
Martien Verbruggen |
Interactive Media Division | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Sat, 06 Oct 2001 17:09:51 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: How to change date of a file
Message-Id: <comdog-73D165.17095106102001@news.panix.com>
In article <5dbrrtcl2mf99nbcescnsn7eh93f605qi0@4ax.com>, NOSPAM@mail.ru
wrote:
> On Sat, 06 Oct 2001 03:19:50 -0500, in comp.lang.perl.misc you wrote:
>
> >In article <s25rrtkm8s6evrgqpkkgv10lael19a1l9e@4ax.com>, NOSPAM@mail.ru
> >wrote:
> >
> >> I need to be able to change date of a file, using a perl script. Have
> >> no idea of the functions and params to call.
> >
> >perhaps you seek utime().
> >
> > http://www.perldoc.com/perl5.6.1/pod/func/utime.html
> Yes, but it doesn't work, the time is *not* changed :-(
ah, you didn't say you couldn't get it to work.
> #!/usr/bin/perl
> $now = time;
> $file = "/path/to/file.tst";
> utime $now, $now, $file;
what does the error variable $! say about it?
print "Error: $!\n";
--
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Sat, 06 Oct 2001 17:10:29 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: How to change date of a file
Message-Id: <comdog-BCAB58.17102906102001@news.panix.com>
In article <3bbf1b51$1@news.microsoft.com>, "Jürgen Exner"
<jurgenex@hotmail.com> wrote:
> <NOSPAM@mail.ru> wrote in message
> news:s25rrtkm8s6evrgqpkkgv10lael19a1l9e@4ax.com...
> > I need to be able to change date of a file, using a perl script. Have
> > no idea of the functions and params to call.
> Are you looking for
> system ("touch $thisfile");
nope. that will create the file if it does not exist. use
utime().
--
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Sat, 6 Oct 2001 18:44:43 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Open Test Failed
Message-Id: <slrn9ruk8q.16b.efflandt@typhoon.xnet.com>
On 6 Oct 2001 07:10:15 -0700, Jeff LaPlante <jlaplante1@hotmail.com> wrote:
> When running a Perl script i get the following error:
>
> open test failed: Value too large for defined data type
>
>
> Can anyone explain this phenomenon and to possibly fix it.
A code snippet that demonstrates the problem as a standalone script might
help determine the problem and allow someone to suggest a solution. There
are many types of open statements.
Note that $! will only contain a relavant value if the open was NOT
successful. If the open was successful, $! may have an arbitrary
(meaningless) value.
--
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sun, 7 Oct 2001 02:21:36 +0800
From: "Peter Chan" <peter.cch@mailexcite.com>
Subject: Perl to set cookie
Message-Id: <3bbf4b9b$1_1@news.tm.net.my>
I'm using Perl to set cookie in when someone is access my site.
But there is a very weird occurence.
When i run the script for the 1st time in a single window.
It will print a log to log file.
Then when i refresh the script, it will stop printing the log because the
script match the cookie that it was just create. I do this to avoid
repeatition log of the same people.
The problem is, the script run correctly if i directly run the script.
But when i put it as SSI - <!--#exec cgi="the_script_name.cgi"--> in a
*.shtml file.(My server support SSI)
It does not run like what I expected. It keep repeat and repeat to log the
same people.
Then i check it by a simple Perl script. I print the $ENV{HTTP_COOKIE}.
It wan empty ...... null for the value of that variable.
So, actually what is the problem that happen?
Why it run correctly if directly run the script but it doesnot when i use it
as SSI.?
Hopefully someone can help me.
Thanks alot.
By Peter
------------------------------
Date: Sat, 6 Oct 2001 19:14:09 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Perl to set cookie
Message-Id: <slrn9rum00.16b.efflandt@typhoon.xnet.com>
On Sun, 7 Oct 2001, Peter Chan <peter.cch@mailexcite.com> wrote:
> I'm using Perl to set cookie in when someone is access my site.
> But there is a very weird occurence.
>
> When i run the script for the 1st time in a single window.
> It will print a log to log file.
> Then when i refresh the script, it will stop printing the log because the
> script match the cookie that it was just create. I do this to avoid
> repeatition log of the same people.
>
> The problem is, the script run correctly if i directly run the script.
> But when i put it as SSI - <!--#exec cgi="the_script_name.cgi"--> in a
> *.shtml file.(My server support SSI)
> It does not run like what I expected. It keep repeat and repeat to log the
> same people.
>
> Then i check it by a simple Perl script. I print the $ENV{HTTP_COOKIE}.
> It wan empty ...... null for the value of that variable.
>
> So, actually what is the problem that happen?
> Why it run correctly if directly run the script but it doesnot when i use it
> as SSI.?
The browser apparently never sees the headers from SSI because that is
handled server side and only the contents embedded in the page. You can
'read' a cookie from SSI, but cannot write a cookie from there.
One possible solution is to do your logging from CGI used as a img src,
since that header will be passed to the browser. But you also have to
pass the contant-type and content of a valid image (which could be a 1
pixel transparent gif.).
What was your Perl question?
--
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sat, 06 Oct 2001 23:36:07 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl via metasend
Message-Id: <755vrtc1i300j89ho9gn6ddd20u45jmg2c@4ax.com>
Rodney wrote:
>How does one use MIME::Lite do send attachments? I have bee trying
>with no success using code in the Summer 1999 PERL Journal. I can get
>the mail sent only if I do not attempt attachments.
I haven't seen that code. I do it using the basic code in the POD. It
takes three steps:
1) Create the main message
2) Attach the attachments
3) Send the message.
What are you trying that fails?
--
Bart.
------------------------------
Date: 6 Oct 2001 18:03:35 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: quasi xml to xml
Message-Id: <1002391419.10@elaine.furryape.com>
In article <1002389568.7424@elaine.furryape.com>,
Alan Barclay <gorilla@elaine.furryape.com> wrote:
>Why the @array?
>
>Seems like it woule be better to use 'for $key (keys %array)'
I've worked it out. Jeff wants to preserve the original order of the
tags.
------------------------------
Date: Sat, 06 Oct 2001 16:34:01 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: resetting variables
Message-Id: <3BBF6AB9.E3315FA9@earthlink.net>
rolf deenen wrote:
>
> > Did you see my previous contribution to this thread?
>
> Well NoBull,
>
> I Did, but you must have miunderstood me. I am not using cgi.pm (in
> fact I don't even know what it is ).
Then you should learn what it is. Writing a CGI program without using a
prewritten CGI module of some sort is just asking for trouble -- so many
problems can occur with roll-your-own code, that module writers have
special handling to avoid, that it's just not worth it to not use a
module.
> I just am rying to learn perl
As in any type of programming, you want to *not* reinvent the wheel.
Learning to use modules [such as CGI.pm], is a large part of learning
how to use preexisting wheels in perl.
> and in the process i try to write a litte script that i can use in
> daily life. The script is supposed to store hyperlinks, like
> "bookmarks" but independend of the machine i work on. So it takes
> input (name, url, comment) and appends this to a file which is than
> layed out and printed to screen.
> The problem is that when i add a line via a form and i refresh this
> form, it adds the line again (which is logical, but not what i
> want...)
If your form use a CGI GET, then each time you reload the page, it
reissues the request to the server.
You have two options. One is to make it so that the user *doesn'*
accidentally reissue a request, the other is to make it so that
recieiving a second identical request doesn't result in a new entry.
To do the first, change the form from a GET to a POST. This way, if the
user presses 'reload', he'll be asked if he wants to repost the form
data. Clicking 'no' will prevent it from calling your script again and
adding a duplicate entry.
To do the second, change the script so that whenever a request is made
to add a new entry, it will first check if an instance of that entry
already exists in the bookmarks file, and if so, ignore the request.
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
Date: Sat, 06 Oct 2001 21:33:34 GMT
From: "Robert Petty" <bogus@mail.address.com>
Subject: tainted Perl on CGI question...
Message-Id: <OMKv7.285341$aZ.56292192@typhoon.tampabay.rr.com>
Ok, this may be off topic for this group. If it is please go easy on me and
advise me where to post it...
Oviewview for use:
-----------------------------------------------------------
I am writing a CGI for a friends site where she can copy
html from a program like AOL Press or Frontpage and
paste the html from the clipboard on her win98 machine
into a form text area in the browser. The CGI on the
backend allows her to post HTML which is then saved
into a specially named file for a weekly newsletter. This
is not rocket science, but I need to clean the data input to
ensure I don't open any security holes.
Question:
------------------------------------------------------------
Should I collect the entire stream from the textarea and parse
it against a list of allowed html tags or should I have a specific
list of tags to remove? Should I allow the textarea to contain
javascript (intended for client side via the resultant html page)?
Do you know of an example I can review to see how others
do this? Are there modules to do this?
I have searched but cannot find anything specifically suited to
this, but I know others are doing it because free user
homepages like angelfire others are allowing almost exactly
the same ability.
Thanks for your indulgence.
Robert
------------------------------
Date: Sat, 06 Oct 2001 14:44:41 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: tainted Perl on CGI question...
Message-Id: <3BBF7B49.A64EB740@vpservices.com>
Robert Petty wrote:
>
> ... The CGI on the
> backend allows her to post HTML which is then saved
> into a specially named file for a weekly newsletter. This
> is not rocket science, but I need to clean the data input to
> ensure I don't open any security holes.
I've never used it but you might start by looking on CPAN for:
HTML::CGIChecker - A Perl module to detect dangerous HTML code
--
Jeff
------------------------------
Date: Sat, 06 Oct 2001 22:04:50 GMT
From: "Robert Petty" <bogus@mail.address.com>
Subject: Re: tainted Perl on CGI question...
Message-Id: <6eLv7.285602$aZ.56327172@typhoon.tampabay.rr.com>
Thank you!
"Jeff Zucker" <jeff@vpservices.com> wrote in message
news:3BBF7B49.A64EB740@vpservices.com...
> Robert Petty wrote:
> >
> > ... The CGI on the
> > backend allows her to post HTML which is then saved
> > into a specially named file for a weekly newsletter. This
> > is not rocket science, but I need to clean the data input to
> > ensure I don't open any security holes.
>
> I've never used it but you might start by looking on CPAN for:
>
> HTML::CGIChecker - A Perl module to detect dangerous HTML code
>
>
> --
> Jeff
>
>
------------------------------
Date: Sat, 06 Oct 2001 16:09:57 -0400
From: Zimmen Gnauh <yah00204052@yahoo.com>
Subject: time transformation
Message-Id: <3BBF6515.FDCCBD78@yahoo.com>
What's the simplest way to tranform 12 hour format time into 24 hour
format, i.e.
9:20am ->9:20
12:30pm ->12:30
4:30pm ->16:30
------------------------------
Date: Sat, 06 Oct 2001 20:39:07 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: time transformation
Message-Id: <slrn9rurp5.88v.tim@vegeta.ath.cx>
Me parece que Zimmen Gnauh <yah00204052@yahoo.com> dijo:
> What's the simplest way to tranform 12 hour format time into 24 hour
> format, i.e.
> 9:20am ->9:20
> 12:30pm ->12:30
> 4:30pm ->16:30
if ($time =~ /^(1?\d):([0-5]\d)([ap])m$/i) {
($h, $m) = ($1, $2);
$h += 12 if $3 eq 'p' and $h < 12;
$time = sprintf "%02d:%02d", $h, $m;
}
...or something like that. Mess with the sprintf format if you don't
like the leading zero in the hours. (American) military time has a
leading zero.
HTH
--
/earth: file system full.
------------------------------
Date: Sat, 06 Oct 2001 21:31:17 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: time transformation
Message-Id: <3BBF76D2.4A29C8F3@acm.org>
Zimmen Gnauh wrote:
> What's the simplest way to tranform 12 hour format time into 24 hour
> format, i.e.
> 9:20am ->9:20
> 12:30pm ->12:30
> 4:30pm ->16:30
How about:
for (qw/12:30am 9:20am 12:00am 12:30pm 4:30pm 12:00pm/) {
print $_, " -> ", cvt ($_), "\n";
}
sub cvt {
my ($time) = @_;
if ($time =~ /^(1?\d):([0-5]\d)([ap])m$/i) {
my ($h, $m) = ($1, $2);
if (lc $3 eq 'p') {
$h += 12 if $h < 12 || $m == 0;
# $h %= 24; # uncomment if you prefer midnight to be 00:00
} else {
$h = 0 if $h == 12 && $m > 0;
}
$time = sprintf "%2d:%02d", $h, $m;
}
$time;
}
Most people follow the convention that 12:00am == noon and
12:00pm == midnight. The above code transforms midnight to
24:00, but you can change that to 0:00 as indicated.
-- Dave Tweed
------------------------------
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 1885
***************************************