[22565] in Perl-Users-Digest
Perl-Users Digest, Issue: 4786 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 30 09:05:47 2003
Date: Sun, 30 Mar 2003 06:05:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 30 Mar 2003 Volume: 10 Number: 4786
Today's topics:
Re: And... <tore@aursand.no>
Re: And... <tore@aursand.no>
Re: And... <tassilo.parseval@rwth-aachen.de>
Re: And... <amiba128@sd6.so-net.ne.jp>
Re: CGI.pm or roll-your-own? <tore@aursand.no>
Re: CGI.pm or roll-your-own? <noreply@gunnar.cc>
Re: DBI problem <bigus NO @ SPAM creationfactor .net>
Re: help understand dereferencing <uri@stemsystems.com>
Re: help understand dereferencing chance@austin.rr.com
Re: help understand dereferencing <hiro@asari.net>
Re: help understand dereferencing <grazz@nyc.rr.com>
Re: help understand dereferencing <goldbb2@earthlink.net>
Re: help understand dereferencing chance@austin.rr.com
Re: Multiple POSTS and GETS from one perl script <meanblue@rascalsdesign.biz>
Re: Multiple POSTS and GETS from one perl script <tore@aursand.no>
Re: Please tell me I'm beginner <amiba128@sd6.so-net.ne.jp>
Re: simple substitution also changes line endings (Tuang)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 30 Mar 2003 10:25:35 +0200
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: And...
Message-Id: <pan.2003.03.30.02.26.34.682437@aursand.no>
On Sat, 29 Mar 2003 23:26:53 +0000, Tassilo v. Parseval wrote:
>>> Excuse me, Mr. Parseval !
>>> It was careless.
>>> I'd forgot the fact it was crosspost,
>>> because it's been long time since my last post.
>>> Entschuldigen Sie, Herr Parseval !
>>> Es war unaufmerksam von mich.
>>> Volkkommen haben ich verlernt,
>>> denn seit meiner letzter Post viel Zeit genommen hast.
>> I'm very sure that Tassilo understands English. If not, why the h*ll
>> would he write his own messages in English?
> Oh, don't worry. It was probably just meant to be a nice gesture by the
> OP which I don't mind at all. Too bad my Japanese has escaped me lately
> so I can't get my own back. :-)
What planet are you from? That's not Japanese. That's German! :) Really.
It is.
--
Tore Aursand
------------------------------
Date: Sun, 30 Mar 2003 10:25:36 +0200
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: And...
Message-Id: <pan.2003.03.30.02.27.12.170784@aursand.no>
On Sat, 29 Mar 2003 23:26:53 +0000, Tassilo v. Parseval wrote:
>>> Entschuldigen Sie, Herr Parseval !
>>> Es war unaufmerksam von mich.
>>> Volkkommen haben ich verlernt,
>>> denn seit meiner letzter Post viel Zeit genommen hast.
>> I'm very sure that Tassilo understands English. If not, why the h*ll
>> would he write his own messages in English?
> Oh, don't worry. It was probably just meant to be a nice gesture by the
> OP which I don't mind at all. Too bad my Japanese has escaped me lately
> so I can't get my own back. :-)
What planet are you from? That's not Japanese. That's German! :)
Really!
--
Tore Aursand
------------------------------
Date: 30 Mar 2003 08:43:38 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: And...
Message-Id: <b66anq$jr2$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Tore Aursand:
> On Sat, 29 Mar 2003 23:26:53 +0000, Tassilo v. Parseval wrote:
>>>> Entschuldigen Sie, Herr Parseval !
>>>> Es war unaufmerksam von mich.
>>>> Volkkommen haben ich verlernt,
>>>> denn seit meiner letzter Post viel Zeit genommen hast.
>
>>> I'm very sure that Tassilo understands English. If not, why the h*ll
>>> would he write his own messages in English?
>
>> Oh, don't worry. It was probably just meant to be a nice gesture by the
>> OP which I don't mind at all. Too bad my Japanese has escaped me lately
>> so I can't get my own back. :-)
>
> What planet are you from? That's not Japanese. That's German! :) Really.
> It is.
Well, I should know that, too, considering the fact that I speak German
rather well. ;-) When a Japanese addresses me in my mother-tongue it
would only be fair for me to address him (or is the OP a she?) in
Japanese which I unfortunately can't.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 30 Mar 2003 07:19:45 -0600
From: "Ami" <amiba128@sd6.so-net.ne.jp>
Subject: Re: And...
Message-Id: <3e86edf4$0$9631$45beb828@newscene.com>
Ja. Ich bin Japane.
Gerich gewusst ich habe, dass in Nordrhein-Westfalen, Deutschland Sie wohnen.
Ich kan als Deutsch besser denn als Englisch sprechen.
Aber gut kan ich sprechen nicht.
Und ich wolle den widig Kerl wer aufreizend mit mir sprach beachten.
Danke,
Ami,
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message
news:b66anq$jr2$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach Tore Aursand:
>
> > On Sat, 29 Mar 2003 23:26:53 +0000, Tassilo v. Parseval wrote:
>
> >>>> Entschuldigen Sie, Herr Parseval !
> >>>> Es war unaufmerksam von mich.
> >>>> Volkkommen haben ich verlernt,
> >>>> denn seit meiner letzter Post viel Zeit genommen hast.
> >
> >>> I'm very sure that Tassilo understands English. If not, why the h*ll
> >>> would he write his own messages in English?
> >
> >> Oh, don't worry. It was probably just meant to be a nice gesture by the
> >> OP which I don't mind at all. Too bad my Japanese has escaped me lately
> >> so I can't get my own back. :-)
> >
> > What planet are you from? That's not Japanese. That's German! :) Really.
> > It is.
>
> Well, I should know that, too, considering the fact that I speak German
> rather well. ;-) When a Japanese addresses me in my mother-tongue it
> would only be fair for me to address him (or is the OP a she?) in
> Japanese which I unfortunately can't.
>
> Tassilo
> --
> $_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
> pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
> $_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sun, 30 Mar 2003 10:25:35 +0200
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <pan.2003.03.30.02.24.41.116154@aursand.no>
On Sat, 29 Mar 2003 23:32:09 +0100, Gunnar Hjalmarsson wrote:
>> On the other hand, we have pointed out at least 2-3 good reasons to why
>> you should use the CGI module.
> I have counted one.
Well, most of them boils down to only _one_ good reason. On the other
hand, that reason is superior to _everything_ when it comes to production
code; maintainability.
A couple of years ago there were _thousands_ of scripts using CGI.pm on
the web. Nobody had ever heard about DoS (for instance). Then DoS rose
from hell, and scripters shivered.
Thanks to CGI.pm, there where only _one_ file on the planet that needed
correction. That same file was uploaded to _one_ site (CPAN). All those
who had been using CGI.pm could use _one_ utility to update their server.
I agree with you on one thing, and one thing only; To find out how a
wheel works, it's most probably a good thing to reinvent it. But, as it
is in this case, that reinvention won't do any good for production code.
You still don't have _one_ good reason for why you're using insecure code
and methods in your production code. And that's good, 'cause there are no
good reasons for that.
--
Tore Aursand
------------------------------
Date: Sun, 30 Mar 2003 12:00:34 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b66f91$23ggn$1@ID-184292.news.dfncis.de>
Steve Grazzini wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>>\n in for instance the subject field in a form (at least a form that
>>submits using the POST method) ends up in nothing but literally '\n'
>>as part of the message subject. The same with %0A etc. But if the
>>querystring is parsed, %0A results in a newline, so the request method
>>does make a difference. [...]
>
> The only difference I see is between data that the browser URI-escapes
> (i.e. what you've typed in an HTML form) and data that it passes along
> untouched (what you've typed in the "address" bar).
>
> But that's browser behavior.
Hmm.. Without having tested with 'clean' HTTP requests, I'm ready to
admit that I was probably wrong. My observations seem to have shown a
difference between typing things in a form field and typing them in
the address bar rather than a difference between the POST and the GET
request methods.
Thanks for clarifying, Steve.
>>To summarize, there are three reasons why %0A etc. can't hurt:
>>- The fact that only POST requests are supported
>>- The Mail::Sender feature you mentioned
>>- The fact that the module does "s/\s+/ /g;" with the values of
>> the header fields
>
> Okay... mea culpa. I missed the whitespace-collapsing, which seems
> like a fine way to address the problem.
And thanks for that recognition. I seem to need that these days. ;-)
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 30 Mar 2003 12:44:35 +0100
From: "Bigus" <bigus NO @ SPAM creationfactor .net>
Subject: Re: DBI problem
Message-Id: <KMAha.876$V24.184@newsfep4-winn.server.ntli.net>
"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3E85EE08.620EC54B@earthlink.net...
[..]
> > I was largely hoping that due the predicted usage of it and the
> > unlikelihood of actions like creating tables and inserting rows
happening at
> > exactly the same time that this problem wouldn't crop up and if it did,
I
> > could fix the DB manually.
> > I guess it wouldn't be difficult for me to create a temp file, before
the
> > table is created or a row is inserted, put a flag in it, then delete the
> > file after the action. Then if someone else comes along and tries the
same
> > thing, the script would check for the presence of the flag and if it
finds
> > it waits for a period of time.
>
> Unless you create the file using sysopen(), with the O_CREAT|O_EXCL flags,
> there's *still* a race condition here.
Unless I give each "lock" file a unique name, like "lock-1234.txt",
"lock-3456", etc using a number randomly generated. Then when an instance of
the script comes to performing a write task on the DB, it can check all
files "lock-". In each file there could be a time stamp and the name of the
table requiring locking (there is a table per newsgroup amd about 5
newsgroups). If the instance wants to amend a "locked" table it first of all
checks the elapsed time between the timestamp in the file and present. If
this is greater than the timeout length of the web server, then it assumes
the lock file hasn't been deleted properly by a previous instance of the CGI
and deletes it, and carries on with updating the DB. Otherwise it loops or
sleep/loops until the lock is freed.
> Oh, and having it wait for a period of time isn't exactly the greatest
> thing in the world, since you may end up keeping the connection alive
> overly long -- it's ok to sleep for a little while, but if you can't get
> the lock quickly enough, have the browser disconnect and try again later.
> See:
> http://www.stonehenge.com/merlyn/WebTechniques/col54.html
>
> > However, that raises the question of what happens if someone hits the
> > stop button their browser and the temp file/flag isn't deleted..
> > hmmmm.. if you know any websites that discuss methods of
> > locking/queueing processes like this, please let me know.
>
> If you're on *nix, then you can lock a filehandle using flock().
>
> If the process exits, the filehandle is automatically unlocked.
>
> On windows... I'm not sure. However, I believe that Access offers
> locking of database tables, through a "LOCK <tablename>" statement.
>
> Make sure that you turn off $dbh->{AutoCommit} before acquiring a lock
> using this method.
Interesting. To be honest, I don't have a full grasp of that article (what's
a sentinel file?), so I'd need to sit down a and read it several more times
and experiment with test scripts. If my above solution is feasible then I
might escape that ;-)
> However... You might not *need* to do any such thing -- if, on inserting
> your rows, you do something like:
>
> $dbh->do( qq{
> INSERT INTO $groupdb
> (article, poster, refs, subject, thedate, client, messageid)
> VALUES (
> (SELECT MAX(article)+1 from $groubdb),
> ?, ?, ?, ?, ?, ?
> )
> }, {}, $poster, $refs, $subj, $date, $client, $messageid );
>
> This should, in a single statement, fetch the max article number, add
> one to it, and use it for inserting a new row.
>
> ... Assuming that that syntax is acceptable to Access. It might not
> be. If not, then use a different CREATE TABLE statement, to force
> the 'article' field for new rows to come from a sequence:
>
> CREATE TABLE IF NOT EXISTS $groubdb (
> article integer NOT NULL DEFAULT nextval('article_seq'),
The problem there is that the article number is the one from the header of
the news posting, and since I discovered a problem with the NNTPClient
module (or at least that's where the problem *seems* to come from) when
trying to retrieve the body of some messages using the messageid, it looks
like I am going to have to make sure I use the article id to do such
retrieving, so it needs to be the one from the header.
[..]
> > "[Microsoft][ODBC Microsoft Access Driver]String data, right truncated
on
> > column number 3 (refs) (SQL-01004)(DBD: st_fetch/SQLFetch (long
truncated
> > DBI attribute LongTruncOk not set and/or LongReadLen too small) err=-1)"
> >
> > Yikes! Any idea what that means? Is it something to do with the data in
> > column 3? It will either contain one or more references like this
> > "b7al8f.1d4.1@hamster.local.invalid#b3aln0.1l4.1@hamster.local.invalid"
or a
> > space " ".
>
> Obviously, the problem is that it contains a string which is longer than
> $dbh->{LongReadLen}. You'll have to increate $dbh->{LongReadLen} to be
> at least as long the longest 'ref' field... or, turn on
> $dbh->{LongTruncOk}, in which case it will throw away part of the data
> without complaining.
Yuk.. that sounds a bit messy on the part of DBI if you have to start
worrying about what length the string in a column in a record that you are
trying to retrieve is. There are numerous circumstances where you might need
to collect data of varying length and since a text field in Access can only
hold 255 chars, it is presumably quite common to need to use a memo field.
> A better solution might have been to set up a seperate table for refs,
> rather than storing it as a memo field.
>
> This would have been done as:
> CREATE TABLE IF NOT EXISTS refs (
> article integer NOT NULL REFERENCES $groubdb article,
> ref text(255) NOT NULL,
> idx integer NOT NULL DEFAULT nextval('ref_id_seq')
> )
>
> Thus, for each article, there'd be an ordered set of references, where
> each reference is one row in the 'refs' table. (The 'idx' column is
> there merely for an 'ORDER BY' clause for your SELECTs.)
>
> Figuring out things like this (knowing to use a seperate table instead
> of a memo field) is really a job for a DBA, not truly a perl-specific
> task.
Yeah, you are probably right. I'm not sure about having one reference per
row though. An individual message has a reference for each message above it
in the thread.. that is, if person1 starts the thread, person2 replies,
person3 replies to person2, then if you as person 4 comes along and replies
to person3, there will be 3 message id's in the references header field of
your message. That means the number of rows would build up rather quickly,
although Access has a limit of about 65k rows, IIRC. Maybe instead, I could
have a row per message and a column per reference. IIRC Access can have up
to 256 columns which should be more than enough.. I'd be more likely to hit
the 2k record size limit then. If an average msgid is say 40 chars then you
could only have 50 text columns.. it is still very uinlikely that you'd get
that many indentations on a thread though.
Hmmm.. or I could just leave the refs as a # separated string in a memo
field as it is at the moment ;-) So, in the DBI scheme of things, if I were
to set $dbh->{LongReadLen} to say 2k, would that be quite feasible?
Regards
Bigus
------------------------------
Date: Sun, 30 Mar 2003 05:15:35 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: help understand dereferencing
Message-Id: <x7brztzb7t.fsf@mail.sysarch.com>
>>>>> "c" == chance <chance@austin.rr.com> writes:
c> What should I read that I haven't read (or understood?)
c> I wasn't aware that 'my @test_array = @$array_ref; ' created an
c> array copy either.
remember, that when you deref an array/hash ref as the whole thing, it
is now a proper array/hash. how else would @foo = @bar work? same with
the above code.
c> You know how do get back the 'real thing' and not a copy? Is that just
c> no possible?
you don't dereference it. just work with the reference. copying the
whole array is not what you want so don't do it.
and read perlreftut and perlref for more.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 30 Mar 2003 05:29:48 GMT
From: chance@austin.rr.com
Subject: Re: help understand dereferencing
Message-Id: <b65vvt$t3u$1@localhost.localdomain>
"Jurgen Exner <jurgenex@hotmail.com> wrote:
> Your problem is not with references, but with assignments.
> Now, if you assign %test_hash = %myhash, what would you expect to happen
> when you modify an element in %test_hash? Will it change %myhash, too? No,
> it doesn't, because %test_hash is a _copy_ of %myhash, not a reference to
> %myhash.
Thank you. This was the source of my brain lock.
with %test_hash = %myhash, I was in fact expecting changes to either
to affect both..... not that I'd really thought about explicitly.
Just in the reptillian-C-programmer- part of my brain I was implicitly
assuming that anything as complicated as a hash is going to have
assignments done to/from (at some point even if hidden from
programmer) with a pointer copy, and not by actually creating a new
hash, and copying all the key value pairs.
So, is there some simple way to start with
my %my_hash;
and get
my %test_hash
to be just another name for the %my_hash?
(and typeglobs don't work on 'my' variables right?).
--
I used to think government was a necessary evil.
I'm not so sure about the necessary part anymore.
------------------------------
Date: Sat, 29 Mar 2003 23:44:02 -0600
From: "Hiro Asari" <hiro@asari.net>
Subject: Re: help understand dereferencing
Message-Id: <v8d10u9pomv970@corp.supernews.com>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
<chance@austin.rr.com> wrote in message
news:b65sd5$t1d$1@localhost.localdomain...
> In comp.lang.perl.misc gb2312 <gb2312@attbi.com> wrote:
> > I really think
>
> > my %test_hash = %$hash_ref;
>
> > should create a new copy, just like
That's exactly Perl does. Try this:
#!/usr/local/bin/perl -w
$aref={ 'a'=>0, 'b'=>1, 'c'=>2 };
%bref=%$aref;
$bref{'a'}=1;
print values %$aref;
print "\n";
print values %bref;
>
> > my @test_array = @$array_ref;
>
> > or
>
> > my $test_scalar = $$test_scalar;
>
> > which is quite consistent.
>
>
> Ahhhh .... I didn't think it should (in the documentation sense,
not
> the philosophical sense), but I thought it was. Hence my
consternation.
>
> What should I read that I haven't read (or understood?)
> I wasn't aware that 'my @test_array = @$array_ref; ' created an
array copy either.
>
> You know how do get back the 'real thing' and not a copy? Is that
just
> no possible?
Your confusion arises from the (ab)?use of 'my'.
>
> Chance
> --
> I used to think government was a necessary evil.
> I'm not so sure about the necessary part anymore.
Hiro
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - GPGOE 0.4.1
iD8DBQE+hoQboXhPvmJPsrERArjnAJ9CmGuTWEJyqUzufg2x9jKWxh/CaACfdbE/
h9CnAinmHsud5TH56cYgMgs=
=hJmu
-----END PGP SIGNATURE-----
------------------------------
Date: Sun, 30 Mar 2003 05:54:13 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: help understand dereferencing
Message-Id: <9Evha.17737$iE4.6172433@twister.nyc.rr.com>
chance@austin.rr.com wrote:
> "Jurgen Exner <jurgenex@hotmail.com> wrote:
>
>> it doesn't, because %test_hash is a _copy_ of %myhash,
>> not a reference to %myhash.
>
> Thank you. This was the source of my brain lock. [...]
>
> So, is there some simple way to start with
>
> my %my_hash;
>
> and get
>
> my %test_hash
>
> to be just another name for the %my_hash?
> (and typeglobs don't work on 'my' variables right?).
You can make an alias
my %a;
our %b; local *b = \%a;
$b{foo} = 'bar';
print "$a{foo}\n";
But usually you'll just work with the reference. The deref
syntax is reasonably compact, after all, and you're much less
likely to shoot yourself in the foot with it.
--
Steve
------------------------------
Date: Sun, 30 Mar 2003 01:15:44 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: help understand dereferencing
Message-Id: <3E868B90.836E3413@earthlink.net>
chance@austin.rr.com wrote:
>
> Jurgen Exner wrote:
>
>> Your problem is not with references, but with assignments.
>
>> Now, if you assign %test_hash = %myhash, what would you expect to
>> happen when you modify an element in %test_hash? Will it change
>> %myhash, too? No, it doesn't, because %test_hash is a _copy_ of
>> %myhash, not a reference to %myhash.
>
> Thank you. This was the source of my brain lock.
>
> with %test_hash = %myhash, I was in fact expecting changes to either
> to affect both..... not that I'd really thought about explicitly.
> Just in the reptillian-C-programmer- part of my brain I was implicitly
> assuming that anything as complicated as a hash is going to have
> assignments done to/from (at some point even if hidden from
> programmer) with a pointer copy, and not by actually creating a new
> hash, and copying all the key value pairs.
>
> So, is there some simple way to start with
>
> my %my_hash;
>
> and get
>
> my %test_hash
>
> to be just another name for the %my_hash?
> (and typeglobs don't work on 'my' variables right?).
Well, mostly not, but if you were to do:
sub test_sub($) {
our %test_hash;
local *test_hash = shift();
...
}
Then inside of test_sub, you should be able to access %test_hash as if
it were whatever you'd passed in.
If you *really* want a my(%test_hash), then you'd have to do:
use Devel::LexAlias; # from CPAN
sub test_sub($) {
my %test_hash;
lexalias(0, '%test_hash', shift());
...
}
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Sun, 30 Mar 2003 06:25:58 GMT
From: chance@austin.rr.com
Subject: Re: help understand dereferencing
Message-Id: <b663bk$t5u$1@localhost.localdomain>
Thanks everybody. I think I got it.
The cool thing about perl is that a lot of the time you can get away
with not always knowing exactly whats going on, and still get the job
done. This seemed like on of those exceptions where I really did need
to understand what was happening, so I appreciate help. Sorry the
final solution was as lame as me not understanding/noticing that '='
does in fact do a copy by value ... yes even for hashes.
One last question and I'll stop pestering :)
If I were to do the below, as Benjamin suggested, would that be thread
safe? i.e. if test_sub gets called at the same time from two different
threads, does each thread get its own copy of %test_hash, or are they
going to step all over each other?
> Well, mostly not, but if you were to do:
> sub test_sub($) {
> our %test_hash;
> local *test_hash = shift();
> ...
> }
I have never used an $our variable. Mostly just becuase I have had
to maintain too much crap in the universe with global variables, so
I've got a very string globals-are-bad-gag-reflex. Even for throw
away scripts.
Not knowing understanding if/how/why $our variables are thread safe
has been a pretty strong second reason not to use them.
In case you can't tell .... I've done a decent amount of perl, but its
always pretty much been throw aways scripts, even if they got pretty
complicated. Now I might get opportunity to write a real application,
you know, a program that has to run correctly more than once, and
actually have other people look at .... so I'm kind of seeing the
other side of perl for the first time.
--
I used to think government was a necessary evil.
I'm not so sure about the necessary part anymore.
------------------------------
Date: Sun, 30 Mar 2003 10:36:03 +0100
From: Andrew Newlands <meanblue@rascalsdesign.biz>
Subject: Re: Multiple POSTS and GETS from one perl script
Message-Id: <4ied8vs2l403tnk4nrnibfbhie9eb2th3n@4ax.com>
On Sat, 29 Mar 2003 21:37:27 +0100, "Tore Aursand" <tore@aursand.no>
wrote:
>On Sat, 29 Mar 2003 14:37:51 +0000, Andrew Newlands wrote:
>> I was wondering if there is a way of posting data to other scripts while
>> continuing to run the original script, branching off so that 2 scripts
>> are runnning on the webserver as opposed to one.
>
>You mean fork()'ing?
possibly...this is what I am trying to determine. Does fork()ing allow
you to post data to another script while continuing to run the one you
are on?
------------------------------
Date: Sun, 30 Mar 2003 14:45:33 +0200
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Multiple POSTS and GETS from one perl script
Message-Id: <pan.2003.03.30.12.12.33.381492@aursand.no>
On Sun, 30 Mar 2003 10:36:03 +0100, Andrew Newlands wrote:
>> You mean fork()'ing?
> possibly...this is what I am trying to determine. Does fork()ing allow
> you to post data to another script while continuing to run the one you
> are on?
Pretty irrelevant; POST'ing has something to do with the behaviour of the
HTTP protocol. As I understand it, you just need to pass a set of
arguments to your script. Wether you do it CGI wise or not, is up to you.
As long as you're using CGI.pm, there's no problem what-so-ever, as it's
all about reading data from STDIN anyways.
See 'perldoc -f fork' and 'perldoc CGI' for more information.
--
Tore Aursand
------------------------------
Date: 30 Mar 2003 07:19:40 -0600
From: "Ami" <amiba128@sd6.so-net.ne.jp>
Subject: Re: Please tell me I'm beginner
Message-Id: <3e86edf2$0$9631$45beb828@newscene.com>
Dear Gunnar !
I thank you very much for your advice.
With pleasure, I can tell you the solution of the problem.
Ami,
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:b645a0$1h9qt$1@ID-184292.news.dfncis.de...
> Ami wrote:
> > I want to set a cookie in a Web page.
> > And I wish to make the cookie disappears, when they close the browser.
> > How do I change the script ?
>
> You want to set a session cookie, which means that you don't need to
> bother about the expires parameter. This is enough for setting a
> session cookie:
>
> print "Set-cookie: $name=$value\n";
>
> Accordingly, you can skip everything about creating an expiration date.
>
> Hope that helps, and welcome back if you encounter any Perl related
> difficulties when proceeding.
>
> / Gunnar
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 29 Mar 2003 22:31:53 -0800
From: tuanglen@hotmail.com (Tuang)
Subject: Re: simple substitution also changes line endings
Message-Id: <df045d93.0303292231.649bb8d9@posting.google.com>
Benjamin Goldberg <goldbb2@earthlink.net> wrote :
>
> > > However, you would be better off if it were opened in the right mode
> > > to begin with; thus, write your script as:
> > >
> > > #!/cygdrive/c/Perl/bin/perl -w -i.bak -p
> > > use open IN => ":raw", OUT => ":raw";
> > > # insert processing code here:
> > > y/A/X/;
> > > __END__
> >
> > I tried this (inserting the "use ..." line, and without any "binmode
> > ..." line) and it didn't work. I didn't get any errors or warnings,
> > but it still converted 0A line endings to 0D 0A.
>
> Strange. I don't know why it didn't work.
And I spoke too soon when I said that "binmode ARGVOUT;" was working.
It turns out that my problem of having it convert my unix (LF) text
files to dos (CR-LF)has been fixed. Unix files now stay Unix, but my
DOS files now convert to Unix!
In other words, here is the complete source:
============================= BEGIN
#!/cygdrive/c/Perl/bin/perl -w -i.bak -p
no warnings 'once'; # Supresses 'ARGVOUT used only once' warning
# following line doesn't appear to do anything, so it's commented out
#use open IN => ":raw", OUT => ":raw";
binmode ARGVOUT;
# Insert the processing code here:
s/A/X/g;
============================= END
With this code, a file with 0A (LF) line endings doesn't have them
converted to 0D 0A (CR-LF) anymore. But now unfortunately all the 0D
0A line endings get converted to 0A.
Here's some more info: if I run this from Cygwin, unix (LF) files are
left as unix files, but DOS files (CR-LF) are changed to Unix (LF)
files. If I run it from the Windows command prompt ("from a DOS
prompt"), I get the reverse. Unix files are changed to DOS files, but
DOS files are left as DOS files.
It's the same ActiveState Perl that runs, either way. "perl -v" from
either command line returns the same:
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
So I'm still looking for generic filter wrapper code that I can reuse
on all platforms that support Perl to process any arbitrary sequence
of bytes and have it make only the changes I specify to those bytes
and no other.
Is this extraordinarily difficult in Perl or is it just difficult for
me. ;-)
Thanks.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4786
***************************************