[15937] in Perl-Users-Digest
Perl-Users Digest, Issue: 3350 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 14 00:05:53 2000
Date: Tue, 13 Jun 2000 21:05:12 -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: <960955512-v9-i3350@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 13 Jun 2000 Volume: 9 Number: 3350
Today's topics:
Re: accessing file with samba <trevor@trevorsky.com>
Re: ANSI Perl: No Way !!! <htp@mac.com>
Re: ANSI Perl: No Way !!! (Neil Kandalgaonkar)
Re: ANSI Perl: No Way !!! <godzilla@stomp.stomp.tokyo>
Re: Can't find the syntax error! (Neil Kandalgaonkar)
Re: CGI::Fast needs perl with sfio? (Mark P.)
Re: Easy CGI question <dan@tuatha.sidhe.org>
Re: Easy CGI question (Eric Bohlman)
Re: Encrypting / decrypting. <dan@tuatha.sidhe.org>
evaluating expressions (Your name)
Re: evaluating expressions <wyzelli@yahoo.com>
Re: evaluating expressions <godzilla@stomp.stomp.tokyo>
Re: evaluating expressions <uri@sysarch.com>
Re: FileHandle simulation within a script? (Neil Kandalgaonkar)
grep - a beginner question <karlh@midco.net>
Help with strings <noone@nowhere.org>
How do I... <altavistaNOalSPAM@agentkhaki.com.invalid>
Re: How do I... (Eric Bohlman)
Installing active perl <whitemagic@zianet.com>
Re: Installing Modules (Jerome O'Neil)
IP address help... <PictureFactoryr@worldnet.att.net>
Re: Larry Rosler interview on perl.com! <htp@mac.com>
Re: Larry Rosler interview on perl.com! <htp@mac.com>
Re: Mystery Regex <dan@tuatha.sidhe.org>
Re: newbie help: how to extract line by column position <jboes@eoexchange.com>
Perl and .htaccess <btate@primary.net>
printing multiple lines to filehandle? <johndoyle33@hotmail.com>
Re: printing multiple lines to filehandle? <johndoyle33@hotmail.com>
Re: Quick Network Ping : Can't make Net::Ping work? <robert@chalmers.com.au>
Re: Reading Files <johndoyle33@hotmail.com>
Remote .htpasswd editting tpaulakis@businessedge.com
Re: reverse Urlizer (Charles DeRykus)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 13 Jun 2000 19:13:03 -0700
From: "Trevor Sky Garside" <trevor@trevorsky.com>
Subject: Re: accessing file with samba
Message-Id: <zOB15.70$C02.55429@news.pacbell.net>
"Paula Jakobs" <pjakobs@wt.net> wrote in message
news:3946BB2A.26991561@wt.net...
> I'm running a script from our NT machine that needs to access a file on
> our linux machine. I have Samba set-up to do sharing on the directory
> where the file is located, and I can get to it fine from windows
> explorer. I'm having problems figuring out how to access it from the
> perl script.
>
> The windows path to the file is:
>
> \\Www\RRS\data\1050-1104001.txt
>
I do not know any way to handle this directly in Perl (does anybody else?),
but I can suggest a possible solution: map your "Www" samba share into a
drive letter and reference the file as if it were local.
--Trevor
------------------------------
Date: Wed, 14 Jun 2000 10:49:30 +0930
From: Henry <htp@mac.com>
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <htp-24C730.10493014062000@news.metropolis.net.au>
In article <3945D06E.F489ACB5@stomp.stomp.tokyo>, "Godzilla!"
<godzilla@stomp.stomp.tokyo> wrote:
> I rather think of ASP as mule manure.
Noticed the following?
Active Server Pages (ASP)
Active State Perl (ASP)
Active Server Programming (ASP)
It's very, very clever marketing to make the acronym for one's products
synonymous with the task itself. Damn clever...
> Shirley you have talked with a stereotypical
> technical support person at an average ISP,
> a pimple face teenager fresh off the hamburger
> flipping line at Sir Reginald's. We have all
> once been this teenager.
Sorry, born in country South Australia - a not exactly, err, advanced
part of the country. The first time I even saw a computer was in 1982
(when I was 13) - about the same time we actually had our first phone
installed! Didn't even know the Internet existed until 1991 (discovered
at Uni). Things kinda took off from there. Now I'm a cynical and
senile 30-year-old who spends time on the _other_end_ of the phone line.
> In time, competition and market trends will slim
> down the gross number of web hosts. Eventually,
> Bill Gates will buy all of them, with pocket change.
William has no interest in actually doing _work_ so that's not going to
happen. He'll just do what he always does and engineer the situation to
ensure that he owns the licenses for the software that all those hosts
are running. And in that case, the more hosts there are, the better.
>>> I admire Bill Gates. He is an American Hero.
>>
>> He's a one-eyed rat with remarkable self-preservation skills.
>
> Missing some of his tail lately as well. Seems some
> G-Men have been chewing his tail lately.
Or maybe he's one of those lizards that drops their tail when threatened
by a predator - giving the predator something to chew on while it
escapes. I think they call the dropped tail a 'balmer' but I could be
mistaken...
> Henry, I have a plan to save Perl and, you are
> just the man for the job. Think with imagination
> on these thoughts, a way to reduce Perl core, reduce
> memory bloat and speed up Perl along with giving it
> a great marketing logo.
>
> "Perl, programs itself and teaches you how to program."
>
> Turn pragmas into modules.
...
> I am not talking about just warnings, but rather
> all pragma hints and whatever else could be jerked
> out of core and made into a series of specialized
> modules with greatly expanded functions.
>
> Impossible? Not at all and exceptionally logical.
> What use are warnings when you have finished
> writing your script and it functions perfect?
> No use at all but, still resides in core.
I got so fed up with -w I wrote my own debugging module a while ago to
give me control over the granularity of warnings. Active State's
(Microsoft) Perl also has such a feature.
I hadn't tought of actually making the _code_itself_ optional - that's
quite ingenious!
My only concern (after superficial treatment) is with regard to
exponential scoping costs. We are talking about feeding limits in to
deliberately stress the code, right? If that's the case, then some of
those limits will affect loops...
> Henry, care to guesstimate how much core could
> be reduced if all pragmas, a good chunk of error
> checking and whatever else, are removed from core?
Isn't there a saying: "10% of the code does 90% of the work"?
Hang a bell curve between 45% and 90% and you end up around the
two-thirds mark. Nice.
> If Perl 5 is to be Plug N Play, why not make it
> a kick butt system? Can you imagine the benefit,
> both in programming and marketing, if documentation
> for Perl is kicked over into specialized modules
> which could be healthy in size and, not effect
> core at all.
...
> What about it Henry? Why don't you work on some
> modules which would strip core to a bare minimum
> and expand functionality for pragmas, syntax
> checking, compile time...
I'm really depressed now. I've just realised that the benefits of any
measure we take to improve Perl will go (increasingly) towards Active
State (Microsoft).
For every MB we save on the core, the bastards will just wedge it up
with 2 MB of cruft. This goes for drive space as well. I can just
imagine "Hello World!" running on Windows linking in 10 MB worth of
crap, and being stored as a 2 MB file on the drive. Word does that
already.
<launches Word 98, types the letter 'a', saves document, checks file
size: 19,456 Bytes>
Damn. The better we make Perl, the faster we lose it. I hadn't thought
of that before.
I don't like that idea one bit - not one, single bit.
Hmmm...
I think I'll make myself a cuppa and think. Yes, think...
Henry.
------------------------------
Date: 14 Jun 2000 01:32:57 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <8i6nc9$j79$1@newsflash.concordia.ca>
In article <3946B057.A8ADEC12@la.znet.com>,
Godzilla! <callgirl@la.znet.com> wrote:
>Perl experts, as a general
>rule, are not very good writers. This applies to all
>technical fields and beyond.
Erm, I would agree with you if you are suggesting that there isn't
much relation between programming in general adn writing abilities.
However, there seems to be no *negative* correlation, and one of
the things I like about the perl community is that a lot of its
leaders are able writers.
I understand that you feel like most of the perl docs are gibberish;
I felt exactly the same way once. I think of myself as halfway
intelligent and I would read sentences over and over trying to grasp
what they meant.
However, now the docs are crystal clear to me. So it's not poor
writing per se, in my opinion -- it's a question of for which
audience they were written.
>Perl 5 core could be stripped down to a sleek and slim
>hot rod of a language and, pragmas,
It might be a worthwhile goal, but perl probably gone too far down
one road to fix that now. Unless Perl 6 were very slim, and
#!/usr/bin/perl loaded in a lot of modules automatically, but
#!/usr/bin/perl6 didn't.
>What you don't see is the email harassment with which I am
>contending, email bombing, break-in attempts at my sites and,
>you don't see how many times I have had to contact both ISPs
>and law enforcement to deal with these sociopathic events.
I have noticed that you start making non sequitur allusions to
shadowy harassers whenever you are losing the argument. Given the
context your claims are hard to take seriously.
Anyway, have you connected these alleged break-in attempts to
anyone here? If you have a website, it attracts crackers.
>Even you suggested committing crimes against me, suggested
>and encouraged others to setup a slander page specifically
>targeting me. You did this. Care to deny this?
I haven't written it yet, so I think the charges of slander are
a bit premature. And as for "crimes", I have never wished any harm
on you or urged others to do so, as the public record shows.
By the way, I never said the page was going to be about you; it
was going to be about trolls on c.l.p.misc.
If you are interested, my plan was simply to define what a usenet
troll was, and why flaming and silly revenge tactics like
mailbombs were both wrong and counter-productive, and ignoring the
troll, or remaining civil, is much better. Then I would link to
selected threads in Dejanews where I see clear evidence of
trolling. Ultimately the goal would be one you could applaud, to
reduce the amount of flames directed against the trolls.
I did not encourage others to do anything. I was going to do it
on my own. However, I am really reluctant to do so, because it
suggests that certain people should be killfiled and ignored on
sight; that they can make no useful contribution. I was starting
to doubt that conclusion today.
>Incidently, do you know Anne Bennett at your college?
I've met her occasionally, a most excellent newsmistress and
sysadmin. Anyway, I would urge you not to bother with a complaint,
because a) it would be a waste of her time and b) since I graduated,
my account will expire at the end of this week -- I'll be switching
news providers.
(BTW, it's "incidentally").
Yours for a better Usenet,
--
Neil Kandalgaonkar
neil@brevity.org
------------------------------
Date: Tue, 13 Jun 2000 19:33:27 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <3946EEF7.BE6E694A@stomp.stomp.tokyo>
Neil Kandalgaonkar wrote:
>Godzilla! <callgirl@la.znet.com> wrote:
> I did not encourage others to do anything. I was going to do it
> on my own. However, I am really reluctant to do so, because it
> suggests that certain people should be killfiled and ignored on
> sight; that they can make no useful contribution. I was starting
> to doubt that conclusion today.
Any statesman or stateswoman worth his or her
weight in diplomatic skills will quickly and
eloquently state, in a firm but fair voice,
"When you engage in a battle of sabre rattling,
leave your opponent sizable face saving room
lest blood actually be shed."
Actually, I made this up but, I can, within my
highly imaginative mind, cast a three breasted
green ambassadorette from Alturas 5 saying this,
and not saying she has a sizable fleet of robotic
beserkers standing ready to reduce Earth to a
cinder ball if diplomatic efforts fail.
Shall we move on to more productive dialog?
Godzilla!
------------------------------
Date: 14 Jun 2000 02:52:16 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: Can't find the syntax error!
Message-Id: <8i6s10$26d$1@newsflash.concordia.ca>
In article <8i6bab$o7n$1@news.service.uci.edu>, Gabe <grichard@uci.edu> wrote:
>The error message is:
>
>Global symbol "fldnames" requires explicit package name at quote.cgi line
>47.
>
>syntax error at quote.cgi line 64, near "}"
>
>My code is:
>
> my @fldnames;
> for (my $i=0; $i<$fldnum->{NUM_OF_FIELDS}; $i++) {
> unless (($tbldef->[$i]->[0] eq 'prosid') || ($tbldef->[$i]->[0] eq
>'reviewed') || ($tbldef->[$i]->[0] eq 'contacted') || ($tbldef->[$i]->[0] eq
>'policy') || ($tbldef->[$i]->[0] eq 'complete')) {
> if (($tbldef->[$i]->[3] eq 'No') && (!$cgi->param($tbldef->[$i]->[0]))
>
> print
>$cgi->redirect('http://www.bestinsuranceinc.com/incomplete.html');
> }
> elsif ($cgi->param($tbldef->[$i]->[0])) {
> push (@fldnames, $tbldef->[$i]->[0]);
> }
> }
> }
A bit unreadable. Uri's comments should be followed.
Alternative way of doing this, totally untested but the ideas should help:
my $incomplete_url = 'http://www.bestinsuranceinc.com/incomplete.html';
my %bad_type;
for ( qw/ prosid reviewed contacted policy complete / ) {
$bad_type{$_} = 1;
}
my @fldnames;
# I am assuming there is no difference between $fldnum->{NUM_OF_FIELDS}
# and the number of elements in the array refered to by $tbldef
for my $t ( @$tbldef ) {
my ($type, $yes_or_no) = @$t[0,3]; # pick better var names
next if $bad_type{$type};
# I assume you really meant "not defined", not "not"
if ( $yes_or_no eq 'No' and not defined $cgi->param($type) ) {
print $cgi->redirect($incomplete_url);
} elsif ( $cgi->param($type) ) {
push @fldnames, $type;
}
}
> my $fldstr;
> my $plcehldr;
> my @values;
> foreach my $i (@fldnames) { # This is line 47
> $fldstr .= "$i, ";
> $plcehldr .= '?, ';
> push @values, $cgi->param($i);
> }
> substr($fldstr, -2) = "";
> substr($plcehldr, -2) = "";
my ($fldstr, $plcehldr, @values);
$fldstr = join ',' => @fldnames;
$plcehldr = join ',' => ('?') x @fldnames;
@values = map { $cgi->param($_) } @fldnames;
> my $insquery = qq{INSERT INTO prospects ($fldstr) VALUES ($plcehldr)};
> my $addpros = $dbh->prepare($insquery);
> $addpros->execute(@values) || die $dbh->errstr;
> }
>} #This is lin 64
>
>I don't see the problem. Please help. Any other comments on my program would
>be appreciated as well.
Constructing the SQL statement at the last minute is sometimes necessary,
but it's a bit of a pain. If I could I would define the sth well in advance,
maybe even in a separate library, with placeholders for all possible fields.
Then a simple map of all possible fields to their cgi params gives you a
@values in all the right order, and you don't have to build @fldnames on the
fly.
--
Neil Kandalgaonkar
neil@brevity.org
------------------------------
Date: Wed, 14 Jun 2000 02:53:45 GMT
From: perl@imchat.com (Mark P.)
Subject: Re: CGI::Fast needs perl with sfio?
Message-Id: <3946f30e.1003533@news.ionet.net>
On Mon, 12 Jun 2000 16:35:40 GMT, jhefferon@my-deja.com wrote:
>Hello,
>
>I want to use CGI::Fast. The documentation refers to the fastcgi
>web site, saying that a patch kit is needed for Perl. From that
>web site, I take it that I need to compile Perl to have the io
>done with sfio. Is that correct?
No! Just use the latest modules and a decent Perl Binary, ie;
5.004 +. You don't have to do a fresh compile. That stuff is a little
dated.
>
>The problem is that I can't get sfio97 to compile. I have a very
>generic linux (RH 6.0), and I can get sfio99 to compile, but
>on CPAN is listed sfio97, and I'm worried there is a mismatch.
>If anyone can either give me a hint about how to compile '97 (I
>followed the directions), or tell me that '99 is OK, or let me know
>the best way to use CGI::Fast, I'd be very grateful.
You shouldn't have to compile sfio if your using the latest
module.
MP
------------------------------
Date: Wed, 14 Jun 2000 01:29:06 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Easy CGI question
Message-Id: <CdB15.25$Zg4.1275@news1.rdc1.ct.home.com>
Larry Rosler <lr@hpl.hp.com> wrote:
> In article <JXv15.1436$My2.2834@news1.rdc1.ct.home.com> on Tue, 13 Jun
> 2000 19:28:41 GMT, Dan Sugalski <dan@tuatha.sidhe.org> says...
>> Alan J. Flavell <flavell@mail.cern.ch> wrote:
> ...
>> > On Tue, 13 Jun 2000, Raphael Pirker wrote:
>>
>> >> The heading (content-type...) must be exactly as follows:
>>
>> > "must"? "exactly"??
>>
>> >> print "Content-type: text/html\n\n";
>>
>> > CA-2000-02 says no. Every text content-type needs a charset
>> > explicitly specified in order to conform with this security advisory.
>>
>> The line endings are also wrong--per the HTTP spec it's supposed to be
>> CRLF pairs, not bare linefeeds.
> That should be taken care of by the server, when transmitting the header
> to the client.
No reason not to get it correct. If you're going to be taking control of
the HTTP conversation, even partially, the data sent should be correct.
Dan
------------------------------
Date: 14 Jun 2000 03:44:48 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Easy CGI question
Message-Id: <8i6v3g$sed$1@slb1.atl.mindspring.net>
Dan Sugalski (dan@tuatha.sidhe.org) wrote:
: Larry Rosler <lr@hpl.hp.com> wrote:
: > In article <JXv15.1436$My2.2834@news1.rdc1.ct.home.com> on Tue, 13 Jun
: > 2000 19:28:41 GMT, Dan Sugalski <dan@tuatha.sidhe.org> says...
:
: >> The line endings are also wrong--per the HTTP spec it's supposed to be
: >> CRLF pairs, not bare linefeeds.
:
: > That should be taken care of by the server, when transmitting the header
: > to the client.
:
: No reason not to get it correct. If you're going to be taking control of
: the HTTP conversation, even partially, the data sent should be correct.
But the bare linefeeds *are* correct terminators for *CGI* headers.
Unless the script is running NPH, it's outputting CGI headers, not HTTP
headers, and the CGI spec allows bare linefeeds. The set of CGI headers
is *almost* isomorphic to that of HTTP headers, but there's definitely a
mapping that the server is supposed to perform (for example, certain
Location: CGI headers are supposed to signal the server to output an
alternate document rather than issuing a Location: HTTP header).
Remember that you're dealing with two separate interfaces here: the CGI
interface between the script and the server, and the HTTP interface
between the server and the user agent.
------------------------------
Date: Wed, 14 Jun 2000 01:48:24 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Encrypting / decrypting.
Message-Id: <IvB15.26$Zg4.1275@news1.rdc1.ct.home.com>
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> A quick thought for you Matt. My presumption
> is you are using a form action for input data
> and using cgi.pm to read and parse your data.
> As a test, I would dump cgi.pm and write your
> own "Steve Brenner" style read and parse.
This is generally a bad thing, as people usually get it wrong, as Gojira
helpfully demonstrates below.
> You
> will find this method by internet search. This
> cgi.pm is well noted for a being a data mangler.
Details on this claim, please.
> Using your own read and parse will kill security
> measures included in cgi.pm which, as a spin-off,
> wreak havoc upon input data.
That you lose security is correct, and a good reason to use CGI.pm
instead. CGI.pm, however, doesn't mangle data.
> elsif ($ENV{'REQUEST_METHOD'} eq "POST")
> { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); }
Alas wrong. This will not reliably get you all your data.
> @in = split(/&/, $in);
> foreach $i (0 .. $#in)
This is both inefficient and error-prone for perl 5.004 and before. For
5.005 and up it's merely error-prine.
> {
> $in[$i] =~ s/\+/ /g;
> ($key, $value) = split(/=/,$in[$i],2);
> ($value eq "") && next;
> $key =~ s/%(..)/pack("c",hex($1))/ge;
> $value =~ s/%(..)/pack("c",hex($1))/ge;
> $in{$key} .= "\0" if (defined($in{$key}));
This makes no attempt to distinguish between nulls embedded in the data
and multiple occurences of the same key. Bad.
> $in{$key} .= $value;
> }
> return 1;
> } # Parse #
And that's on quick scan. Not too good, Gojira. This is the fifth code
sample I've seen that you've posted, and all five have been wrong.
Dan
------------------------------
Date: Wed, 14 Jun 2000 02:15:06 GMT
From: rroe@mail.com (Your name)
Subject: evaluating expressions
Message-Id: <8F52E8CA5rroemailcom@64.34.205.9>
The code
$w="10+3*x-x**2";
$w=~s/x/1/g;
print $w;
outputs
10+3*1-1**2
How to get this calculated to 12 please?
------------------------------
Date: Wed, 14 Jun 2000 12:18:33 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: evaluating expressions
Message-Id: <9mC15.9$HA4.2349@vic.nntp.telstra.net>
Your name <rroe@mail.com> wrote in message
news:8F52E8CA5rroemailcom@64.34.205.9...
> The code
> $w="10+3*x-x**2";
> $w=~s/x/1/g;
> print $w;
>
> outputs
> 10+3*1-1**2
>
> How to get this calculated to 12 please?
Add this before the print:
$w = eval $w;
Wyzelli
------------------------------
Date: Tue, 13 Jun 2000 20:05:45 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: evaluating expressions
Message-Id: <3946F689.18F1E96B@stomp.stomp.tokyo>
Your name wrote:
> The code
> $w="10+3*x-x**2";
> $w=~s/x/1/g;
> print $w;
> outputs
> 10+3*1-1**2
> How to get this calculated to 12 please?
Mr. Name, change your sequence of events
and change your syntax. No problem! Look
over my printed results and test script.
You will quickly understand.
Godzilla!
PRINTED RESULTS
_______________
Test One - X equals one:
Output: 12
Test Two - X is substituted to one:
Output: 12
Test Three - X equals one using quotes:
Output: 10+3*1-1**2
Test Four - Original Method:
Output: 10+3*1-1**2
TEST SCRIPT
___________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
## TEST ONE
print "Test One - X equals one:\n\n";
$x = 1;
$w = (10+3*$x-$x**2);
print " Output: $w \n\n";
## TEST TWO
print "Test Two - X is substituted to one:\n\n";
$x = "x";
$x =~ s/x/1/;
$w = (10+3*$x-$x**2);
print " Output: $w \n\n";
## TEST THREE
print "Test Three - X equals one using quotes:\n\n";
$x = 1;
$w = "10+3*$x-$x**2";
print " Output: $w \n\n";
## TEST FOUR
print "Test Four - Original Method:\n\n";
$w="10+3*x-x**2";
$w=~s/x/1/g;
print " Output: $w";
exit;
------------------------------
Date: Wed, 14 Jun 2000 03:51:30 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: evaluating expressions
Message-Id: <x71z209aym.fsf@home.sysarch.com>
>>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
G> Your name wrote:
>> The code
>> $w="10+3*x-x**2";
>> $w=~s/x/1/g;
>> print $w;
>> outputs
>> 10+3*1-1**2
>> How to get this calculated to 12 please?
G> You will quickly understand.
no he won't because you didn't answer his question as usual.
G> print "Content-Type: text/plain\n\n";
this has nothing to do with cgi, so why wrap it in one? learn to use
perl like MOST of the perl programs in world which DON'T USE CGI!!!
G> $x = 1;
G> $w = (10+3*$x-$x**2);
do you understand the difference between a string and a perl expression?
obviously not. you don't have the following line ANYWHERE in your code
so your doesn't address his query at all. just the usual lack of
comprehension on your part. some english phd who can't even follow a
simple word problem.
$w="10+3*x-x**2";
G> $w = (10+3*$x-$x**2);
again no string there.
G> $w = "10+3*$x-$x**2";
G> print " Output: $w \n\n";
well there is a string there, but this is the output:
G> Output: 10+3*1-1**2
G> $w="10+3*x-x**2";
G> $w=~s/x/1/g;
G> Output: 10+3*1-1**2
so where is the output of 12 when the input is a string?
nowhere but in the deep recesses of your psychosis.
you make matt wright and selena sol look intelligent by comparison. at
least they know how to follow a word problem even if they can't code
worth a damn.
just go away. you used to threaten that all the time so just do it.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 14 Jun 2000 01:49:11 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: FileHandle simulation within a script?
Message-Id: <8i6oan$vam$1@newsflash.concordia.ca>
In article <8i6kob$r8i$1@nnrp1.deja.com>,
Chovy <johndoyle33@hotmail.com> wrote:
>Hello,
>
>I want to iterate through a loop, which basically will generate rows of
>a table on the fly.
>
>I can do this with a FileHandle, but I would rather append to a variable
>within the script without using anything outside the script (like a
>filehandle)....is there someway of simulating a FileHandle in perl?
>Here's a sample script:
>
> while(@results = $sth->fetchrow_array()) {
>
> $print_links = qq(
> <a href="../commentary/feature/$db_file">$db_title</a><br>
> );
>
> }
>
>I want to append this to the previous value of $print_links...any
>suggestions?
The concatenation operator is period (.); a short way of saying $x = $x . $y; is
$x .= $y; see perldoc perlop for more explanation.
my $links;
while (something) {
$links .= $something;
}
--
Neil Kandalgaonkar
neil@brevity.org
------------------------------
Date: Tue, 13 Jun 2000 20:40:09 -0500
From: karlh <karlh@midco.net>
Subject: grep - a beginner question
Message-Id: <3946E279.6F6D6919@midco.net>
I am trying to learn how to use grep in a Perl program and have written
the following to experiment with.
@array = ("Bob Stands Tall", "Sarah Sits Still", "Mary Runs Slowly");
print "Search for: ";
$search = <>;
chomp $search;
@arrayout = grep($_ = $search, @array);
print "@arrayout\n";
I want the last print line to print the array fields which contained the
search string.
For example, when I enter "Tall" for a search string, the print output
is, "Tall Tall Tall". I do not know what this is.
Thanks for taking a look at this.
Karl
karlh@midco.net
------------------------------
Date: Wed, 14 Jun 2000 03:24:35 GMT
From: "Mike Ray" <noone@nowhere.org>
Subject: Help with strings
Message-Id: <TVC15.6001$xX4.80133@newsread2.prod.itd.earthlink.net>
Hi All,
I have a problem with string comparisons which has me climbing the
walls. I've exhausted all I can think to do to resolve the problem(s).
Help would be much appreciated. My environment is Perl 5.004 on Unix.
The code that is giving me problems is as follows:
for( $k = 0; $k <= $#PLines; $k++) {
if ($PLines[$k] =~ /FORMNAME/) {
$PLines[$k] =~ /=(.+?)\]/;
if ($Form{'FORMID'} eq $1) { #THIS LINE ALWAYS FAILS
$SectionFlag = 1;
$SectionIndex = $k;
last;
}
}
}
My problem is that "if" statement labeled above always returns false
even when it should be true.
In the above code, the hash element $Form{'FORMID'} is being filled in
by cgi-lib.pl when form input is parsed. It "appears" to have the
correct content visually and contains nothing Perl5 considers whitespace
(i.e. "\s").
The third line of the code is extracting a string from a line of the
form "[FORMNAME=string]" into $1 and seems to do this correctly - but
there is a weirdness I'll describe later. $1 also has nothing Perl5
considers whitespace.
In debugging this code I have tried lots of things with the variables
$Form{'FORMID'} and $1 to get a handle on why the "if" comparison is
failing when it should not, including translating whitespace (\s) plus
signs (and printing the variables) to see if there is any hidden
whitespace.
One thing I have done in debugging that is really driving me batty is to
look at the string lengths to see if there may be some hidden characters
that are not printable by doing the following:
$length1 = length($Form{'FORMID'});
$foo = $1;
$length2 = length($foo);
For both of the above lines of code I don't get anything nearly like I
would expect. The line with the assignment to the $length1 variable
causes Perl 5.004 to crash and terminate my script. The line with the
assignment to $length2 always returns a length longer than it should be;
for example, if $foo contains the string 'NLD_Inquiry' the result of the
"length" function is 17 - longer than the expected 11. Can anyone
explain why both of the above length assignments fail? Worse, if I do
the following:
$foo = 'NLD_Inquiry';
$length2 = length($foo);
then value in $length2 is 11 as expected. Arrrgh!!! What on earth is
going on here?
In the "if" comparison of line 4 of the above code, maybe a string match
function (m//) is more appropriate or even the only solution. However,
the code as written seems reasonable yet it does not work. Any help in
resolving this problem and an explanation as to why it fails is very
much appreciated.
Thanks.
------------------------------
Date: Tue, 13 Jun 2000 20:31:08 -0700
From: Agentkhaki <altavistaNOalSPAM@agentkhaki.com.invalid>
Subject: How do I...
Message-Id: <21d086a8.f579dd66@usw-ex0109-068.remarq.com>
I thought I posted this question already, but apparently
not...
I'm thinking about writing a portal of sorts (like My
Excite) and I was wondering if anyone knew how web based
email clients like ZDNetmail retrieve mail from any POP3
account you specify to them... is this done using CGI or in
some other manner? I'm fairly new to Perl, but I've been
designing websites for a while (see
http://www.agentkhaki.com/~webdesign for a list of
excamples, if you're interested) and I'm ready to give them
some extra ooomph.
Also, if I were going to store user preferences so that
then a person came to the site, it looked say, the same as
they had last arranged it or logged them in (I would
assume) using cookies, would that information be stored in
a database or could it simply be written to a file and then
accessed using Perl...
To tell the truth, I'm not even sure if my questions are
valid, or possible, or whatnot. Please let me know. Thanks.
* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful
------------------------------
Date: 14 Jun 2000 03:56:22 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: How do I...
Message-Id: <8i6vp6$sed$2@slb1.atl.mindspring.net>
Agentkhaki (altavistaNOalSPAM@agentkhaki.com.invalid) wrote:
: I'm thinking about writing a portal of sorts (like My
: Excite) and I was wondering if anyone knew how web based
: email clients like ZDNetmail retrieve mail from any POP3
: account you specify to them... is this done using CGI or in
: some other manner? I'm fairly new to Perl, but I've been
: designing websites for a while (see
: http://www.agentkhaki.com/~webdesign for a list of
: excamples, if you're interested) and I'm ready to give them
: some extra ooomph.
You could certainly do it using CGI, though a large dedicated webmail
service would probably use some server-integrated process like mod_perl
instead. You'll probably find Net::POP3 (part of the libnet bundle) or
Mail::POP3Client helpful here.
: Also, if I were going to store user preferences so that
: then a person came to the site, it looked say, the same as
: they had last arranged it or logged them in (I would
: assume) using cookies, would that information be stored in
: a database or could it simply be written to a file and then
: accessed using Perl...
You might want to download Chris Nandor's My Portal script
<URL:http://www.news.perl.org/my_portal/> to see how he did it.
------------------------------
Date: Tue, 13 Jun 2000 19:43:33 -0600
From: "BJ James" <whitemagic@zianet.com>
Subject: Installing active perl
Message-Id: <3946e3b8.0@oracle.zianet.com>
I have NT 4.0 sp6 and am trying to install Active Perl's latest. I keep
getting access violations when trying to run the example.pl from the MS-dos
command line. Does anyone have a quick FAQ on the exact steps to take to
allow scripts to run on the server? I changed the MMC for the www server,
but am lost from there.
------------------------------
Date: Wed, 14 Jun 2000 01:12:30 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Installing Modules
Message-Id: <2_A15.551$Kr1.56582@news.uswest.net>
Todd Anderson <todd@mrnoitall.com> elucidates:
> Can a perl module normally be installed in public_html?
Sure! You can install them just about anywhere you like!
> I've uploaded the package "PDF-Create" and when telneting to Makefile.PL
> I get a "permission denied" message.
Change the permissions so you have execute priveledge.
> When propted from the browser I get "500 error".
What's a browser?
> Any ideas on where to get installation help, more extensive than CPAN's?
Yes. The documentation for your web server. That will tell you how to
appropriately configure it so it understands executable content.
------------------------------
Date: Wed, 14 Jun 2000 01:46:49 GMT
From: "PictureFactory" <PictureFactoryr@worldnet.att.net>
Subject: IP address help...
Message-Id: <duB15.701$Uw3.33951@bgtnsc04-news.ops.worldnet.att.net>
Is there a Perl function to resolve an IP like
24.10.125.132 into 130.atlanta-41-and more details...
Or could you point me to a script that does that?
------------------------------
Date: Wed, 14 Jun 2000 11:01:35 +0930
From: Henry <htp@mac.com>
Subject: Re: Larry Rosler interview on perl.com!
Message-Id: <htp-52F486.11013514062000@news.metropolis.net.au>
In article <qNA15.543$Kr1.56582@news.uswest.net>,
jerome.oneil@activeindexing.com wrote:
> Every document I listed ships with the 5.6 distribution. I don't
> know Macintosh, but if it doesn't ship with the complete doc set,
> I'd say it's broken.
Not broken, just a little behind the standard track. Open source
development relies on key people, and sometimes the real world conspires
against them.
Not to worry, the public beta of Mac OS X (which has a BSD foundation)
is coming out sometime within the next 78 days. The whole issue becomes
moot when that happens.
Henry.
------------------------------
Date: Wed, 14 Jun 2000 11:20:16 +0930
From: Henry <htp@mac.com>
Subject: Re: Larry Rosler interview on perl.com!
Message-Id: <htp-2A2B7C.11201614062000@news.metropolis.net.au>
In article <3946B579.FEF423B6@attglobal.net>, Drew Simonis
<care227@attglobal.net> wrote:
>> And I reply (again) that it's the _lack_ of approachable
>> documentation (documentation that newbies can comprehend)
>> that ships with the standard distribution that's got my goat.
>
> I am failing to see this point. I appologize if my thick headedness
> comes into play, but I count myself among the newbies.
...
> I am that neophyte you speak of, and I have
> found the majority of the documents to be _very_ approachable.
Then you are not 'average'. Consider yourself lucky to have a head
wired in such a way that makes assimilation of the documentation
effortless.
> My point is that millions of newbies are able to comprehend
> things far beyond what you are willing to give them credit for.
My opinion is base on first-hand personal experience. It is regretful
that this does not conform with your perspective of reality.
Henry.
------------------------------
Date: Wed, 14 Jun 2000 01:24:01 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Mystery Regex
Message-Id: <R8B15.24$Zg4.1275@news1.rdc1.ct.home.com>
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> Dan Sugalski wrote:
>
>> Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>> I'd say someone was better off trying something else,
>> since this won't work as it should...
> Code Cop Mule Manure.
Nope. Your code is broken, and inefficiently broken on top of that.
Dan
------------------------------
Date: Tue, 13 Jun 2000 14:25:03 -0400
From: Jeff Boes <jboes@eoexchange.com>
Subject: Re: newbie help: how to extract line by column position
Message-Id: <3946ee29$0$1493$44a10c7e@news.net-link.net>
gelshocker@my-deja.com wrote:
>
> for each line {
> column position 1-30 into one scalar var;
> column position 31-40 into another;
> etc.
> }
>
perldoc -f unpack
--
Jeff Boes jboes@eoexhange.com
Sr. Software Engineer 616-381-9889 ext 27
Change Technology 616-381-4823 fax
EoExchange, Inc. http://www.eoexchange.com
------------------------------
Date: Tue, 13 Jun 2000 21:57:42 -0500
From: "Bob Tate" <btate@primary.net>
Subject: Perl and .htaccess
Message-Id: <1GC15.3868$bc4.262822@news1.primary.net>
I am trying to find out if there is a way in Perl to provide a website user
to a secured website using .htaccess procedures to be able to "Logoff" by
clicking a button. This would remove the reference stored in memory of the
browser to be removed so that if the user were to click "Refresh" they would
be asked again to provide the user name/password as if it was there first
time.
Anyone know if this can be done and how?
------------------------------
Date: Wed, 14 Jun 2000 01:45:29 GMT
From: Chovy <johndoyle33@hotmail.com>
Subject: printing multiple lines to filehandle?
Message-Id: <8i6o3m$toi$1@nnrp1.deja.com>
How do I print multiple lines to a filehandle?
I am trying this, but to no avail:
print HTML = qq(a
bunch
of
html
text here
);
--
Thanks,
Chovy
johndoyle33@hotmail.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 14 Jun 2000 01:54:35 GMT
From: Chovy <johndoyle33@hotmail.com>
Subject: Re: printing multiple lines to filehandle?
Message-Id: <8i6okl$u4n$1@nnrp1.deja.com>
Nevermind, I took out the "=" and it worked!
In article <8i6o3m$toi$1@nnrp1.deja.com>,
Chovy <johndoyle33@hotmail.com> wrote:
> How do I print multiple lines to a filehandle?
>
> I am trying this, but to no avail:
>
> print HTML = qq(a
>
> bunch
> of
> html
> text here
>
> );
>
> --
> Thanks,
> Chovy
> johndoyle33@hotmail.com
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
--
Thanks,
Chovy
johndoyle33@hotmail.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 14 Jun 2000 13:55:56 +1000
From: "Robert Chalmers" <robert@chalmers.com.au>
Subject: Re: Quick Network Ping : Can't make Net::Ping work?
Message-Id: <dmD15.174$W74.3633@nsw.nnrp.telstra.net>
I tried the code example here on the cpan site, but can't get it to do
anything?
Would anyone have a small example of how to get a result from this please?
Thanks a lot
Robert
use Net::Ping;
$p = Net::Ping->new();
print "$host is alive.\n" if $p->ping($host);
$p->close();
$p = Net::Ping->new("icmp");
foreach $host (@host_array)
{
print "$host is ";
print "NOT " unless $p->ping($host, 2);
print "reachable.\n";
sleep(1);
}
$p->close();
$p = Net::Ping->new("tcp", 2);
while ($stop_time > time())
{
print "$host not reachable ", scalar(localtime()), "\n"
unless $p->ping($host);
sleep(300);
}
undef($p);
# For backward compatibility
print "$host is alive.\n" if pingecho($host);
"Elaine -HFB- Ashton" <elaine@chaos.wustl.edu> wrote in message
news:slrn8jd097.pq9.elaine@chaos.wustl.edu...
> In article <8h5m05$rsr$1@nnrp1.deja.com>, scarey_man@hotmail.com wrote:
> >Does anyone know how to quickly ping a device using perl, when the
> >device is not available over the network and a normal UNIX ping would
> >take a few seconds or more to time out?
>
> http://search.cpan.org/search?dist=Net-Ping
>
> e.
------------------------------
Date: Wed, 14 Jun 2000 01:42:06 GMT
From: Chovy <johndoyle33@hotmail.com>
Subject: Re: Reading Files
Message-Id: <8i6ntb$tem$1@nnrp1.deja.com>
If you need to grab a remote template file, just use `lynx -source` and
dump the source code to a tmp file, then open the tmp file with your
filehandle.
-Chovy
In article <8i5suj$q41$1@newsg2.svr.pol.co.uk>,
"John Leatherbarrow" <john@tcs-web.fsnet.co.uk> wrote:
> This is a multi-part message in MIME format.
>
> ------=_NextPart_000_0008_01BFD569.0CE6D500
> Content-Type: text/plain;
> charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> Ok,
>
> I've written a script that reads in a html file and then outputs it =
> again as part of a template.
>
> This works fine if its a file on the same server
>
> However it doesn't work if I want to read in a file from another =
> location i.e. a URL
>
> This is how I'm doing it
>
> sub Prop
> {
> open (BODY, "template/prop.htt");
> local($/) =3D undef;
> $Body =3D <BODY>;
> close(BODY);
> }
>
> $Body is then passed to the main template file and the contents of the
=
> prop.htt file are output.
>
> If I want to use the URL eg www.tduncan.com/prop.htt this file does
=
> not exist in this location
>
> then it doesn't work
>
> HELP
>
> ------=_NextPart_000_0008_01BFD569.0CE6D500
> Content-Type: text/html;
> charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>
> <META content=3D"text/html; charset=3Diso-8859-1" =
> http-equiv=3DContent-Type>
> <META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
> <STYLE></STYLE>
> </HEAD>
> <BODY>
> <DIV><FONT face=3DArial size=3D2>Ok,</FONT></DIV>
> <DIV> </DIV>
> <DIV><FONT face=3DArial size=3D2>I've written a script that reads in a
=
> html file and=20
> then outputs it again as part of a template.</FONT></DIV>
> <DIV> </DIV>
> <DIV><FONT face=3DArial size=3D2>This works fine if its a file on the
=
> same=20
> server</FONT></DIV>
> <DIV> </DIV>
> <DIV><FONT face=3DArial size=3D2>However it doesn't work if I want to
=
> read in=20
> a file from another location i.e. a URL</FONT></DIV>
> <DIV> </DIV>
> <DIV><FONT face=3DArial size=3D2>This is how I'm doing it</FONT></DIV>
> <DIV> </DIV>
> <DIV><FONT face=3DArial size=3D2>sub Prop<BR>{<BR>open (BODY,=20
> "template/prop.htt");<BR>local($/) =3D undef;<BR>$Body =3D=20
> <BODY>;<BR>close(BODY);<BR>}</FONT></DIV>
> <DIV> </DIV>
> <DIV> </DIV>
> <DIV> </DIV>
> <DIV><FONT face=3DArial size=3D2>$Body is then passed to the main =
> template file and=20
> the contents of the prop.htt file are output.</FONT></DIV>
> <DIV> </DIV>
> <DIV><FONT face=3DArial size=3D2>If I want to use the URL
eg =
> <A=20
> href=3D"http://www.tduncan.com/prop.htt">www.tduncan.com/prop.htt</A>
=
> <EM>this=20
> file does not exist in this location</EM></FONT></DIV>
> <DIV> </DIV>
> <DIV><FONT face=3DArial size=3D2>then it doesn't work</FONT></DIV>
> <DIV> </DIV>
> <DIV><FONT face=3DArial =
> size=3D5><STRONG>HELP</STRONG></FONT></DIV></BODY></HTML>
>
> ------=_NextPart_000_0008_01BFD569.0CE6D500--
>
>
--
Thanks,
Chovy
johndoyle33@hotmail.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 14 Jun 2000 02:54:04 GMT
From: tpaulakis@businessedge.com
Subject: Remote .htpasswd editting
Message-Id: <8i6s46$fn$1@nnrp1.deja.com>
I've been forever searching on the web for a perl script that lets an
authenticated user change his password (and his password alone) without
compromising the security of the other .htpasswd entries. All I found
was C
program that didn't even compile, and plus my server doesn't even
support
cgi scripts written in C (only those written in Perl). Please help!
~T
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 14 Jun 2000 02:42:41 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: reverse Urlizer
Message-Id: <Fw4I75.363@news.boeing.com>
In article <MGu05.175$1y5.16471@news3.cableinet.net>,
red [2] <reevesg@cableinet.co.ukx> wrote:
>thanks a long time ago to you guys i got an url to convert into a link.
>now, i need to get it to go the other way around
>
>$post =~ s!(http://[\-~A-Za-z0-9_/\.]+)!<a href=\"$1\">$1</a>!gi;
>is what im using to convert http://www.quadmonkey.co.uk/ into
><a href=" etc
>
>but i want to convert
><a href="http://[\-~A-Za-z0-9_/\.]+)">URLNAME</a> into
>URLNAME <http://url/>
>
>can you wonderful people help me out again... im not sure how to strip from
>the href= to the > , mainly because im not sure how to do it IF there's a "
>or not (id like it to be flexible)
>
Maybe for flexibility, something like:
use HTML::TokeParser;
my $arg_string = q{<a href="http://foo.com">The Foo Co.</a>};
my $p = HTML::TokeParser->new(\$arg_string) or die $!;
while (my $token = $p->get_tag("a")) {
my $href = $token->[1]{href} || "-";
my $text = $p->get_trimmed_text("/a");
print "$text <$href>\n";
}
--
Charles DeRykus
------------------------------
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 3350
**************************************