[16233] in Perl-Users-Digest
Perl-Users Digest, Issue: 3645 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 12 21:10:36 2000
Date: Wed, 12 Jul 2000 18:10:16 -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: <963450615-v9-i3645@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 12 Jul 2000 Volume: 9 Number: 3645
Today's topics:
Re: Reading lines of a file within a loop? (Eric Bohlman)
Re: reg expression not working. WHY??? <pdmos23@geocities.com>
Re: regex question (Tad McClellan)
Re: regex question <rrindels@arkansas.net>
Re: regex question (Abigail)
Re: Scripts for online Tests/Quizzes with Boolean calcu <rrindels@arkansas.net>
Re: sdbm record size restrictions (Eric Bohlman)
searching multiple sites <muhala@my-deja.com>
Re: stupid perl question (Eric Bohlman)
using %ENV with CGI <trent.mankelow@unisys.com>
Re: using @_ with subs (Just a quickie from a Perl Wann (Keith Calvert Ivey)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 12 Jul 2000 22:37:13 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Reading lines of a file within a loop?
Message-Id: <8kirup$10c$6@nntp9.atl.mindspring.net>
Tad McClellan (tadmc@metronet.com) wrote:
: On 11 Jul 2000 21:35:51 -0700, John Casey <John_member@newsguy.com> wrote:
:
: >
: >I need to write a script to scan a XML file for the lines containing the search
:
:
: You should be very sure that you really want to do this using
: a pattern match.
:
: Parsing XML with a real XML parser is a much safer way to go about it...
In this application, one of the parsers that outputs in PYX notation
(Matt Sergeant's XML::PYX from CPAN or my XML::TiePYX, which isn't yet on
CPAN but is available from
<URL:http://www.omsdev.com/ebohlman/perlmodules/>) would probably be the
best choice. PYX is a line-oriented notation, based on ESIS, in which
start tags, attribute name-value pairs, text content, and end tags each
get lines of their own, with the first character of the line determining
the type.
------------------------------
Date: Wed, 12 Jul 2000 23:03:17 GMT
From: Pasquale <pdmos23@geocities.com>
Subject: Re: reg expression not working. WHY???
Message-Id: <396CFAD5.212E6841@geocities.com>
Thanks, but it still is not working. Do I really need to use CGI.pm to
get this to work? I'm not too familiar with linking to that module. I
never have had to. The variables you suggested to be printed are
printing OK. It happen to be something I was trying previously to "see"
things.
This is the rest of the code following what I previously sent. I don't
know if it has anything to do with the problem. I don't think it would,
but....who knows. Thanks again!!
open(LOGFILE, "> test.tmp") || die "Can't open logfileB $!\n";
foreach $row(@entries) {
print LOGFILE "$row\n";
}
close(LOGFILE);
rename("test.tmp", "test.log") || die "Can't rename $!\n";
open(LOGFILE, "test.log") || die "Can't open logfileC $!\n";
@entry = <LOGFILE>;
close(LOGFILE);
print "Content-type: text/html\n\n";
print "<body>\n";
print "<table>\n";
foreach $line(@entry) {
@field = split(/::/, $line);
print "<tr><td>$field[2] <td>$field[3]<td>$field[1]<td>$field[0]\n";
}
print "</table>\n";
1;
Drew Simonis wrote:
> Pasquale wrote:
> >
> > The conditional statement
> > does not seem to be matching/working?? Thanks in advance!!
> > Pasquale
> >
> > $address = $formdata{'address'};
> > $price = $formdata{'price'};
>
> You aren't using CGI.pm, are you? Thats likely your third mistake.
> (I assume you haven't used -w or strict pragma either)
>
> > open(LOGFILE, "test.log");
>
> Should read: open LOGFILE, "test.log" or die "Can't open: $!\n";
>
> > @entries = <LOGFILE>;
> > close(LOGFILE);
> >
> > foreach $line(@entries) {
> > chomp($line);
> > @cells = split(/::/, $line);
> > if ($address eq $cells[3]) {
> > $cells[0] = $price;
> > last;
> > }
> > }
>
> Try this, its easier to type, but a little more cloudy. I'll also
> added some print statments that should make debugging easier. You'll
> remove them when you've seen the problem.
>
> for(@entries) { # work with the default $_ varible
> chomp; # works on $_ by default
> @cells = split /::/; # also works on $_ by default
> if ($address eq $cells[3]) {
> $cells[0] = $price;
> last;
> }
> }
>
> So, for a completed snippet (sans the CGI.pm way of getting data), we
> have:
>
> my $address = $formdata{'address'};
> my $price = $formdata{'price'};
>
> print $address, "\n";
> print $price, "\n";
>
> open LOGFILE, "test.log" or die "Can't open logfile: $!\n";
> chomp(@entries = <LOGFILE>); #nasty newlines
> close(LOGFILE);
>
> for(@entries)
> {
> @cells = split /::/;
> print $cells[3], "\n";
> if ($address eq $cells[3])
> {
> $cells[0] = $price;
> last;
> }
> }
>
> But you are aware that they array is being clobbered with
> each iteration. I'm sure thats why you've included the last
> command, but I just wanted to make sure.
------------------------------
Date: Wed, 12 Jul 2000 16:59:32 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: regex question
Message-Id: <slrn8mpn1k.88v.tadmc@magna.metronet.com>
On Wed, 12 Jul 2000 14:23:28 -0500, Rodney Rindels <rrindels@arkansas.net> wrote:
>I am using Mason and mod_perl on apache. The question I have is in regards
>to matching a password string , strict is in use by default under Mason.
>
> if ($pass1=~/[!@#$%^&*()]/){
^^
^^
The value of the $% variable is zero :-)
You are doing it backwards too.
You are testing for bad chars. What if you forget one (like semicolon)?
It is much safer to state what you _will_ allow, rather than
what you won't allow.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 12 Jul 2000 17:57:09 -0500
From: "Rodney Rindels" <rrindels@arkansas.net>
Subject: Re: regex question
Message-Id: <CO6b5.334$PI1.32222@news-west.usenetserver.com>
Thanks for the help.
The "affilliate site" my employer is attempting to connect to sets the list
of characters not to be used. I would normally do it the other way, but I
just work here :-) thanks..
Rodney
Tad McClellan <tadmc@metronet.com> wrote in message
news:slrn8mpn1k.88v.tadmc@magna.metronet.com...
> On Wed, 12 Jul 2000 14:23:28 -0500, Rodney Rindels <rrindels@arkansas.net>
wrote:
> >I am using Mason and mod_perl on apache. The question I have is in
regards
> >to matching a password string , strict is in use by default under Mason.
> >
> > if ($pass1=~/[!@#$%^&*()]/){
> ^^
> ^^
>
> The value of the $% variable is zero :-)
>
>
> You are doing it backwards too.
>
> You are testing for bad chars. What if you forget one (like semicolon)?
>
> It is much safer to state what you _will_ allow, rather than
> what you won't allow.
>
>
>
> --
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------------------------------
Date: 12 Jul 2000 20:28:07 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: regex question
Message-Id: <slrn8mq4a1.dun.abigail@alexandra.delanet.com>
Rodney Rindels (rrindels@arkansas.net) wrote on MMDVII September MCMXCIII
in <URL:news:mG3b5.4$PI1.1342@news-west.usenetserver.com>:
@@ I am using Mason and mod_perl on apache. The question I have is in regards
@@ to matching a password string , strict is in use by default under Mason.
@@
@@ if ($pass1=~/[!@#$%^&*()]/){
@@ #cannot continue to register
@@ } else {
@@ #ok register
@@ }
@@
@@ I thought this would not allow the character in the [] to be in the string
@@ ,
@@ but this also fails if a 0 is in the string all other numeric values work
@@ correctly. It does not matter where the 0 is in the string whether
@@ $pass1="foo0" or $pass1="10" or $pass1="0bar"
perl -wle 'print $%' will enlight you.
Abigail
--
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
-> define ("foldoc", "perl")) [0] -> print'
------------------------------
Date: Wed, 12 Jul 2000 17:59:53 -0500
From: "Rodney Rindels" <rrindels@arkansas.net>
Subject: Re: Scripts for online Tests/Quizzes with Boolean calculation ?
Message-Id: <cR6b5.356$PI1.33139@news-west.usenetserver.com>
I could write you one for say $100.00 an hour + all the jolt I can drink?
Edward <Dedwahl@usa.net> wrote in message
news:396cca65.8928721@news.cybercity.dk...
> Dear Friends,
>
> I am in need of interactive Perl scripts that can handle
> a quiz/test on a webpage where you have two choices at each
> question/line and then do some Boolean calculations like:
>
> IF (LINE 1 = FALSE) AND (LINE 2 = TRUE) THEN
>
> create a certain predefined line in the response page sent
> back as the reply to the finished testpage.
>
> In fact I want to make a similar test to the one found on
> http://www.careerdiscovery.com/fastcompany/
>
> I have searched many Perl archives but only found more
> or less the same test/quiz scripts - but they only seam to
> ad true score (and may be calculate averages, % levels
> etc. and NOT doing Boolean calculations).
>
> I would appeciate very much if you could help me find
> suitable scripts (not necessarily free- or sharewre).
>
>
> Regards Edward Wahl
> (delete "D" in email address)
>
------------------------------
Date: 12 Jul 2000 23:02:23 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: sdbm record size restrictions
Message-Id: <8kitdv$10c$7@nntp9.atl.mindspring.net>
desarollador@my-deja.com wrote:
: I am developing a quick and dirty application on
: NT (not my choice) and so there is no DB_File,
: etc. for storing hash-tied data. I have read
: that the record restriction (1K) in SDBM can be
: modified, but I have not been able to find out
: how. Thanks for any and all help.
You can get a pre-compiled DB_File from ActiveState; that's almost
certainly the best option.
------------------------------
Date: Wed, 12 Jul 2000 23:41:58 GMT
From: Nitin <muhala@my-deja.com>
Subject: searching multiple sites
Message-Id: <8kivo3$b2v$1@nnrp1.deja.com>
Hi,
I'm trying to write a script that will allow a user to enter a search
term and have it searched over multiple web sites. The problem I am
running into is that some of these sites that I am searching are
password protected. I have access to the sites and I know how to deal
with sites that are using the standard web server authentication (where
the browser pops up the the userid/password challenge box). How do I
deal with sites that have set up their own authentication mechanism
(via a custom logon page) like the one at
http://www.nytimes.com/auth/login
Any input is appreciated.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 12 Jul 2000 22:07:35 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: stupid perl question
Message-Id: <8kiq77$10c$3@nntp9.atl.mindspring.net>
NP (nvp@spamnothanks.speakeasy.org) wrote:
: I'm surprised that folks in this NG still bother arguing/rationalizing
: with trolls. I've learned two things about the behavior of a troll:
: (a) the troll is indeed lacking a clue or (more likely) (b) the troll
: is clever enough to piss you off and likes when you get bent out of
: shape. Since I don't particularly appreciate either of those things, I
: tend to ignore (what I perceive as trolls) completely.
:
: It just doesn't seem worth getting upset about.
Under most circumstances, you'd be right. However, our troll was giving
newbies bad programming advice, and many of us felt it necesary to correct
it in order to keep the newbies from passing it on to others.
Unfortunately, as the "beyond Perl" thread shows, Perl has a poor
reputation among lots of management types simply because there's no
marketing effort behind it, and people writing sloppy code in Perl only
makes the situation worse.
------------------------------
Date: Thu, 13 Jul 2000 12:53:33 +1200
From: "Trent Mankelow" <trent.mankelow@unisys.com>
Subject: using %ENV with CGI
Message-Id: <8kj3t8$k3b$1@mail.pl.unisys.com>
I'm trying to do some CGI stuff with HTTPd 1.5 (I know it's old school, but
it's what my client has), and use several modules from the base script
(called generate_html.pl). The trouble is that when I use the line:
use lib "$ENV{NIKAUHOME}/lib";
to add the lib directory to @INC, it comes back and tells me that it can't
find the environment variable $NIKAUHOME. I've got a setup script that sets
this variable by "sourcing" a file that has the following line in it:
setenv NIKAUHOME /home/peri/nikau
Even after I run this script, it still comes back and says it can't find any
environment variable called $NIKAUHOME. What's going on? Do I have to stop
and start the server or something? Somehow tell HTTPd that this variable has
been set?
TIA
Trent
------------------------------
Date: Thu, 13 Jul 2000 00:19:51 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: using @_ with subs (Just a quickie from a Perl Wannabe :)
Message-Id: <396f0a8c.1764074@nntp.idsonline.com>
Drew Simonis <care227@attglobal.net> wrote:
>&error; # fine, no args thou.
>error(); # same as above
Not quite. Check perlsub. The version with & and no
parentheses uses makes the current @_ visible to the subroutine.
Thus, it's the same as error(@_), not error(). But that's not
quite right, either, since the & disables prototype checking of
arguments.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
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 3645
**************************************