[17281] in Perl-Users-Digest
Perl-Users Digest, Issue: 4703 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 23 18:20:45 2000
Date: Mon, 23 Oct 2000 15:20:30 -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: <972339629-v9-i4703@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 23 Oct 2000 Volume: 9 Number: 4703
Today's topics:
Re: Q: how to convert 2 arrays to 1 hash <yanick@babyl.sympatico.ca>
Re: Q: how to convert 2 arrays to 1 hash <stephenk@cc.gatech.edu>
Re: Q: how to convert 2 arrays to 1 hash <adamf@box43.gnet.pl>
Re: Q: how to convert 2 arrays to 1 hash <ren.maddox@tivoli.com>
Re: Question about perl -w <kent@darwin.eeb.uconn.edu>
Re: Removing line breaks from a string - HELP! <russ_jones@rac.ray.com>
Re: Removing line breaks from a string - HELP! <bart.lateur@skynet.be>
Re: should be easy, but not working - help ! <jihad.battikha@sharewire.com>
Re: Subroutine reference/undef/redefine anomaly <mauldin@netstorm.net>
Re: Subroutine reference/undef/redefine anomaly <gellyfish@gellyfish.com>
Traversing any workstation of a Windows domain (Otto Wyss)
Re: Using text file to display form data <lr@hpl.hp.com>
What will the code look like? <hldpub@ix.netcom.com>
Re: What will the code look like? (Jerome O'Neil)
Re: What will the code look like? <jihad.battikha@sharewire.com>
Re: Writing multiple files to a particular directory <gellyfish@gellyfish.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 23 Oct 2000 18:05:33 GMT
From: Yanick Champoux <yanick@babyl.sympatico.ca>
Subject: Re: Q: how to convert 2 arrays to 1 hash
Message-Id: <N5%I5.373500$1h3.10028602@news20.bellglobal.com>
"Thomas Åhlen" <thomas2@dalnet.se> wrote:
: If i have this
: $key_array = [ 'a', 'b', 'c' ];
: $value_array = [ 1, 2, 3 ];
: what is the easies way to get this
: $hash = { 'a' => 1, 'b' => 2, 'c' => 3 };
: There must be a simple oneliner for this something like..
: $hash->{@$key_array} = @$value_array;
: well i know this one doesn't work and why..
You were close, though:
@{$hash}{ @$key_array } = @$value_array;
Joy,
Yanick
--
($_,$y)=("Yhre lo .kePnarhtretcae\n", '(.) (.)' );
$y=~s/\(/(./gwhile s/$y/$2$1/xg;print; @ !;
" `---' ";
------------------------------
Date: Mon, 23 Oct 2000 14:15:46 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: Q: how to convert 2 arrays to 1 hash
Message-Id: <39F48051.D8CE10BD@cc.gatech.edu>
"Thomas Åhlen" wrote:
> If i have this
>
> $key_array = [ 'a', 'b', 'c' ];
> $value_array = [ 1, 2, 3 ];
>
> what is the easies way to get this
>
> $hash = { 'a' => 1, 'b' => 2, 'c' => 3 };
>
> There must be a simple oneliner for this something like..
>
> $hash->{@$key_array} = @$value_array;
>
> well i know this one doesn't work and why..
>
Close.
@$hash{@$key_array} = @$value_array;
--
Stephen Kloder | "I say what it occurs to me to say.
stephenk@cc.gatech.edu | More I cannot say."
Phone 404-874-6584 | -- The Man in the Shack
ICQ #65153895 | be :- think.
------------------------------
Date: Mon, 23 Oct 2000 20:15:45 +0200
From: Adam <adamf@box43.gnet.pl>
Subject: Re: Q: how to convert 2 arrays to 1 hash
Message-Id: <39F48051.69C1@box43.gnet.pl>
Thomas Åhlen wrote:
>
> If i have this
>
> $key_array = [ 'a', 'b', 'c' ];
> $value_array = [ 1, 2, 3 ];
>
> what is the easies way to get this
>
> $hash = { 'a' => 1, 'b' => 2, 'c' => 3 };
>
> There must be a simple oneliner for this something like..
>
> $hash->{@$key_array} = @$value_array;
this shoud work (works for me ;):
use strict;
my $key_array = [ 'a', 'b', 'c' ];
my $value_array = [ '1', '2', '3' ];
my %hash;
@hash{@$key_array} = @$value_array;
--Adam.
------------------------------
Date: 23 Oct 2000 12:55:17 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Q: how to convert 2 arrays to 1 hash
Message-Id: <m3hf638mt6.fsf@dhcp11-177.support.tivoli.com>
"Thomas Åhlen" <thomas2@dalnet.se> writes:
> If i have this
>
> $key_array = [ 'a', 'b', 'c' ];
> $value_array = [ 1, 2, 3 ];
>
> what is the easies way to get this
>
> $hash = { 'a' => 1, 'b' => 2, 'c' => 3 };
>
> There must be a simple oneliner for this something like..
>
> $hash->{@$key_array} = @$value_array;
>
> well i know this one doesn't work and why..
So close...
@{$hash}{@$key_array} = @$value_array;
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 23 Oct 2000 14:55:46 -0400
From: Kent Holsinger <kent@darwin.eeb.uconn.edu>
Subject: Re: Question about perl -w
Message-Id: <m0zojv1j65.fsf@darwin.eeb.uconn.edu>
>>>>> "Mark" == Mark-Jason Dominus <mjd@plover.com> writes:
Mark> When you accumulate too many points, your will be
Mark> required to attend a retaining class and pay a fine before
^^^^^^^^^
Mark> you can execute Perl again.
i.e., a class intended to make sure you don't get discouraged by all
of the warnings, not one that would help you avoid them.
Kent
--
Kent E. Holsinger kent@darwin.eeb.uconn.edu
http://darwin.eeb.uconn.edu
-- Department of Ecology & Evolutionary Biology
-- University of Connecticut, U-3043
-- Storrs, CT 06269-3043
------------------------------
Date: Mon, 23 Oct 2000 15:31:57 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <39F4A03D.41B93498@rac.ray.com>
"Goodwill!" wrote:
>
>
> Your inherent ignorance beguiles your own malice intent
> and significant degree of illiteracy, consistently.
You really should look up some of these harder words before you use
them.
--
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
Quae narravi, nullo modo negabo. - Catullus
------------------------------
Date: Mon, 23 Oct 2000 21:46:35 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <dec9vsc8tnqq9hv98cohmsbbtb08m5956u@4ax.com>
Russ Jones wrote:
>"G!" wrote:
>>
>> Your inherent ignorance beguiles your own malice intent
>> and significant degree of illiteracy, consistently.
>
>You really should look up some of these harder words before you use
>them.
I don't think that would help.
--
Bart.
------------------------------
Date: Mon, 23 Oct 2000 15:49:19 -0400
From: Jihad Battikha <jihad.battikha@sharewire.com>
Subject: Re: should be easy, but not working - help !
Message-Id: <39F4963F.E903AD16@sharewire.com>
none wrote:
> ...it just keeps showing 1 as the topping total. There's a space
> after each value in the checkbox list.
> -------------------------
> Which toppings would you like? (All pizzas include cheese and tomato
> sauce)<p></td></tr>
> <tr><td><input type="checkbox" name="toppings" value="X-Cheese ">Extra
> Cheese<br>
> <input type="checkbox" name="toppings" value="Pepperoni
> ">Pepperoni<br>
> <input type="checkbox" name="toppings" value="Sausage
> ">Sausage<br>
> <input type="checkbox" name="toppings" value="Onion
> ">Onion<br>
> </td></tr>
> ....
> @line = qw($input{toppings});
> $toppingtotal = @line;
This isn't related to Perl. But anyway:
Your CGI script is probably getting back:
topping=X-Cheese&toppings=Pepperoni&toppings=etc.
as part of the query string. I don't know how you're populating
$input{toppings}, but chances are, if you're not using CGI.pm, it's only
grabbing the first name=value pair from the query string. Have you
tried checking the value of $input{toppings}? Its contents might not
contain what you think it contains. Also, if $input{toppings} is
actuall an array reference, you need to dereference it in otder to
actually get an array returned which, in turn, makes your qw() attempt
pretty useless in that context. If $input{toppings} were actually an
array reference, you migth want to do this:
if (ref($input{toppings}) eq 'ARRAY') {
$toppingtotal = scalar(@{$input{toppings}});
} else {
# what the hell is in $input{toppings}?
# I'll leave that to you to figure out...
}
If $input{toppings} is a string containing a space-delimited list of
values, the only thing that qw($input{toppings}) will do is return the
same exact string, which for all intents and purposes could have very
well been "1" to begin with. Since you're not checking the original
contents of $input{toppings}, you're guessing at the contents. And, if
it's meant to be an array reference, you're not de-referencing it
properly. My guess is that if you're using CGI.pm then what's happeing
is that qw($input{toppings}) is returning something like
"HASH(1235ABCD)", populating the first item in the @line array with
"HASH(1235ABCD)", which is then correctly returning "1" for your total.
--
Jihad Battikha <jihad.battikha@sharewire.com>
Sharewire, Inc. --- http://www.sharewire.com/
- Free forms, programs, and content for web sites.
- No assembly required.
Disclaimer:
Before sending me commercial e-mail, the sender must first agree
to my LEGAL NOTICE located at: http://www.highsynth.com/sig.html
------------------------------
Date: Mon, 23 Oct 2000 18:40:34 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Subroutine reference/undef/redefine anomaly
Message-Id: <39F4851A.6D03C1F2@netstorm.net>
nobull@mail.com wrote:
>
> Jim Mauldin <mauldin@netstorm.net> writes:
>
> > nobull@mail.com wrote:
> > > Undefining and then redefining a subroutine creates an anomalous state
> > > in references to the old subroutine.
>
> > When you declare:
> > my $old_foo = \&foo;
> >
> > a new Perl reference (with a different reference ID) is created that
> > contains the same pointer to the sub as the one in the symbol table for
> > &foo, and the reference count is increased to 2. When you undef &foo,
> > the reference count of $$old_foo decreases to 1 and the status of both
> > references are set to undef, even though the code continues to exist.
>
> No, undef(THING) causes THING to become undefined, it doesn't
> disconnect references to THING. Any references to the old thing now
> refer to the undefined thing.
>
Huh? Who's disagreeing? Your question was why a reference saved in a
scalar continues to point to the code after the subroutine is undefined
and then redefined, and my answer was that until you destroy all
references to the referant, perl maintains the underlying pointers.
-- Jim
------------------------------
Date: 23 Oct 2000 19:56:20 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Subroutine reference/undef/redefine anomaly
Message-Id: <8t21kk$5d6$1@orpheus.gellyfish.com>
On 20 Oct 2000 17:23:38 +0100 nobull@mail.com wrote:
> Undefining and then redefining a subroutine creates an anomalous state
> in references to the old subroutine.
>
> #!/usr/bin/perl -w
> use strict;
>
> sub foo { 2 };
> my $old_foo = \&foo;
> undef &foo;
> *foo = sub { 3 };
> print 0 + defined &$old_foo;
> print $old_foo->();
>
> This prints '03'. This is of course nonsense. How can I call an
> undefined function and have it return 3?
>
Inserting a 'print $old_foo->()' between the undef'ing of foo and its
redefinition gives some inkling of what is going on.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Mon, 23 Oct 2000 23:24:21 +0200
From: otto.wyss@bluewin.ch (Otto Wyss)
Subject: Traversing any workstation of a Windows domain
Message-Id: <1eiz96v.1h3k90519clh7mN%otto.wyss@bluewin.ch>
I want to know if a specific file is on any workstation of a Windows
domain. Each workstation runs Windows NT4.0 and has a share "C$". Are
there any modules which traverses a Windows domain and maps a share on
any discovered workstation? Does anybody have an example for such a task
(the script should run on Windows)?
Is this alltogether possible in perl or do I have to use an external
program? If yes, which?
O. Wyss
------------------------------
Date: Mon, 23 Oct 2000 13:23:28 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Using text file to display form data
Message-Id: <MPG.145e3e1fa377bf2698ae57@nntp.hpl.hp.com>
In article <8st8v7$5d1$02$1@news.t-online.com> on Sun, 22 Oct 2000
01:37:26 +0100, Christian Mahnke <mahnke@fliegen-ist-schoener.de>
says...
> Hello,
>
> try it with
>
> #Open the headings text file
> open(INF,"headings.dat")
That is mssing both the test for failure and the terminating semicolon.
The latter proves that your code was never tested, even to see whether
it compiles.
> chomp @ary = <INF>; <-**************
That compiles, but doesn't do what you want. Parentheses are needed.
chomp(@ary = <INF>);
> close(INF);
No problem with that line, at least! (Though others may think you
should test for the success of closing an input file, the point of doing
that escapes me.)
> when you read in the file, could be the newline on the end of evey row,
>
> cheers,
>
> Christian
<SNIP> 12-line signature without proper cut line ("\n-- \n"); Usenet
conventions ask that you limit signatures to four lines.
<SNIP> Complete quoting of post being responded to; the conventions of
this and most other newsgroups are that you quote selectively, and
intersperse your comments after what you are responding to. Of course,
your style is a prime indicator of bogosity, as in this case. So maybe
you should stick with it if you keep on posting bogus code.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 23 Oct 2000 14:38:43 -0700
From: The Starmaker <hldpub@ix.netcom.com>
Subject: What will the code look like?
Message-Id: <39F4AFE3.48E6@ix.netcom.com>
I want to inflate the traffic count on my web page.
I already have a script that does that but I want to add something else.
I want to act as a "visitor" to my web site and sends a fictitious
http_referer and a fake IP address.
I'll be using a CGI-generated in-line GIF advertising images.
These graphics are usually only displayed, and counted, when my Web page
has a legitimate visitor as determined by the http_referer field sent
from the client to the server during http transactions. What will the
code look like to act as a "visitor" to my web site and send a
fictitious http_referer and a fake IP address.
Thanks in advance
Helen
------------------------------
Date: Mon, 23 Oct 2000 21:53:15 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: What will the code look like?
Message-Id: <fr2J5.2842$Rr2.235783@news.uswest.net>
The Starmaker <hldpub@ix.netcom.com> elucidates:
> I want to inflate the traffic count on my web page.
[ Snip ]
> I'll be using a CGI-generated in-line GIF advertising images.
So, do you always commit fraud when you try to make a buck, or
is this something new for you?
--
"Civilization rests on two things: the discovery that fermentation
produces alcohol, and the voluntary ability to inhibit defecation.
And I put it to you, where would this splendid civilization be without
both?" --Robertson Davies "The Rebel Angels"
------------------------------
Date: Mon, 23 Oct 2000 17:54:52 -0400
From: Jihad Battikha <jihad.battikha@sharewire.com>
Subject: Re: What will the code look like?
Message-Id: <39F4B3AC.AEC5DE1B@sharewire.com>
The Starmaker wrote:
> I want to inflate the traffic count on my web page.
> I already have a script that does that
A script that inflates traffic all by itself? Cool! Does it work like
a magnet and make people just really really want to visit your site for
no apparent reason?
> but I want to add something else.
> I want to act as a "visitor" to my web site and sends a fictitious
> http_referer and a fake IP address.
You mean, something that can fake out all those spamfest pyramid scheme
alladvantage crapfilliate programs? So you can fake out "your" web
server with fictitious hits and fill up your web logs to show your
buddies how kewl you are?
> I'll be using a CGI-generated in-line GIF advertising images.
Hey, that sounds like what those spamfest banner guyz do.
> These graphics are usually only displayed, and counted, when my
> Web page has a legitimate visitor as determined by the
> http_referer field sent from the client to the server
> during http transactions.
Hmm, yes.
> What will the code look like to act as a "visitor" to my web
> site and send a fictitious http_referer and a fake IP address.
Man, good luck fooling your own server! Like, will you have to give
yourself amnesia after you do this so that you won't know it's you
faking yourself out? If you get the fake IP address thing figured out,
let us know!
--
Jihad Battikha <jihad.battikha@sharewire.com>
Sharewire, Inc. --- http://www.sharewire.com/
- Free forms, programs, and content for web sites.
- No assembly required.
Disclaimer:
Before sending me commercial e-mail, the sender must first agree
to my LEGAL NOTICE located at: http://www.highsynth.com/sig.html
------------------------------
Date: 23 Oct 2000 22:09:54 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Writing multiple files to a particular directory
Message-Id: <8t29f2$6ob$1@orpheus.gellyfish.com>
On Sun, 22 Oct 2000 23:50:07 -0400 Tad McClellan wrote:
> On 22 Oct 2000 16:31:45 -0500, Logan Shaw <logan@cs.utexas.edu> wrote:
>>In article <slrn8v6dj2.17n.tadmc@magna.metronet.com>,
>>Tad McClellan <tadmc@metronet.com> wrote:
>>>What is help.com, and what relationship does it have to this newsgroup?
>>
>>Apparently help.com (which is part of CNET) is advertising
>>comp.lang.perl.misc as part of its "Help Centers".
>
>
> OIC. (Oh, I see).
>
> Can articles posted via help.com be recognized somehow?
>
> Like do they put "help.com" in the Message ID or anything?
>
The Message IDs appear to end with @corp.supernews.com
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
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 4703
**************************************