[14045] in Perl-Users-Digest
Perl-Users Digest, Issue: 1455 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 22 06:05:39 1999
Date: Mon, 22 Nov 1999 03:05:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <943268714-v9-i1455@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 22 Nov 1999 Volume: 9 Number: 1455
Today's topics:
Re: "Genric" cookies: Need help!! <gary@2dgs.com>
Re: adjusting HTML <gisle@aas.no>
Re: Can Perl return the ASCII code for a given characte (David H. Adler)
Re: Catching STDOUT to an array <korjoan1@babylon.dat.tele.fi>
Re: Catching STDOUT to an array <rhomberg@ife.ee.ethz.ch>
Re: Encryption Algorithm for Perl Source Code?? - activ jut@letterbox.com
exists causes internal server errors!! <bunjonwa@trek.CS.ORST.EDU>
Re: exists causes internal server errors!! <slanning@bu.edu>
Re: Getting HTML tags via regular expression <gisle@aas.no>
Re: Getting HTML tags via regular expression (Abigail)
Re: Help w/ DBI <gellyfish@gellyfish.com>
Re: How to create file in other directory ? <slanning@bu.edu>
How write records to ASCII file <albert@netmation.com>
Re: How write records to ASCII file <rwhitfie@speedlink.com.au>
Re: How write records to ASCII file (Simon Cozens)
Re: Looking for Programmers <rwhitfie@speedlink.com.au>
Re: mailto:Idon'tThinkSo <jarrowwx@NOSPAM.home.com>
Re: newbie : looking for a script that reads all the f <xirdwbjrdac5clmskuqdcp3m41@proxymate.com>
Re: OT Y2K, was Re: Problematic horizontal scrollbars <gellyfish@gellyfish.com>
Passing a parameter does not work when it came from a l <dontemail@postresponses.com>
Re: Passing a parameter does not work when it came from <ron@savage.net.au>
Re: Passing a parameter does not work when it came from <lr@hpl.hp.com>
Re: perl script to change .htpasswd <gary@2dgs.com>
Perl Shopping Cart with Inventory? (Miles Burke)
Recursion Problem using my() <jegglest@my-deja.com>
Re: Testsuite Mac/cgi/perl (Hado Hein)
timelocal - strange result (Sergei Gnezdov)
Re: timelocal - strange result (Sam Holden)
Re: timelocal - strange result (Abigail)
Variable assignment confusion <silvenis@wavetech.net>
Re: Variable assignment confusion (Sam Holden)
Re: What is a good book on Perl (John McNamara)
Re: WINNT, Email, MS Outlook and MS Exchange (Jason L. James)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 22 Nov 1999 10:25:19 GMT
From: Gary Varnell <gary@2dgs.com>
Subject: Re: "Genric" cookies: Need help!!
Message-Id: <38391A4D.146166FB@2dgs.com>
Take a look at CGI.pm
Cookies are easily created and retrieved using this module,
including a list of cookies that your script has read access to.
Note: You should try to limit yourself to less cookies per site.
I try to limit myself to 2 cookies per site.
Some browsers limit the number of cookies per site.
If you have problems using CGI.pm let me know.
Gary V.
--
__________________________________________________________
Digital Graphics Studios (DGS)
----------------------------------------------------------
805 College ST. SE Lacey, WA. 98503
Website: http://www.2dgs.com Phone: (360) 491-1149
E-mail: mailto:Info@2dgs.com
------------------------------
Date: 22 Nov 1999 07:17:28 +0100
From: Gisle Aas <gisle@aas.no>
Subject: Re: adjusting HTML
Message-Id: <m33dtzrqx3.fsf@eik.g.aas.no>
abigail@delanet.com (Abigail) writes:
> I can see the lexical analyzer part, but I don't see where HTML::Parser
> parses. All it does is making call backs on encountering _tokens_,
> but never on any syntactical constructs.
One way to see this is to think of "<img src='foo' ismap>" as
consisting of the tokens:
STAGO name name VI string name TAGC
"<" "img" "src" "=" "'foo'" "ismap" ">"
Collecting this sequence of tokens as a valid start tag is then
parsing and the reason the SGML standard define _parser_ they way it
does.
> And last time I checked, it was unware of CDATA declared content. Which
> is a requirement to even tokenize HTML.
The new XS based implementation does not have this problem.
--
Gisle Aas
------------------------------
Date: 22 Nov 1999 00:42:33 -0500
From: dha@panix.com (David H. Adler)
Subject: Re: Can Perl return the ASCII code for a given character?
Message-Id: <slrn83hlu6.4vc.dha@panix.com>
On 20 Nov 1999 05:34:25 -0600, Abigail <abigail@delanet.com> wrote:
>use constant VIII => sub {die "Blake only had seven.\n"};
I hang out in only two irc channels, one is #perl, the other is (in
theory, at least) about british SF television. I would like to thank
Abigail for bridging that gap for me...
:-)
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"I think I'd better sit down."
"You are sitting down."
"Oh. Good for me."
- Buffy the Vampire Slayer, "Welcome to the Hellmouth"
------------------------------
Date: Mon, 22 Nov 1999 09:57:02 GMT
From: Antti-Jussi Korjonen <korjoan1@babylon.dat.tele.fi>
Subject: Re: Catching STDOUT to an array
Message-Id: <Or8_3.78$nZ1.3133@read2.inet.fi>
lee.lindley@bigfoot.com wrote:
> Antti-Jussi Korjonen <Antti-Jussi.Korjonen@sonera.com> wrote:
> :>Hi!
> :>Is it possible to redirect STDOUT or STDERR to an array without
> :>having to circle it through a file?
> Yes. `perldoc perlop` and page down to the section on `STRING`
> (if you are searching, include the backquotes).
> my @array = `some_command 2>&1`;
> However, if you are talking about a command that you are opening
> as a writable pipe, then the answer is more complex.
> `perldoc -q stderr` brings up quite a bit on this topic.
I'm not executing a shell command...
I'm using perlmenu & SNMP modules.
Doing this
&SNMP::addMibFiles($self->{MibFile});
When some mibs don't exist, it gives an error message and
it just goes by, because I'm using perlmenu.
So I would need to redirect STDERR and possibly STDERR
to an array to figure out, if everything went ok and if
not display the contents of the array.
--
__/ __/ __/ __/ Antti-Jussi Korjonen
__/ __/ __/ __/ __/__/ Kaarikatu 15-17 A9
__/ __/ __/ __/ __/__/ 33100 TAMPERE, FINLAND
__/ __/ __/__/__/ __/ __/ tel. +358-(0)40-538 5730
Antti-Jussi.Korjonen@sonera.com
------------------------------
Date: Mon, 22 Nov 1999 11:08:26 +0100
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Catching STDOUT to an array
Message-Id: <3839161A.A562DA58@ife.ee.ethz.ch>
Antti-Jussi Korjonen wrote:
>
> Hi!
>
> Is it possible to redirect STDOUT or STDERR to an array without
> having to circle it through a file?
I don't think so. AFAIK STDOUT and STDERR must be filehandles. But you
could make a workaround (depending on your OS) by using a pseudo-file
such as a named pipe or so.
- Alex
PS: Unlike the other answerers, I assume you mean what you write. Which
is clearly not the output of an other command.
------------------------------
Date: Mon, 22 Nov 1999 05:36:15 GMT
From: jut@letterbox.com
Subject: Re: Encryption Algorithm for Perl Source Code?? - activator.cgi (0/1)
Message-Id: <3838d61c.7381436@news.singnet.com.sg>
Probable all three (four) of the above?
<shrug>
On Sun, 21 Nov 1999 19:36:39 -0800, Larry Rosler <lr@hpl.hp.com>
wrote:
>In article <3838a3ab.8577083@news.singnet.com.sg> on Mon, 22 Nov 1999
>02:03:03 GMT, jut@letterbox.com <jut@letterbox.com> says...
>> Oh yeah, I looked up the documentation for it. I did use the -MO
>> switch.
>>
>> I think the best way is still to post it up here, so whoever's
>> interested can have a crack at it. Although it's technivally
>> commercial software, they've got demo versions on their website, so I
>> don't think I'm infringing any copyrights here.
>>
>> On Sun, 21 Nov 1999 20:00:03 GMT, *@dragons.duesouth.net (Matthew
>> Bafford) wrote:
>>
>> >[Please place your replies below the message you are replying to. This
>> > lets people quickly glance over the previous message and freshen up on
>> > what's going on.]
>> >
>>
>> Sorry, I'm kinda new to this.
>
>And responding directly after that suggestion from Matthew Bafford, you
>still go on to quote dozens of lines of stuff on which you commented
>above the message. It's hard to decide whether you are blind or dumb,
>malicious or stupid.
>
Don't see how calling names solves anything!
>> >On Sun, 21 Nov 1999 17:35:44 GMT, jut@letterbox.com poured coffee onto a
>> >keyboard, producing the following in comp.lang.perl.misc:
>
>...
------------------------------
Date: Sun, 21 Nov 1999 22:10:53 -0800
From: Waranun Bunjongsat <bunjonwa@trek.CS.ORST.EDU>
Subject: exists causes internal server errors!!
Message-Id: <Pine.GSO.4.03.9911212206120.7603-100000@trek.CS.ORST.EDU>
Hi,
Now, I managed to get the dbmopen() works the db is not DB_File
but it is something with *.dir and *.pag. Do not know what type of
database because I use 'use AnyDBM_File;', and use
dbmopen(%myhash,'filename', 0644); However when I do ...
$myquery = "myname";
if(exists $myhash{$myquery}){
...
}
It causes internal compilation error, Anyboby could tell me why ?
Thanks in advance,
--
____________________________________________________________________________
Waranun Bunjongsat tel: 541-343-5970
Graduate Student e-mail: bunjonwa@cs.orst.edu
Department of Computer Science homepage:http://www.cs.orst.edu/~bunjonwa
Oregon State University
____________________________________________________________________________
------------------------------
Date: 22 Nov 1999 02:41:17 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: exists causes internal server errors!!
Message-Id: <kusemdj6kip.fsf@strange.bu.edu>
Waranun Bunjongsat <bunjonwa@trek.CS.ORST.EDU> writes:
> It causes internal compilation error, Anyboby could tell me why ?
I assume this is a CGI question, which I, and probably a couple
others, will point out belongs in comp.infosystmes.www.authoring.cgi
or another CGI-related group.
If you add the -c switch, like
#!/usr/local/bin/perl -wc
use strict;
then run your program from the command line, perl might tell
you the error.
If you don't have access to the server error logs, then put
use CGI qw(fatalsToBrowser);
near the beginning of your program, then, after you got a
'syntax OK' from the -c switch (don't forget to remove it
when you run from browser) the runtime error will be displayed
in your browser.
--
qualification: I'm a dimwit according to someone who emailed me
------------------------------
Date: 22 Nov 1999 07:21:07 +0100
From: Gisle Aas <gisle@aas.no>
Subject: Re: Getting HTML tags via regular expression
Message-Id: <m3yabrqc6k.fsf@eik.g.aas.no>
abigail@delanet.com (Abigail) writes:
> It will get most pages that use javascript to generate markup wrong.
> Which isn't uncommon at all.
>
>
> <SCRIPT>
> document.write ("<BR>");
> </SCRIPT>
>
> will trigger 2 calls to "start", one call to "end", and 2 calls to
> "text", while a real HTML tokenizer would see 3 tokens: the SCRIPT
> begin tag, a CDATA section (for which there isn't a call back at all
> in HTML::Parser), and the end tag for SCRIPT.
This problem is fixed in the new XS based HTML::Parser. CDATA is
signaled with an extra boolean parameter to the text handler.
--
Gisle Aas
------------------------------
Date: 22 Nov 1999 01:53:48 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Getting HTML tags via regular expression
Message-Id: <slrn83htqi.m2v.abigail@alexandra.delanet.com>
Gisle Aas (gisle@aas.no) wrote on MMCCLXXIV September MCMXCIII in
<URL:news:m3yabrqc6k.fsf@eik.g.aas.no>:
$$ abigail@delanet.com (Abigail) writes:
$$
$$ > It will get most pages that use javascript to generate markup wrong.
$$ > Which isn't uncommon at all.
$$ >
$$ >
$$ > <SCRIPT>
$$ > document.write ("<BR>");
$$ > </SCRIPT>
$$ >
$$ > will trigger 2 calls to "start", one call to "end", and 2 calls to
$$ > "text", while a real HTML tokenizer would see 3 tokens: the SCRIPT
$$ > begin tag, a CDATA section (for which there isn't a call back at all
$$ > in HTML::Parser), and the end tag for SCRIPT.
$$
$$ This problem is fixed in the new XS based HTML::Parser. CDATA is
$$ signaled with an extra boolean parameter to the text handler.
I used CPAN.pm to install the latest HTML::Parser (2.25) just before
writing the above posting, and it still triggered on strings looking like
tokens inside CDATA.
Abigail
--
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
for (s;s;s;s;s;s;s;s;s;s;s;s)
{s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 22 Nov 1999 10:02:49 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Help w/ DBI
Message-Id: <383914c9_1@newsread3.dircon.co.uk>
Adam Levenstein <che@worker.com> wrote:
> On 21 Nov 1999 12:57:16 -0000, Jonathan Stowe
> <gellyfish@gellyfish.com> wrote:
>>> $dbh->do("INSERT INTO sublets VALUES ('$loc, $roomies, $ownroom),
>>> $rent, $deposit, $utilities, $parking, $pets, $name, $email, $phone,
>>> $description')", undef, $dbh->quote("number"), $dbh->quote("name"));
>>>
>>
>>The first parameter to do() does not appear to be a correct SQL statement
>>you appear to b trying to inserting a single value your row here - I
>>dont understand what those two single quotes and the unmatched ) after
>>$ownroom are doing - I would recommend that you check the success of
>>the do() and print $dbh->errstr if it fails :
>
> The first ")" is a typo. Basically I'm trying to input a set of values
> from the form (hence the $variables) and add it to the db. "undef" and
> onward I got from a DBI page; I'm not sure if it's necessary.
>
Well if you dont know what they are for leave them out - that still leaves
the unwanted single quotes and the fact that you left all the string values
unquotes (necesaary in SQL) - I really do recommend that you take my advice
about checking the success of the do() and printing the error.
/J\
--
"Two or three of our staff were stoned on their way to work" - British
Airways Spokesman
------------------------------
Date: 22 Nov 1999 00:39:13 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: How to create file in other directory ?
Message-Id: <kus7ljbt79a.fsf@bottom.bu.edu>
abigail@delanet.com (Abigail) writes:
> s/foo|bar|baz/"is_$&"->()/eg while<>;
Kewl!
------------------------------
Date: Mon, 22 Nov 1999 01:19:19 -0800
From: "Al Franz" <albert@netmation.com>
Subject: How write records to ASCII file
Message-Id: <81b1k1$45u$1@eskinews.eskimo.com>
Are there public domain perl scripts to write data and/or retrieve data
from ascii files?
------------------------------
Date: Mon, 22 Nov 1999 21:23:08 +1100
From: Stephen J Whitfield <rwhitfie@speedlink.com.au>
Subject: Re: How write records to ASCII file
Message-Id: <3839198B.8A4EEB20@speedlink.com.au>
Al Franz wrote:
> Are there public domain perl scripts to write data and/or retrieve data
> from ascii files?
#!/usr/bin/perl -w
use strict;
my $filename = "ascii.txt";
my $line_num = 0;
# write data
open FILE, >>$filename or die "Could not open $filename: $!";
print FILE "data\n";
close FILE || die "Could not close $filename: $!";
# retrieve data
open FILE, $filename or die "Could not open $filename: $!";
while (<FILE>) {
if (/data/) {
print "data found on line $line_num";
}
$line_num++;
}
close FILE || die "Could not close $filename: $!";
Of course, if you can't be bothered to look up how to do this yourself, you
may as well quit now.
--
---------------------------------------------------------
Stephen Whitfield
------------------------------
Date: 22 Nov 1999 10:56:34 GMT
From: simon@brecon.co.uk (Simon Cozens)
Subject: Re: How write records to ASCII file
Message-Id: <slrn83i8b2.u8p.simon@othersideofthe.earth.li>
Stephen J Whitfield (comp.lang.perl.misc):
>close FILE || die "Could not close $filename: $!";
^^
It'll get you one day.
--
Different all twisty a of in maze are you, passages little.
------------------------------
Date: Mon, 22 Nov 1999 21:46:30 +1100
From: Stephen J Whitfield <rwhitfie@speedlink.com.au>
Subject: Re: Looking for Programmers
Message-Id: <38391F06.FCF399D4@speedlink.com.au>
info@perlscan.com wrote:
> Hi all,
>
> PerlCoders is currently looking for CGI programmers to work on several new projects that we have in the works. If you have the high skill levels we are looking for then contact us via email with your resume/qualifications at info@perlcoders.com
PerlCoders is also looking for a newsreader that handles wordwrap.
> Thanks,
And your perl question is?
> William Cross
> PerlCoders
--
---------------------------------------------------------
Stephen Whitfield
------------------------------
Date: Mon, 22 Nov 1999 05:31:08 GMT
From: John Arrowwood <jarrowwx@NOSPAM.home.com>
Subject: Re: mailto:Idon'tThinkSo
Message-Id: <3838D543.C423FB9F@NOSPAM.home.com>
styxx wrote:
> So I am writing a reply perl script. And in the perlscript I want my
> recipients to send me suggestions, if they please. But when I write the HTML
> contents in the
> content-type: text/html\n\n;
> print<<__end;
> <html>so on and so forth
>
> __end
>
> I try and include a \<a \href="mailto:me@mysite.com\> (without the escape
> characters, of course). however the perl script will not accept the mailto.
> Even if I create form and set the "Action" equal to the mailto:address, the
> script will not accept it. Any suggestions?
Start by turning on -w in perl then running from the command-line. You will
PROBABLY (but not guaranteed) see that perl doesn't like you putting an @ sign
that is unescaped. Why? Because it thinks you're referring to an array
variable. Prefix the @ with a backslash and it MIGHT work. I say might
because I can't predict what other problems might be lurking... :)
-- John
------------------------------
Date: 21 Nov 1999 04:50:10 -0500
From: G. Asch <xirdwbjrdac5clmskuqdcp3m41@proxymate.com>
Subject: Re: newbie : looking for a script that reads all the file names in the directory
Message-Id: <m2emdkrx65.fsf@spinoza.ash>
Bob Walton <bwalton@rochester.rr.com> writes:
BW> jim and lois flaherty wrote:
>> I am looking for a perl script the reads the names of all the
>> files in a directory , then I can make the script to build a html
>> page
BW> ...
>> Jim
BW> @file_names_in_current_directory=<*.*>;
^^^^^
actually I believe it should be <*>,
but is the poster aware that html indexs are created
automatically e.g. file:///current_directory/. ?
--
_________________________________________________________
Gabriel Asch
Email: xirdwbjrdac5clmskuqdcp3m41@proxymate.com
!!! Note: to foil spammers,
if you reply by email, your message must either contain a
proper Reference header or you must quote !this line!
"in a sense, you are already dead"
J. L. Borges
________________________________________________________
------------------------------
Date: 22 Nov 1999 09:53:08 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: OT Y2K, was Re: Problematic horizontal scrollbars
Message-Id: <38391284_1@newsread3.dircon.co.uk>
In comp.lang.perl.misc Alan J. Flavell <flavell@mail.cern.ch> wrote:
>
> I know this was "only" your sig, but IMNSHO this needs refuting.
>
> On Sun, 21 Nov 1999, Dave Eastabrook wrote:
>
>> Did you know there was a problem with Perl and JavaScript? Well,
>> http://www.elmbronze.co.uk/year2000/perlprob.htm is a tiny taster.
>
> There is _NO_ Y2K problem with Perl. Its behaviour is clearly
> documented for anyone who cares to RTFM, and it is entirely consistent.
>
> There are *big* problems with badly-written Perl scripts, of which their
> Y2K muddle is probably only a tiny part.
>
I am amused that this page cites two of my clpm articles ... Interestingly
both of which go to some lengths to make the point that the misuse of
(localtime)[5] is a symptom of wider bad programming practice that can
be found in the bulk of Matt Wrights output ...
/J\
--
"Enter the Great Jaffa Cakes Debate. In these jam-filled concoctions
were cakes they would escape VAT. Because they are soft and not hard,
they were deemed to be cakes and therefore VAT free. In 1974 Master of
the Universe asked the VAT tribunal to exempt him from VAT because he
is the Supreme Authority in the Universe and therefore should not pay
it. He lost his case" - BBC News Website
------------------------------
Date: Mon, 22 Nov 1999 06:18:09 GMT
From: "Steve Poulsen" <dontemail@postresponses.com>
Subject: Passing a parameter does not work when it came from a list.
Message-Id: <Be5_3.2640$f5.143837@server1.news.adelphia.net>
I am taking a list and getting a variable from it. Then when I make a copy,
modify it, and use it as a destination filename for the rename subroutine.
This fails (since its CGI I can't see why it failed). So, I print out the
filename and get what I expect. So I just hardcode the variable to this
name and it all works. For some reason, getting it from a list and
modifying it creates a problem. Anyone know why this is? I have checked
FAQs, MANS, and everything I could find.
Thanks,
Steve
Small but entire script follows.
#!/usr/local/bin/perl -Tw
require "./cgi-lib.pl";
MAIN:
{
my (%cgi_data, # The form data
%cgi_cfn, # The uploaded file(s) client-provided name(s)
%cgi_ct, # The uploaded file(s) content-type(s). These are
# set by the user's browser and may be unreliable
%cgi_sfn, # The uploaded file(s) name(s) on the server (this
machine)
$ret, # Return value of the ReadParse call.
$buf, # Buffer for data read from disk.
$newfile, # New filename
);
$cgi_lib::writefiles = "symbols";
$cgi_lib::maxdata = 500000;
# Start off by reading and parsing the data. Save the return value.
# Pass references to retreive the data, the filenames, and the
content-type
$ret = &ReadParse(\%cgi_data,\%cgi_cfn,\%cgi_ct,\%cgi_sfn);
if (!defined $ret) {
&CgiDie("Error in reading and parsing of CGI input");
} elsif (!$ret) {
&CgiDie("Missing parameters\n",
"Please complete the form <a href='fup.html'>fup.html</a>.\n");
} elsif (!defined $cgi_data{'upfile'} or !defined
$cgi_data{'description'}) {
&CgiDie("Data missing\n",
"Please complete the form <a href='fup.html'>fup.html</a>.\n");
}
#############################
# HERE BEGINS THE PROBLEM
#############################
# $newfile is the client filename and is C:\path\grep.zip
$newfile = $cgi_cfn{'upfile'};
$newfile =~ s/^.*\\([^\\]*)$/symbols\/$1/;
# at this point, $newfile is symbols/grep.zip as the following line prints
out.
print "Renaming from $cgi_sfn{'upfile'} to $newfile \n";
# If I hardcode the file name, the following rename works. Otherwise,
something goes wrong
# $newfile = "symbols/grep.zip";
rename $cgi_sfn{'upfile'},$newfile or
print("Unable to rename file $cgi_sfn{'upfile'} to $newfile\n");
#############################
# END OF THE PROBLEM
#############################
print "<hr>File $cgi_data{'upfile'} has now been renamed\n";
}
------------------------------
Date: Mon, 22 Nov 1999 18:34:20 +1100
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Passing a parameter does not work when it came from a list.
Message-Id: <Wq6_3.7109$MZ.54831@ozemail.com.au>
Steve,
Several things come to mind. See below.
--
Cheers
Ron & Pen Savage
ron@savage.net.au pen@savage.net.au
http://savage.net.au/index.html
[snip]
>
> #!/usr/local/bin/perl -Tw
>
> require "./cgi-lib.pl";
Oh, dear. cgi-lib.pl is _ancient_ software technology, seriously. Upgrade to
'use CGI;' immediately, please.
>
> MAIN:
> {
> my (%cgi_data, # The form data
> %cgi_cfn, # The uploaded file(s) client-provided name(s)
> %cgi_ct, # The uploaded file(s) content-type(s). These are
> # set by the user's browser and may be unreliable
> %cgi_sfn, # The uploaded file(s) name(s) on the server (this
> machine)
> $ret, # Return value of the ReadParse call.
> $buf, # Buffer for data read from disk.
> $newfile, # New filename
> );
>
> $cgi_lib::writefiles = "symbols";
> $cgi_lib::maxdata = 500000;
>
> # Start off by reading and parsing the data. Save the return value.
> # Pass references to retreive the data, the filenames, and the
> content-type
> $ret = &ReadParse(\%cgi_data,\%cgi_cfn,\%cgi_ct,\%cgi_sfn);
>
> if (!defined $ret) {
> &CgiDie("Error in reading and parsing of CGI input");
> } elsif (!$ret) {
> &CgiDie("Missing parameters\n",
> "Please complete the form <a href='fup.html'>fup.html</a>.\n");
> } elsif (!defined $cgi_data{'upfile'} or !defined
> $cgi_data{'description'}) {
> &CgiDie("Data missing\n",
> "Please complete the form <a href='fup.html'>fup.html</a>.\n");
> }
>
> #############################
> # HERE BEGINS THE PROBLEM
> #############################
> # $newfile is the client filename and is C:\path\grep.zip
>
> $newfile = $cgi_cfn{'upfile'};
> $newfile =~ s/^.*\\([^\\]*)$/symbols\/$1/;
> # at this point, $newfile is symbols/grep.zip as the following line prints
> out.
>
> print "Renaming from $cgi_sfn{'upfile'} to $newfile \n";
>
> # If I hardcode the file name, the following rename works. Otherwise,
> something goes wrong
> # $newfile = "symbols/grep.zip";
>
> rename $cgi_sfn{'upfile'},$newfile or
> print("Unable to rename file $cgi_sfn{'upfile'} to $newfile\n");
I suggest "rename ($cgi_sfn{'upfile'},$newfile) or ...". That way, you'll
never get caught by confusion over the relative precedence of 'comma' and
'or'.
> #############################
> # END OF THE PROBLEM
> #############################
> print "<hr>File $cgi_data{'upfile'} has now been renamed\n";
> }
Here, why don't you say "renamed $newfile", to see what the result is?
------------------------------
Date: Mon, 22 Nov 1999 00:18:08 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Passing a parameter does not work when it came from a list.
Message-Id: <MPG.12a29c16a51414df98a24e@nntp.hpl.hp.com>
In article <Wq6_3.7109$MZ.54831@ozemail.com.au> on Mon, 22 Nov 1999
18:34:20 +1100, Ron Savage <ron@savage.net.au> says...
...
> > $newfile = $cgi_cfn{'upfile'};
> > $newfile =~ s/^.*\\([^\\]*)$/symbols\/$1/;
> > # at this point, $newfile is symbols/grep.zip as the following line prints
> > out.
> >
> > print "Renaming from $cgi_sfn{'upfile'} to $newfile \n";
> >
> > # If I hardcode the file name, the following rename works. Otherwise,
> > something goes wrong
> > # $newfile = "symbols/grep.zip";
> >
> > rename $cgi_sfn{'upfile'},$newfile or
> > print("Unable to rename file $cgi_sfn{'upfile'} to $newfile\n");
>
> I suggest "rename ($cgi_sfn{'upfile'},$newfile) or ...". That way, you'll
> never get caught by confusion over the relative precedence of 'comma' and
> 'or'.
The code is correct as written, and the compiler isn't "caught by
confusion over the relative precedence of 'comma' and 'or'". So this
isn't the problem.
I would suggest including $! in the diagnostic, so the OS can tell you
what is wrong with the rename. I would also examine the contents of
$cgi_sfn{upfile} and $newfile after the substitution very carefully --
using length() and perhaps a hex dump, and putting delimiting characters
in the printout. Perhaps there is whitespace at the end of the input
parameter, so it doesn't match the real name of the file.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 22 Nov 1999 10:45:42 GMT
From: Gary Varnell <gary@2dgs.com>
Subject: Re: perl script to change .htpasswd
Message-Id: <38391F12.7412D304@2dgs.com>
The .htpasswd file just contains a list formatted like so:
username:cryptedpassword
To change the password for a user just read the htpasswd file
into a hash so that each username is a key and the password is the
value.
To generate the new password for userx just crypt it
say the new password for Fred contained in $newpass
my $npass = crypt ("$newpass","$newpass");
$htpasswd{'Fred'}=$npass;
now you can print the hash back out to .htpasswd
Hope this helps you out.
Gary V.
--
__________________________________________________________
Digital Graphics Studios (DGS)
----------------------------------------------------------
805 College ST. SE Lacey, WA. 98503
Website: http://www.2dgs.com Phone: (360) 491-1149
E-mail: mailto:Info@2dgs.com
------------------------------
Date: Mon, 22 Nov 1999 13:41:45 +0800
From: miles@scoop.nospamplease.com.au (Miles Burke)
Subject: Perl Shopping Cart with Inventory?
Message-Id: <miles-2211991341450001@192.168.1.2>
Hi Folks,
I have spent the better part of today searching for a perl based shopping
cart that allows for an inventory, ie: part X with 10 remaining, sell one
it becomes nine remaining, etc and when it gets to zero, removes the part
from the list.
Anyone seen anything like it? It only needs to handle perhaps 50 items at
any one period, but needs to be able to have an inventory...I expected to
find one with no trouble, but alas, neither free nor commercial ones can
be found (maybe good idea for perl expert to write?).
Please remove 'nospamplease' from my address to email me.
Cheers!
Miles.
------------------------------
Date: Mon, 22 Nov 1999 08:53:30 GMT
From: Jason Eggleston <jegglest@my-deja.com>
Subject: Recursion Problem using my()
Message-Id: <81b0a9$j20$1@nnrp1.deja.com>
I've read through all of the FAQs I could find, and all of the usenet
discussions I could find.
The following script will produce this on the call before it dies:
Range: 800b44fd-803f1f04 Max: 800b44a1-80fc8703
a LMIN: 80000000, LMAX: 803fffff, MASK: ffc00000
SCALAR(0x80e58b8)
b LMIN: 80000000, LMAX: 803fffff, MASK: ffc00000
SCALAR(0x80e58b8)
c LMIN: 80000000, LMAX: 801fffff, MASK: ffe00000
SCALAR(0x80e58b8)
{cut middle out}
Range: 80200000-803f1f04 Max: 80200000-80fc8703
a LMIN: 80200000, LMAX: 803fffff, MASK: ffe00000
SCALAR(0x80ea1d4)
b LMIN: 80000000, LMAX: 801fffff, MASK: ffe00000
SCALAR(0x80e9f58)
c LMIN: 80100000, LMAX: 801fffff, MASK: fff00000
SCALAR(0x80e9f58)
Spin off Lower
Died at ./test.pl line 12.
Now, with the first call of the function, $localmin refers to the same
variable both inside and outside of the while() loop. By the last
call, the variables refer to different values... values of previous
function calls!
Is there something I have to do to re-bind the variables in the while()
loop to the correct values?
#!/usr/bin/perl -w
use strict;
&GetRange(0x800b44fd, 0x803f1f04, 0x800b44a1, 0x80fc8703);
sub GetRange {
my($rangemin, $rangemax, $min, $max) = @_;
my($data, $mask, $localmin, $localmax, $oldlocalmin, @nets);
my($bits) = 32;
die if($rangemin > $rangemax || $min > $max);
printf("Range: %08x-%08x Max: %08x-%08x\n", $rangemin, $rangemax,
$min, $max);
$data = $rangemin ^ $rangemax;
$mask = -1;
while($data) {
$mask <<= 1;
$data >>= 1;
$bits--;
}
$localmin = $rangemin & $mask;
$localmax = $localmin | ~$mask;
printf("a LMIN: %08x, LMAX: %08x, MASK: %08x\n", $localmin,
$localmax, $mask);
print \$localmin, "\n";
while(($localmin < $min) or ($localmax > $max)) {
printf("b LMIN: %08x, LMAX: %08x, MASK: %08x\n", $localmin,
$localmax, $mask);
print \$localmin, "\n";
$mask >>= 1;
$mask |= 1 << 31;
$oldlocalmin = $localmin;
$localmin = $rangemin & $mask;
$localmax = $localmin | ~$mask;
printf("c LMIN: %08x, LMAX: %08x, MASK: %08x\n", $localmin,
$localmax, $mask);
print \$localmin, "\n";
if($oldlocalmin == $localmin) {
if($localmax+1 <= $rangemax) {
print "Spin off Upper\n";
push @nets, &GetRange($localmax+1, $rangemax,
$localmax+1, $max);
}
else {
print "Spin off Upper not necessary.\n";
}
}
else {
print "Spin off Lower\n";
unshift @nets, &GetRange($rangemin, $localmin-1, $min,
$localmin-1);
}
}
push @nets, sprintf("%08x/%d", $localmin, $bits);
return @nets;
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 22 Nov 1999 06:33:47 +0100
From: Hado.Hein@gmx.net (Hado Hein)
Subject: Re: Testsuite Mac/cgi/perl
Message-Id: <1e1nr0i.sr3z701chumy5N@p3e9ebbab.dip.t-dialin.net>
> References: <1e1j9zc.13rpxbq1dmrrbcN@p3e9eb8ac.dip.t-dialin.net>
> From: kragen@dnaco.net (Kragen Sitaker)
> > What tool to use for that ? MacPerl or somethig from stairways.com ?
>
> Perhaps you should ask this question somewhere where people know what
> "NetPresenz" and "stairways.com" are.
Well, I just stated the stuff I run my Perl on. If it is not yours... I
did not see seperated groups for the usual platforms. For the Mac's
these are the tools to run Perl.
jakal <jakem@camtech.net.au> wrote:
> I am not familiar with NetPresenz, but I use WebStar (a web server) and
> MacPerl on a Macintosh.
NetPresenz is the shareware version of WebStar.
> You need to save the Perl scripts as CGI scripts. Choose 'save as' from
> within MacPerl. Webstar requires the scripts to have a .acgi extensions,
> NetPresenz may do the same.
>
> Hope this helps,
It did exactly. thx.
Anyhow the script does not run - but thats not the problem.
--
Hado Hein, Berlin, Fed. Rep. of Germany
find PGP and http in Headers
------------------------------
Date: 22 Nov 1999 05:56:59 GMT
From: sergeiga@hotpop.com (Sergei Gnezdov)
Subject: timelocal - strange result
Message-Id: <8E5613B03sergeigahotpopcom@news.mindspring.com>
The following code:
#####
my $SEC_PER_DAY = 86400; # 60sec * 60min * 24hour = 86400sec
...
my @days;
$_ = $date_1;
print "\$date_1 = $date_1, localtime = ".localtime($date_1)."\n";
while ($_ < $date_2) {
push @days, (localtime $_)[3];
$_ += $SEC_PER_DAY;
}
print "days: @days\n";
exit;
#####
produces the following output:
$date_1 = 940737600, localtime = Sun Oct 24 00:00:00 1999
days: 24 25 26 27 28 29 30 31 31 1 2 3 4
^ ^
duplicate days
The number 31 printed twice.
I don't want to have 31 to be printed twice.
What is wrong here?
Thanks
------------------------------
Date: 22 Nov 1999 06:07:48 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: timelocal - strange result
Message-Id: <slrn83hne8.4kh.sholden@pgrad.cs.usyd.edu.au>
On 22 Nov 1999 05:56:59 GMT, Sergei Gnezdov <sergeiga@hotpop.com> wrote:
>The following code:
>
>#####
>my $SEC_PER_DAY = 86400; # 60sec * 60min * 24hour = 86400sec
What is wrong with just writing 60*60*24.
This is perl not assembler...
>...
>my @days;
>$_ = $date_1;
>print "\$date_1 = $date_1, localtime = ".localtime($date_1)."\n";
>while ($_ < $date_2) {
> push @days, (localtime $_)[3];
> $_ += $SEC_PER_DAY;
>}
>print "days: @days\n";
>exit;
>#####
>
>produces the following output:
>
>$date_1 = 940737600, localtime = Sun Oct 24 00:00:00 1999
>days: 24 25 26 27 28 29 30 31 31 1 2 3 4
> ^ ^
> duplicate days
>
>The number 31 printed twice.
>I don't want to have 31 to be printed twice.
Daylight saving? Just a guess.
It works fine for me (though my localtime is 14 hours after yours)...
--
Sam
Perl is the Cliff Notes of Unix.
--Tom Christiansen
------------------------------
Date: 22 Nov 1999 01:59:24 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: timelocal - strange result
Message-Id: <slrn83hu53.m2v.abigail@alexandra.delanet.com>
Sergei Gnezdov (sergeiga@hotpop.com) wrote on MMCCLXXIV September
MCMXCIII in <URL:news:8E5613B03sergeigahotpopcom@news.mindspring.com>:
^^
^^ my $SEC_PER_DAY = 86400; # 60sec * 60min * 24hour = 86400sec
^^ ...
^^ What is wrong here?
The assumption that every day has 86400 seconds, that's what's wrong.
On certain places, twice a year, a day doesn't have 86400 seconds,
but 3600 more, or less.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sun, 21 Nov 1999 23:22:34 -0600
From: Eric Lengvenis <silvenis@wavetech.net>
Subject: Variable assignment confusion
Message-Id: <3838D31A.D29250F@wavetech.net>
I have looked hard for the answer to this before I posted, so forgive me
if it is obvious. I can't figure out where the two variables $f and $d
get their values. I am trying to read someone else's code (the solitaire
encryption code from Neal Stephenson's Cryptonomicon) and I understood
everything but the third line. The program references these variables,
but I never see them assigned anything. I understand that it is an
if..then..else, and I assume the value -1 or 1 is assigned $_.
#!/usr/bin/perl -s
die "Usage: $0 [-d] 'key phrase' [infile ...]\n" unless $#ARGV >=0;
$f=$d ? -1 : 1;
<snip> # next reference is...
if(!$d){do some things}
------------------------------
Date: 22 Nov 1999 05:48:31 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Variable assignment confusion
Message-Id: <slrn83hma3.4kh.sholden@pgrad.cs.usyd.edu.au>
On Sun, 21 Nov 1999 23:22:34 -0600,
Eric Lengvenis <silvenis@wavetech.net> wrote:
>I have looked hard for the answer to this before I posted, so forgive me
>if it is obvious. I can't figure out where the two variables $f and $d
>get their values. I am trying to read someone else's code (the solitaire
>encryption code from Neal Stephenson's Cryptonomicon) and I understood
>everything but the third line. The program references these variables,
>but I never see them assigned anything. I understand that it is an
>if..then..else, and I assume the value -1 or 1 is assigned $_.
>
>#!/usr/bin/perl -s
That -s enables simplistic switch parsing. See the documentation that
comes with perl for details. perldoc perlrun.
>die "Usage: $0 [-d] 'key phrase' [infile ...]\n" unless $#ARGV >=0;
>$f=$d ? -1 : 1;
That sets $f to -1 if -d was specified on the command line, or 1 in not.
--
Sam
Fifty years of programming language research, and we end up with C++ ???
--Richard A. O'Keefe
------------------------------
Date: Mon, 22 Nov 1999 09:21:23 GMT
From: jmn.ac.delete@abanet.it (John McNamara)
Subject: Re: What is a good book on Perl
Message-Id: <38390b05.7119317@news.eni.it>
On Sun, 21 Nov 1999 17:01:02 -0800, David Cassell
<cassell@mail.cor.epa.gov> wrote:
>Uri Guttman wrote:
>[snip]
>> the new johnson book from manning: elements of programming in perl (we
>> need a nickname or an abbrev for that) is aimed at first time
>
>The 'woman in a fez' book?
>The 'fashion-victim' book?
The "Hitch-hiker" book?
John McNamara
--
------------------------------
Date: Mon, 22 Nov 1999 07:32:02 GMT
From: jasonj@rwdata.co.uk (Jason L. James)
Subject: Re: WINNT, Email, MS Outlook and MS Exchange
Message-Id: <3838f0f5.226948477@news.demon.co.uk>
Once MS Exchange was working OK it wasn't too bad to solve. All
I then had to do was change the domain of the server to be the
same as the domain of my email addresses and everything worked fine.
I ended up using Mail::sender. It can be a bit slow if your Exchange
server is a little low on memory, but other thatn that everything is
working just great.
Cheers
Jason
On Fri, 19 Nov 1999 16:52:42 GMT, dwiesing@my-deja.com wrote:
>Jason,
>
>I'm running in the same environment as you & ran into similar problems
>getting my script to send an Email. I opted to use NET::SMTP to send
>my messages - someone said it's better. My script isn't quite working
>yet because my NT box is soo locked down that I can't find out what our
>SMTP address is on our corporate WAN.
>
>If you don't want to switch to SMTP, then maybe a 'perl Makefile.pl' on
>your NET directory will help you initialise the missing variable?
>(Warning...I'm a newbie at this stuff, so take my advice with a grain
>of salt.)
>
>Good luck, & lemme know how it goes.
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 1455
**************************************