[25073] in Perl-Users-Digest
Perl-Users Digest, Issue: 7323 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 27 14:10:52 2004
Date: Wed, 27 Oct 2004 11:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 27 Oct 2004 Volume: 10 Number: 7323
Today's topics:
Re: HOW TO replace ' but not ?' <whitey@newmail.net>
Re: HOW TO replace ' but not ?' <whitey@newmail.net>
Re: HOW TO replace ' but not ?' <whitey@newmail.net>
Re: HOW TO replace ' but not ?' <mritty@gmail.com>
Re: MAIL recommendation <nospam@nospam.com>
Re: MAP question <mritty@gmail.com>
Re: MAP question <do-not-use@invalid.net>
Re: MAP question <ThomasKratz@REMOVEwebCAPS.de>
Re: MAP question <1usa@llenroc.ude.invalid>
Re: MAP question (Anno Siegel)
Re: Modify program to write just data to a text file. <1usa@llenroc.ude.invalid>
Re: Modify program to write just data to a text file. <noreply@gunnar.cc>
Re: Modify program to write just data to a text file. <1usa@llenroc.ude.invalid>
Re: Modify program to write just data to a text file. <noreply@gunnar.cc>
Re: open-perl-ide qustion <nospam@nospam.com>
Re: What's the seed? ctcgag@hotmail.com
Re: What's the seed? ctcgag@hotmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 27 Oct 2004 11:36:27 -0500
From: Whitey Johnson <whitey@newmail.net>
Subject: Re: HOW TO replace ' but not ?'
Message-Id: <pan.2004.10.27.16.36.27.99401@newmail.net>
On Wed, 27 Oct 2004 15:30:23 +0200, tor muttered incoherently:
> Hello
> I want to put a new line after each ', but not after ?'.
> If someone are familiare with edifact they understand.
>
> AAA+Tim?'s'BBB+123'
>
> should become
>
> AAA+Tim?'s'
> BBB+123'
>
> anyone???
>
> Torfinn
Ooooh oooh oooh!!
I wanna give this a try before I look at the other respones:
#!/usr/bin/perl
use strict;
use warnings;
my $line = "AAA+Tim?'s'BBB+123'";
$line =~ s#[^?]'#'\n#;
print $line. "\n";
------------------------------
Date: Wed, 27 Oct 2004 11:39:41 -0500
From: Whitey Johnson <whitey@newmail.net>
Subject: Re: HOW TO replace ' but not ?'
Message-Id: <pan.2004.10.27.16.39.41.309658@newmail.net>
On Wed, 27 Oct 2004 11:36:27 -0500, Whitey Johnson muttered incoherently:
<snip>
>
> Ooooh oooh oooh!!
> I wanna give this a try before I look at the other respones:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my $line = "AAA+Tim?'s'BBB+123'";
> $line =~ s#[^?]'#'\n#;
Damn, make that: $line =~ s#[^?]'#'\n#g;
> print $line. "\n";
------------------------------
Date: Wed, 27 Oct 2004 12:34:09 -0500
From: Whitey Johnson <whitey@newmail.net>
Subject: Re: HOW TO replace ' but not ?'
Message-Id: <pan.2004.10.27.17.34.09.442818@newmail.net>
On Wed, 27 Oct 2004 11:39:41 -0500, Whitey Johnson muttered incoherently:
<snip snip>
>>
>> my $line = "AAA+Tim?'s'BBB+123'";
>> $line =~ s#[^?]'#'\n#;
>
> Damn, make that: $line =~ s#[^?]'#'\n#g;
One more try: $line =~ s#([^?])'#$1'\n#g;
I read Tad's post and was wondering if there was a case where this
wouldn't work?
>
>> print $line. "\n";
------------------------------
Date: Wed, 27 Oct 2004 17:45:44 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: HOW TO replace ' but not ?'
Message-Id: <c9Rfd.4078$9R4.984@trndny09>
"Whitey Johnson" <whitey@newmail.net> wrote in message
news:pan.2004.10.27.17.34.09.442818@newmail.net...
> On Wed, 27 Oct 2004 11:39:41 -0500, Whitey Johnson muttered
incoherently:
>
> <snip snip>
> >>
> >> my $line = "AAA+Tim?'s'BBB+123'";
> >> $line =~ s#[^?]'#'\n#;
> >
> > Damn, make that: $line =~ s#[^?]'#'\n#g;
>
> One more try: $line =~ s#([^?])'#$1'\n#g;
>
> I read Tad's post and was wondering if there was a case where this
> wouldn't work?
>
Yes. Read my post in this thread.
Paul Lalli
------------------------------
Date: Wed, 27 Oct 2004 13:17:56 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: MAIL recommendation
Message-Id: <1098897519.35237@nntp.acecape.com>
"Michele Dondi" <bik.mido@tiscalinet.it> wrote in message
news:8javn05kadj90tbnhhh9cthsuggip56n6d@4ax.com...
> Then you *are* looking for people agreeing with you... on what a
> newsgroup is really for.
well to quote you previously, about the OP not getting bashed on "what's a
good book?"...to me is the same as "any pref's to an IDE?"
>but some precious contributors here have left this
> group because of the too high noise/signal ratio. Doesn't this tell
> anything to you?
is it possible that noises occurs by both sides...
daniel
------------------------------
Date: Wed, 27 Oct 2004 15:12:52 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: MAP question
Message-Id: <UVOfd.2441$803.1580@trndny04>
"Noname" <Noname@hot.com> wrote in message
news:QPOfd.28817$g4.539696@news2.nokia.com...
> but now the question in @_tem array has values
> ('one','two','three','four);
> which when initializes as > %allReleases = @_tem;
> it becomes one=>two,three=>four,
> what I want is all the values in array becomes keys of hash
Well you should have specified that originally! ;-) Indeed, you still
haven't given a complete problem description, because you haven't told
us what you want the values of the hash to be. I will make a random
assumption that you want each value of the hash to be the number 1.
In that case, you can use a hash slice:
@allReleases{@_tem} = (1) x @_tem;
This creates a list of 1s on the right (of the same size as @_tem), and
assigns each position of %allReleases corresponding to the values of
@_tem to a value of 1.
If that syntax is confusing, you could do it with a loop instead:
$allReleases{$_} = 1 foreach @_tem;
> I hope I am talking some sence
Some, but not enough. ;-) If you're looking for the values of the hash
to be something other than a constant integer, please post a complete
problem description.
Paul Lalli
------------------------------
Date: 27 Oct 2004 17:16:25 +0200
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: MAP question
Message-Id: <yzdvfcw2nue.fsf@invalid.net>
"Noname" <Noname@hot.com> writes:
> I realized my mistake, of chomp, thanks
> but now the question in @_tem array has values
> ('one','two','three','four);
> which when initializes as > %allReleases = @_tem;
> it becomes one=>two,three=>four,
> what I want is all the values in array becomes keys of hash
> I hope I am talking some sence
You seem to be talking about a hash table with no values in it. This does
make sense, if you want the hash table to just be a collection of strings
that allows for fast lookup whether a given string is present or not.
The line below constructs a hash table with keys as given in @_tem,
with the "undefined value" as value for them. It does this by specifiying
a hash slice (of a hash table that doesn't exist yet, but that's Perl).
@allReleases{@_tem} = undef;
If you do want to associate the keys with values in your hash table,
you need to let the values enter the computation somewhere.
------------------------------
Date: Wed, 27 Oct 2004 17:44:09 +0200
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: MAP question
Message-Id: <417fc24a$0$17104$bb690d87@news.main-rheiner.de>
Paul Lalli wrote:
> Well you should have specified that originally! ;-) Indeed, you still
> haven't given a complete problem description, because you haven't told
> us what you want the values of the hash to be. I will make a random
> assumption that you want each value of the hash to be the number 1.
>
> In that case, you can use a hash slice:
> @allReleases{@_tem} = (1) x @_tem;
>
> This creates a list of 1s on the right (of the same size as @_tem), and
> assigns each position of %allReleases corresponding to the values of
> @_tem to a value of 1.
>
> If that syntax is confusing, you could do it with a loop instead:
>
> $allReleases{$_} = 1 foreach @_tem;
Or:
my %allReleases = map { $_ => 1 } @_tem;
Then you don't have to declare %allReleases beforehand under strict.
Thomas
--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
------------------------------
Date: 27 Oct 2004 15:47:53 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: MAP question
Message-Id: <Xns958F7804BB64Easu1cornelledu@132.236.56.8>
Arndt Jonasson <do-not-use@invalid.net> wrote in
news:yzdvfcw2nue.fsf@invalid.net:
> You seem to be talking about a hash table with no values in it. This
> does make sense, if you want the hash table to just be a collection of
> strings that allows for fast lookup whether a given string is present
> or not.
>
> The line below constructs a hash table with keys as given in @_tem,
> with the "undefined value" as value for them. It does this by
> specifiying a hash slice (of a hash table that doesn't exist yet, but
> that's Perl).
>
> @allReleases{@_tem} = undef;
>
> If you do want to associate the keys with values in your hash table,
> you need to let the values enter the computation somewhere.
The above is misleading in that it creates the impression that one could
replace the undef above with anything else and still use it this way.
That is patently untrue:
use strict;
use warnings;
my @keys = qw(one two three four five);
my %hash;
@hash{@keys} = 1;
use Data::Dumper;
print Dumper \%hash;
__END__
Run it and see what it produces.
Thus, if you want to use a hash-slice rather than the foreach loop
solution suggested by Paul Lalli, you should do:
use strict;
use warnings;
my @keys = qw(one two three four five);
my %hash;
@hash{@keys} = (1) x @keys;
use Data::Dumper;
print Dumper \%hash;
__END__
Sinan
------------------------------
Date: 27 Oct 2004 17:38:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: MAP question
Message-Id: <clomen$b2a$3@mamenchi.zrz.TU-Berlin.DE>
A. Sinan Unur <1usa@llenroc.ude.invalid> wrote in comp.lang.perl.misc:
> Arndt Jonasson <do-not-use@invalid.net> wrote in
> news:yzdvfcw2nue.fsf@invalid.net:
>
> > You seem to be talking about a hash table with no values in it. This
> > does make sense, if you want the hash table to just be a collection of
> > strings that allows for fast lookup whether a given string is present
> > or not.
> >
> > The line below constructs a hash table with keys as given in @_tem,
> > with the "undefined value" as value for them. It does this by
> > specifiying a hash slice (of a hash table that doesn't exist yet, but
> > that's Perl).
> >
> > @allReleases{@_tem} = undef;
> >
> > If you do want to associate the keys with values in your hash table,
> > you need to let the values enter the computation somewhere.
>
> The above is misleading in that it creates the impression that one could
> replace the undef above with anything else and still use it this way.
Yup, misleading also to a casual reader of the program. It explicitly
assigns undef() to one hash element and leaves the others alone for no
good reason. While the effect is the same, the correct way of writing
this is to leave all elements unspecified:
@allReleases{@_tem} = ();
Anno
------------------------------
Date: 27 Oct 2004 15:07:29 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Modify program to write just data to a text file.
Message-Id: <Xns958F712AC6BC8asu1cornelledu@132.236.56.8>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in news:2u9rdpF28btapU1@uni-
berlin.de:
> A. Sinan Unur wrote:
>> Gunnar Hjalmarsson wrote:
>>> Abigail wrote:
>>>> It certainly prohibits any reader from this script to add the
>>>> features the OP wants and return the modified script to the OP.
...
>>> That interpretation is simpy unreasonable.
>>
...
>> By the way, the example of hiring a consultant is not the same thing
>> as me modifying a script and posting it on the UseNet.
>>
>> Are you trying to imply that the license conditions actually allow me
>> to do that?
>
> Probably not to post the modified script on Usenet. But that's not what
> Abigail said. Neither did Chris.
The bit about UseNet is a bit of a read herring. There can be debate where
a _hired_ consultant, that is an agent of the OP, may modify the script and
give it back to him. There does not seem to be any ambiguity, however, that
if you or I or anyone else on this group modified the script and gave it
back to him on any medium, we would be violating the license conditions.
Sinan.
------------------------------
Date: Wed, 27 Oct 2004 17:07:47 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Modify program to write just data to a text file.
Message-Id: <2u9siqF27lt8jU1@uni-berlin.de>
A. Sinan Unur wrote:
> Gunnar Hjalmarsson wrote:
>> A. Sinan Unur wrote:
>>> Are you trying to imply that the license conditions actually
>>> allow me to do that?
>>
>> Probably not to post the modified script on Usenet. But that's not
>> what Abigail said. Neither did Chris.
>
> The bit about UseNet is a bit of a read herring. There can be debate
> where a _hired_ consultant, that is an agent of the OP, may modify
> the script and give it back to him. There does not seem to be any
> ambiguity, however, that if you or I or anyone else on this group
> modified the script and gave it back to him on any medium, we would
> be violating the license conditions.
Sorry, but I don't follow you. Assuming that the OP is allowed to let a
hired consultant modify the script on his behalf, why wouldn't *anybody*
in this group be allowed to help him, provided that the result isn't
made publicly available? You don't mean that it would make a difference
whether the assisting programmer gets paid, do you?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 27 Oct 2004 15:41:09 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Modify program to write just data to a text file.
Message-Id: <Xns958F76E0148C2asu1cornelledu@132.236.56.8>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in news:2u9siqF27lt8jU1@uni-
berlin.de:
> A. Sinan Unur wrote:
>> Gunnar Hjalmarsson wrote:
>>> A. Sinan Unur wrote:
>>>> Are you trying to imply that the license conditions actually
>>>> allow me to do that?
>>>
>>> Probably not to post the modified script on Usenet. But that's not
>>> what Abigail said. Neither did Chris.
>>
>> The bit about UseNet is a bit of a read herring. There can be debate
>> where a _hired_ consultant, that is an agent of the OP, may modify
>> the script and give it back to him.
...
> Sorry, but I don't follow you. Assuming that the OP is allowed to let a
> hired consultant modify the script on his behalf, why wouldn't *anybody*
> in this group be allowed to help him, provided that the result isn't
> made publicly available? You don't mean that it would make a difference
> whether the assisting programmer gets paid, do you?
Yes, I do. If you a hired by somebody, you are that person's agent (in the
legal sense). For example, if you get in a traffic accident on a business
trip, your employer can be sued for damages. If you get in a traffic
accident while on vacation, your employer cannot be sued for damages. Same
deal.
Sinan.
------------------------------
Date: Wed, 27 Oct 2004 17:50:55 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Modify program to write just data to a text file.
Message-Id: <2u9v4eF28h4g5U1@uni-berlin.de>
A. Sinan Unur wrote:
> Gunnar Hjalmarsson wrote:
>> Sorry, but I don't follow you. Assuming that the OP is allowed to
>> let a hired consultant modify the script on his behalf, why
>> wouldn't *anybody* in this group be allowed to help him, provided
>> that the result isn't made publicly available? You don't mean that
>> it would make a difference whether the assisting programmer gets
>> paid, do you?
>
> Yes, I do. If you a hired by somebody, you are that person's agent
> (in the legal sense). For example, if you get in a traffic accident
> on a business trip, your employer can be sued for damages. If you get
> in a traffic accident while on vacation, your employer cannot be sued
> for damages.
What makes me allowed to drive the car in both cases is my driving
license. I don't see the analogy.
It would be interesting to hear a lawyer's opinion on this.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 27 Oct 2004 13:22:00 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: open-perl-ide qustion
Message-Id: <1098897763.16003@nntp.acecape.com>
"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:clnsc5$n7i$1@mamenchi.zrz.TU-Berlin.DE...
> Then why did you post it? It has zero informative content.
merely replying to someone who posted a nuetral/unnegative resposne...
i see ted posted a reply too. any chance he read the FAQ which he wrote (i
asumme many authors and he typed it) and waited the alloted "don't answer
angry rule"?
------------------------------
Date: 27 Oct 2004 17:11:33 GMT
From: ctcgag@hotmail.com
Subject: Re: What's the seed?
Message-Id: <20041027131133.841$0R@newsreader.com>
Ben Morrow <usenet@morrow.me.uk> wrote:
> Quoth ctcgag@hotmail.com:
> > Ben Morrow <usenet@morrow.me.uk> wrote:
> > > Quoth ctcgag@hotmail.com:
> > > > Derek Fountain <nospam@example.com> wrote:
> > > > >
> > > > > single, steps. I have my suspicions about the quality of my seed!
> > > >
> > > > my $x=int rand(~0); #Cause srand to be invoked "naturally"
> > > > srand($x);
> > > > warn "using $x as seed"; #record seed
> > >
> > > I think this is incorrect: the seed contains *more* entropy than any
> > > given return value from rand(), so this will give you less random
> > > numbers than not setting the seed at all.
> >
> > But the primary purpose wasn't to create a seed with more entropy
> > than perl's default seed, but rather to know what the seed was so it
> > could be re-used in the future.
>
> Yes, but (I think) that your method will give a seed with substantially
> *less* entropy than the perl default, which given the OP's comments
> about the quality of his seed I would take to be a Bad Thing.
My interpretation was that the OP was worried about the time-variance
of the initial seed quality, not the total theoretical entropy of the seed
over infinite time. (That is why I asked what he was using it for.) For
almost all applications, I'd gladly give up a little overall total entropy
to get better time-variance entropy. (And for those application where I
wouldn't, I wouldn't use the default RNG at all, regardless of seed)
With all the stuff that "make" and does to header files, and with the
defining and redefining of preprocessor macros, I'm having a hard time
figuring out what the perl C code looks like at the instant before the
Perl source compiles. But as far as I can tell, the seed is a U32
with 32 bits, and the loss of entropy associated with re-seeding would be
less than one bit.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 27 Oct 2004 17:58:09 GMT
From: ctcgag@hotmail.com
Subject: Re: What's the seed?
Message-Id: <20041027135809.977$1d@newsreader.com>
"Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de> wrote:
> Also sprach ctcgag@hotmail.com:
>
> > Ben Morrow <usenet@morrow.me.uk> wrote:
> >> Quoth ctcgag@hotmail.com:
> >> > Derek Fountain <nospam@example.com> wrote:
> >> > > In any recent version of Perl, the seed for the random number
> >> > > generator is set at the first time rand() is called. Can I find
> >> > > out what that seed is so I can subsequently reproduce the random
> >> > > sequence?
> >> > >
> >> > > At present I'm setting my own seed using "time ^ ($$ + ($$ <<
> >> > > 15))", but my program is being run repeatedly over and over, and
> >> > > only takes a fraction of a second to do its job. That means time
> >> > > is often the same for several runs, and $$ tends to go up in
> >> > > small, sometimes single, steps. I have my suspicions about the
> >> > > quality of my seed!
> >> >
> >> > I think this would be generally adequate, but you don't say what you
> >> > are using this for. If you are concerned, and you think that perl's
> >> > default srand is better than what you are doing, I would do
> >> > something like this:
> >> >
> >> > my $x=int rand(~0); #Cause srand to be invoked "naturally"
> >> > srand($x);
> >> > warn "using $x as seed"; #record seed
> >>
> >> I think this is incorrect: the seed contains *more* entropy than any
> >> given return value from rand(), so this will give you less random
> >> numbers than not setting the seed at all.
> >
> > But the primary purpose wasn't to create a seed with more entropy
> > than perl's default seed, but rather to know what the seed was so it
> > could be re-used in the future.
>
> There's no way of getting this information. The seed is calculated using
> Perl_seed() (in util.c). Its return value is used to initialize the
> libc's random number generator but it's not stored anywhere. That means
> one has to call srand() manually if one intends to produce the same
> sequence of random number all over again.
I know. Calling srand() manually is what I proposed doing.
I just proposed a different way of arriving at the seed
which is passed to srand().
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7323
***************************************