[16335] in Perl-Users-Digest
Perl-Users Digest, Issue: 3747 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 19 11:10:27 2000
Date: Wed, 19 Jul 2000 08: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: <964019416-v9-i3747@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 19 Jul 2000 Volume: 9 Number: 3747
Today's topics:
Re: Search and replace with a large amount of text <aqumsieh@hyperchip.com>
Re: Set cookie after sending text? <jbritain@home.com>
Re: Set cookie after sending text? (Keith Calvert Ivey)
Re: Sign Up Script <mrclyde@bolomail.dyn.dhs.org>
Re: Taint mode question (M.J.T. Guy)
Re: Truly Orthogonal Persistence (M.J.T. Guy)
Re: upper case first (Keith Calvert Ivey)
Re: upper case first <sariq@texas.net>
Re: What does this mean? <graham.wood@iona.com>
Re: What does this mean? <graham.wood@iona.com>
Re: What does this mean? <bart.lateur@skynet.be>
Re: why does this not work? (M.J.T. Guy)
Re: why does this not work? <foo@bar.va>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 19 Jul 2000 14:54:33 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Search and replace with a large amount of text
Message-Id: <7asnt6i312.fsf@merlin.hyperchip.com>
Richard Lawrence <ralawrence@my-deja.com> writes:
> I wonder if anyone can help? I need to load in a reasonably large
> amount of text and do some searches and replaces on it (which could
> span several lines). I don't know how big the text will be (it will
> vary) but I do know its going to be large.
It depends on the nature of the changes you want to make. Can you be
more specific?
> Now I could do:
>
> my $contents = "";
> open(FILE, "text") || die "erk: $!";
> while (<FILE>)
> {
> $contents .= $_;
> }
> close FILE;
>
> but the text file could be larger than the maximum limit $contents can
> hold.
There is no maximum limit on scalar variables in Perl (except the
physical limit imposed by the amount of memory your computer holds).
> I can't load each line and process individually as some of the searches
> and replaces will span over several lines.
>
> So, what on earth can I do? Should I just use sed and be done with it
> or is there a good approach?
You should read the FAQs. In perlfaq6:
I'm having trouble matching over more than one line. What's wrong?
--Ala
------------------------------
Date: Wed, 19 Jul 2000 13:14:51 GMT
From: Jim Britain <jbritain@home.com>
Subject: Re: Set cookie after sending text?
Message-Id: <+ah1OTLLkdsOWUdTQ9aQTWoH5Wtd@4ax.com>
[mailed and posted]
On Wed, 19 Jul 2000 06:30:03 GMT, Charles Weaver
<charles_weaver@post.harvard.edu> wrote:
>The only time I have been successful in setting a cookie in a .cgi program
>is if the first header I print is:
> print "Set-Cookie..."
>
>If I have already printed some html text the Set-Cookie line simply shows
>up on the screen as text. Is there a way to set a cookie in a program that
>has already sent text to the screen?
#1. This question belongs in a group discussing servers, or web
programming, not Perl.
#2. In answer to your question, NO, Once the HTML has started, you
cannot send a cookie -- a cookie part of the httpd transaction, which
all occurs in the invisible (to the normal user) headers that occur
before the HTML code.
------------------------------
Date: Wed, 19 Jul 2000 12:51:11 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Set cookie after sending text?
Message-Id: <3979a38f.37996542@news.newsguy.com>
Charles Weaver <charles_weaver@post.harvard.edu> wrote:
>The only time I have been successful in setting a cookie in a .cgi program
>is if the first header I print is:
> print "Set-Cookie..."
>
>If I have already printed some html text the Set-Cookie line simply shows
>up on the screen as text. Is there a way to set a cookie in a program that
>has already sent text to the screen?
This is not a Perl question. It's the same in any language.
You can't send header lines after you've finished sending the
header lines and started sending the content.
Maybe you want to save your HTML in a variable and print it when
you've decided what cookie to set.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
(Free at last from the forced spamsig of
Newsfeeds.com, cursed be their name)
------------------------------
Date: Wed, 19 Jul 2000 09:48:58 -0400
From: "MrClyde" <mrclyde@bolomail.dyn.dhs.org>
Subject: Re: Sign Up Script
Message-Id: <8l4buo$12v6$1@news.gate.net>
Thanks Alex. Yes, I have done searches,as you suggested, many times and have
dropped a large number of emails over a period of days but replys have been
nil. Coincidently, I have had 2 replies in the past 30 minutes. One from
someone in this newsgroup and one from the freelance Perl group. So, I will
consider them and perhaps even get a few more posts.
Thanks for your time.
Clyde
"Alex T." <samara_biz@hotmail.com> wrote in message
news:39759BBA.692AB269@hotmail.com...
> What he was saying is that if you go to, say, www.yahoo.com and type "sign
up
> script" in the search box, it will give you a huge number of links to the
> web-sites where you can get the script that you need. Password
protection/Sign
> up scripts are pretty common.
>
> It's a different case if you need a script to with in IIS/Windows NT.
There's
> not that many of them, but in that case you should have said what platform
> you're using.
>
> Alex
>
> MrClyde wrote:
>
> > Thanks for your gracious reply. That's exactly what I have been trying
to do
> > for two weeks.
> >
> > "Abigail" <abigail@delanet.com> wrote in message
> > news:slrn8nap38.3do.abigail@alexandra.delanet.com...
> > > MrClyde (mrclyde@bolomail.dyn.dhs.org) wrote on MMDXIV September
MCMXCIII
> > > in <URL:news:8l3dhj$thq$1@news.gate.net>:
> > > )) Does anyone know where I can get a script to work with an account
sign
> > up
> > > )) forms page? I need something that determines if the client's
requested
> > > )) account name is available and if 2 password enteries they are
required
> > to
> > > )) fill in are identical prior to the form being processed.
> > >
> > >
> > > Hire a programmer.
> > >
> > >
> > >
> > > Abigail
> > > --
> > >
> >
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47
> > ]
> > >
> >
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W
> > ]
> > >
> >
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^
> > V
> > > %$^U;$^V/=$^U}while$^V!=$^W'
>
------------------------------
Date: 19 Jul 2000 13:52:34 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Taint mode question
Message-Id: <8l4br2$2cc$1@pegasus.csx.cam.ac.uk>
Jonathan C. Dunn <jondunn@speakeasy.org> wrote:
>
>I've created the "safe backticks" construction from the perlsec man page.
Did you absorb the comment before that example?
Here's a way to do backticks reasonably safely. Notice how
the exec is not called with a string that the shell could
expand. This is by far the best way to call something that
might be subjected to shell escapes: just never call the
shell at all.
>1) Why can I pass in all of @ARGV to exec with no problem, but when I pass
>$ARGV[0] I get "insecure dependency..." ?
That's the distinction between exec with one argument using the shell
and exec with more than one not using the shell. As perlsec puts it:
exec "echo $arg"; # Insecure
exec "echo", $arg; # Secure (doesn't use the shell)
exec "sh", '-c', $arg; # Considered secure, alas!
>2) What alternatives are there (to the exec construction)? I can stick an
>"undef" onto the array, but that louses up some functions...
Errr.. alternatives for doing what? If you want the exec() functionality,
Perl's exec() function is the easiest way of getting it. That's what
it was provided for. :-)
Mike Guy
------------------------------
Date: 19 Jul 2000 13:21:58 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Truly Orthogonal Persistence
Message-Id: <8l4a1m$su$1@pegasus.csx.cam.ac.uk>
In article <8l254t$23d$1@nnrp1.deja.com>, <newsvan33@hotmail.com> wrote:
>I've noticed the common object serialization schemes are not truly
>orthogonal either: for instance when I try to serialize CPAN objects
>like DBI or CGI.pm handles using FreezeThaw or Data::Dumper,
>and then thaw them out, bad things happen. (It does seem
>to work fine for my own objects that I define, however.) Some sample
>code demonstrating this is appended to the end of this article.
The problem here is that the objects aren't true Perl structures;
rather they are a mix of Perl structures and pointers to C structures.
Any mechanism to serialise them correctly has to know about the DBI
internal structures (and will have to be written at least partly in C).
And you've just re-invented the DBI module.
Mike Guy
------------------------------
Date: Wed, 19 Jul 2000 12:55:53 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: upper case first
Message-Id: <397aa481.38238607@news.newsguy.com>
bernard.el-hagin@lido-tech.net (Bernard El-Hagin) wrote:
>$_ = "mIcHael josepH soloMon";
>s/(\w+)/ucfirst (lc $1)/eg;
>print;
>
>That'll do it.
No need for /e.
s/(\w+)/\u\L$1/g;
I guess we're going to answer this question every day now.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
(Free at last from the forced spamsig of
Newsfeeds.com, cursed be their name)
------------------------------
Date: Wed, 19 Jul 2000 09:30:21 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: upper case first
Message-Id: <3975BB7D.38411327@texas.net>
mike solomon wrote:
>
> I need to convert a name to be lower case but with the first letter as
> uppercase
FAQ.
perldoc -q capitalize
- Tom
------------------------------
Date: Wed, 19 Jul 2000 14:20:16 +0100
From: "Graham Wood" <graham.wood@iona.com>
Subject: Re: What does this mean?
Message-Id: <8l4a9i$ohi$1@bvweb.iona.com>
It's doing this:
1. reading input lines from filehandle F
2. removing newlines
3. splitting the remaining line into a part before "=" and a part after "="
.
2. prepending property\ to the part before the "="
3. putting the part after the "=" into a hash called %headinter using the
property\part before "=" as the key.
Name=Graham
Skill=None
Helpful=slightly more
in your file F will give you 3 entries in the headinter hash with keys of
Name, Skill and Helpful and values of Graham, None and slightly more.
Syntax like this will access the values using the keys.
$value= $headinter{"property\Name"};
will put the value "Graham" into $value.
print $headinter{"Skill"};
will print "None"
Graham
Taurean <jaurangNOjaSPAM@crosswinds.net.invalid> wrote in message
news:010b13aa.d8f4b80a@usw-ex0108-061.remarq.com...
> Does anybody know what this means?
>
> while (<F>) {
> chomp;
> @pare=split(/=/);
> $pare[0]="property\\"."$pare[0]";
> $headinter{"$pare[0]"}=$pare[1];
> }
>
> TIA.
>
>
> * 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: Wed, 19 Jul 2000 14:25:18 +0100
From: "Graham Wood" <graham.wood@iona.com>
Subject: Re: What does this mean?
Message-Id: <8l4aj1$oj9$1@bvweb.iona.com>
I can count up to five really.
Graham Wood <graham.wood@iona.com> wrote in message
news:8l4a9i$ohi$1@bvweb.iona.com...
> It's doing this:
> 1. reading input lines from filehandle F
> 2. removing newlines
> 3. splitting the remaining line into a part before "=" and a part after
"="
> .
> 2. prepending property\ to the part before the "="
> 3. putting the part after the "=" into a hash called %headinter using the
> property\part before "=" as the key.
>
> Name=Graham
> Skill=None
> Helpful=slightly more
>
> in your file F will give you 3 entries in the headinter hash with keys of
> Name, Skill and Helpful and values of Graham, None and slightly more.
> Syntax like this will access the values using the keys.
>
> $value= $headinter{"property\Name"};
>
> will put the value "Graham" into $value.
>
> print $headinter{"Skill"};
>
> will print "None"
>
> Graham
>
> Taurean <jaurangNOjaSPAM@crosswinds.net.invalid> wrote in message
> news:010b13aa.d8f4b80a@usw-ex0108-061.remarq.com...
> > Does anybody know what this means?
> >
> > while (<F>) {
> > chomp;
> > @pare=split(/=/);
> > $pare[0]="property\\"."$pare[0]";
> > $headinter{"$pare[0]"}=$pare[1];
> > }
> >
> > TIA.
> >
> >
> > * 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: Wed, 19 Jul 2000 14:15:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: What does this mean?
Message-Id: <8rdbnss77f9qg05p8lvn3mac6tv5k5ui8d@4ax.com>
Taurean wrote:
>Does anybody know what this means?
>
>while (<F>) {
> chomp;
> @pare=split(/=/);
> $pare[0]="property\\"."$pare[0]";
> $headinter{"$pare[0]"}=$pare[1];
>}
It will read key/value pairs (not "pares") of properties, for example:
name=Taurean
and populate the hash %headinter with it. Once this line is processed,
the entry for 'property\name' will be "Taurean".
--
Bart.
------------------------------
Date: 19 Jul 2000 13:05:29 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: why does this not work?
Message-Id: <8l492p$a3$1@pegasus.csx.cam.ac.uk>
Ala Qumsieh <aqumsieh@hyperchip.com> wrote:
>
>mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:
>>
>> That's perl4. Upgrade.
>
>I don't think so. Perl4 will give you:
>
> Unquoted string "chomp" may clash with future reserved word ..
>
>I suspect there is a missing semicolon at the end of the line before the
>chomp()?
That *is* Perl4. "next 2 tokens" is the giveaway.
There may well be other errors, of course.
Mike Guy
------------------------------
Date: Wed, 19 Jul 2000 15:24:21 +0200
From: Marco Natoni <foo@bar.va>
Subject: Re: why does this not work?
Message-Id: <3975AC05.5DC863D0@bar.va>
Ala
Ala Qumsieh wrote:
> Perl4 will give you:
> Unquoted string "chomp" may clash with future reserved word ..
Really prophetic...
Best regards,
Marco
------------------------------
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 3747
**************************************