[18556] in Perl-Users-Digest
Perl-Users Digest, Issue: 724 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 19 21:05:40 2001
Date: Thu, 19 Apr 2001 18:05:08 -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: <987728708-v10-i724@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 19 Apr 2001 Volume: 10 Number: 724
Today's topics:
Re: Banner does not display (Eric Bohlman)
Calling a subroutine with two Hashes Of Hashes <rogerp@ipass.net>
Re: Calling a subroutine with two Hashes Of Hashes (John Joseph Trammell)
Re: Calling a subroutine with two Hashes Of Hashes <ren@tivoli.com>
Re: Can't open file, dies (Jim Kroger)
Re: Can't open file, dies (Jim Kroger)
Re: Combining hierarchical and alphabetical sorting? <ren@tivoli.com>
Re: DBI and hashref question... <xris@dont.send.spam>
Re: Document Format [not explicitly perl related] <mischief@velma.motion.net>
Re: Duplicate Emails <mischief@velma.motion.net>
FAQ .: Bundled Distributions <faq@denver.pm.org>
Re: help needed with sorting Hash <moverho1@nycap.rr.com>
Re: hex to binary conversion <ren@tivoli.com>
Perl & PHP programmer available. (Gil G.)
Re: possible to pass a parameter from href to cgi scrip (Craig Berry)
Re: Slighty OT: Perl Books... <Juha.Laiho@iki.fi>
TRANSMITTING A REQUEST TO A WEB PAGE with lwp etc <j.herbert@oxagen.co.uk>
Re: TRANSMITTING A REQUEST TO A WEB PAGE with lwp etc <comdog@panix.com>
two associative arrays printed at the same time <justin.devanandan.allegakoen@intel.com>
Re: two associative arrays printed at the same time <comdog@panix.com>
Re: two associative arrays printed at the same time <justin.devanandan.allegakoen@intel.com>
unicode-impressions <pilsl_@goldfisch.at>
Re: use strict & require... (Tad McClellan)
Re: What is wrong here? <ren@tivoli.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Apr 2001 22:45:49 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Banner does not display
Message-Id: <9bnpqt$c0v$1@bob.news.rcn.net>
get_got_it@yahoo.com wrote:
> I have problem displaying a banner in a dynamic page. The banner is coming
> from a dynamic page (a perl script).For showing the image am using
> redirection (Location : $url) in the perl script.
> It works fine when the code for the banner is put in a static page(HTML)
> or a dynamic page(provided it uses the GET method).
> But if one uses the POST method in the form, then the page to which the
> form is submitted the banner does not appear. On looking at the
> Environment variables i have seen that when HTTP_ACCEPT is */* the banner
> appears else when its image/gif, image/x-xbitmap, image/jpeg,
> image/pjpeg ... it fails ..when the form is being submitted.
> But it works fine when the same page is submitted using GET method.
> There is not problem in Netscape. It works fine on all versions of
> netscape and versions of IE5 and lower.
> Is it a bug in IE5.5 or iam having some problem in my script?
This is an HTTP problem, not a Perl problem (you'd have it regardless of
what language you wrote your script in). Therefore the appropriate place
to ask is comp.infosystems.www.authoring.cgi, *after* reading the CGI
FAQs. Basically the problem is that issuing a redirect in response to a
POST request is, well, problematic, but the people in ciwac can explain it
better than I can.
------------------------------
Date: Thu, 19 Apr 2001 18:02:08 -0400
From: "Roger Perryman" <rogerp@ipass.net>
Subject: Calling a subroutine with two Hashes Of Hashes
Message-Id: <tduop9he1nfl7c@corp.supernews.com>
I am experiencing EXTREME difficulty passing hashes to a subroutine. I've
read numerous postings, FAQs, man pages but the best I could accomplish was
'almost' works; I've been struggling with this for 3 days now and I can't
afford to waste anymore time on it. Being a long time object oriented
developer, I can't bring myself to use global variables! Ideally, it would
only pass references. It will be called frequently so it should be a
reusable object.
Here is the code. Note that the subroutine is mostly pseudo code, since I
couldn't figure out how to extract the passed in arguments. I tried several
different was but none of them worked. I realize that the args come in as an
array (@_) but I couldn't translate that back into two hashes. I would have
thought it would be as simple as converting @_[0] into hash 1 and @_[1] into
hash 2. Maybe it is :-/
Any help would be greatly appreciated. I am very new to Perl so constructive
criticism is welcomed.
Roger
========== Code Starts Here ==========
#!C:/Perl/bin/perl -w
# OS: Win2K
# Perl: 5.6
#
# Tell Perl to help me
use diagnostics -verbose;
use strict 'refs';
use strict 'subs';
# Subroutine Prototypes
sub diffRunningVsRegisteredProcesses( %% );
# Declare my variables
my %registeredProcesses = ();
my %runningProcesses = ();
my %deadProcesses;
# Build a Hash of the available instances which contains a Hash of the name,
port and pid.
$registeredProcesses{ 1 }{ appName } = "myApp";
$registeredProcesses{ 1 }{ pid } = "1001";
$registeredProcesses{ 1 }{ port } = "2001";
$registeredProcesses{ 2 }{ appName } = "myApp";
$registeredProcesses{ 2 }{ pid } = "1002";
$registeredProcesses{ 2 }{ port } = "2002";
# Build a similar Hash of the instances which are actually running.
$runningProcesses{ 1 }{ appName } = "myApp";
$runningProcesses{ 1 }{ pid } = "1001";
$runningProcesses{ 1 }{ port } = "2001";
%deadProcesses = diffRunningVsRegisteredProcesses( \%registeredProcesses,
\%runningProcesses );
exit 0;
# Each dictionary has the following structure
#
# {
# "instanceID" =
# {
# appName = "appName";
# pid = "pid";
# port = "port";
# }
#
# Args: registered processes dictionary, running processes dictionary
# Desc: This method compares the 'actually' running processes dictionary to
the
# 'should be' running processes dictionary. The difference is the
dead instances.
sub diffRunningVsRegisteredProcesses( %% )
{
my %registered = $_[0]; # FirstArgumentPassedToFunction
my %running = $_[1]; # SecondArgumentPassedToFunction
my %dead;
# foreach instanceID in the outer registered dictionary
# see if there is a corresponding instanceID in the outer running
dictionary
# if not, add the registered dictionary (outer and inner) info to the
dead dictionary
return %dead;
}
------------------------------
Date: Thu, 19 Apr 2001 22:54:56 GMT
From: trammell@bayazid.hypersloth.invalid (John Joseph Trammell)
Subject: Re: Calling a subroutine with two Hashes Of Hashes
Message-Id: <slrn9dup0k.g13.trammell@bayazid.hypersloth.net>
On Thu, 19 Apr 2001 18:02:08 -0400, Roger Perryman wrote:
[snip]
> I would have thought it would be as simple as converting @_[0]
> into hash 1 and @_[1] into hash 2. Maybe it is :-/
Sorta.
> #!C:/Perl/bin/perl -w
> # OS: Win2K
> # Perl: 5.6
> #
>
> # Tell Perl to help me
> use diagnostics -verbose;
> use strict 'refs';
> use strict 'subs';
use strict;
> # Subroutine Prototypes
> sub diffRunningVsRegisteredProcesses( %% );
Are prototypes really necessary?
> # Declare my variables
> my %registeredProcesses = ();
> my %runningProcesses = ();
> my %deadProcesses;
Are you sure hashes are the best way to keep this data?
Somehow I was thinking arrays of hashes.
[initialization, comments snipped for brevity]
> %deadProcesses = diffRunningVsRegisteredProcesses(
> \%registeredProcesses, \%runningProcesses );
>
> exit 0;
>
> sub diffRunningVsRegisteredProcesses {
> my %registered = $_[0]; # FirstArgumentPassedToFunction
> my %running = $_[1]; # SecondArgumentPassedToFunction
my ($registered,$running) = @_;
> my %dead;
...
> return %dead;
return \%dead;
> }
--
Never hit anyone with glasses. Instead, use your fist.
------------------------------
Date: 19 Apr 2001 18:00:41 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Calling a subroutine with two Hashes Of Hashes
Message-Id: <m33db4336u.fsf@dhcp9-172.support.tivoli.com>
On Thu, 19 Apr 2001, rogerp@ipass.net wrote:
> #!C:/Perl/bin/perl -w
> # OS: Win2K
> # Perl: 5.6
> #
>
> # Tell Perl to help me
> use diagnostics -verbose;
> use strict 'refs';
> use strict 'subs';
What, no strict 'vars' ??
> # Subroutine Prototypes
> sub diffRunningVsRegisteredProcesses( %% );
Uh-oh... that's a no-no. You've declared this function to take two
hashes (not hash references) as arguments, but the first one will
*always* eat up all of the arguments. Perhaps you meant:
sub diffRunningVsRegisteredProcesses( \%\% );
which means that it will take two hash references as arguments.
> # Declare my variables
> my %registeredProcesses = ();
> my %runningProcesses = ();
> my %deadProcesses;
Stylistically, why would you initialize the first two hashes but not
the third? I prefer to leave of the explicit initialization as you
did with %deadProcesses, but certainly be consistent.
> # Build a Hash of the available instances which contains a Hash of the name,
> port and pid.
> $registeredProcesses{ 1 }{ appName } = "myApp";
> $registeredProcesses{ 1 }{ pid } = "1001";
> $registeredProcesses{ 1 }{ port } = "2001";
Looks kind of strange to quote those numeric values....
> $registeredProcesses{ 2 }{ appName } = "myApp";
> $registeredProcesses{ 2 }{ pid } = "1002";
> $registeredProcesses{ 2 }{ port } = "2002";
>
> # Build a similar Hash of the instances which are actually running.
> $runningProcesses{ 1 }{ appName } = "myApp";
> $runningProcesses{ 1 }{ pid } = "1001";
> $runningProcesses{ 1 }{ port } = "2001";
>
> %deadProcesses = diffRunningVsRegisteredProcesses(
> \%registeredProcesses, \%runningProcesses );
So, you're expecting the function to return a hash (not a hash ref),
and you're passing in two hashes. The prototype allows this syntax as
it sees an even number of arguments, so it does look like a hash. The
fact that the two arguments are actually hash refs is immaterial to
the prototype.
If the ( \%\% ) prototype were used instead, then things would be
interpreted differently, but the effect would really be the same.
> exit 0;
>
> # Each dictionary has the following structure
> #
> # {
> # "instanceID" =
> # {
> # appName = "appName";
> # pid = "pid";
> # port = "port";
> # }
> #
> # Args: registered processes dictionary, running processes dictionary
> # Desc: This method compares the 'actually' running processes dictionary to
> the
> # 'should be' running processes dictionary. The difference is the
> dead instances.
> sub diffRunningVsRegisteredProcesses( %% )
You'll want to fix the prototype here as well.
> {
> my %registered = $_[0]; # FirstArgumentPassedToFunction
> my %running = $_[1]; # SecondArgumentPassedToFunction
Now here's the problem. You're passing in hash refs, but now you're
assigning them directly to hashes. This is like:
my %hash = "red";
which is obviously incorrect.
There are two ways to fix this, but there are quite different. One of
them copies the hash (shallow copy), which I assume you don't want.
For completeness, that method is:
my %registered = %{$_[0]};
my %running = %{$_[1]};
As I said, I doubt this is what you want. Instead, use:
my $registered = $_[0];
my $running = $_[1];
and then later, when you want to use the hash, use either:
%$registered
to reference the entire hash, or:
$registered->{key}
to access keys in the hash (note the dereference via the arrow).
> my %dead;
>
> # foreach instanceID in the outer registered dictionary
>
> # see if there is a corresponding instanceID in the outer running
> dictionary
>
> # if not, add the registered dictionary (outer and inner) info to
> # the
> dead dictionary
>
> return %dead;
> }
And finally, you probably don't want to return the hash, which will be
a copy. Instead return a reference to it:
return \%dead;
(and modify the call above to handle this). Since %dead is a lexical
variable, returning a reference to it is OK and will actually be a
different piece of data on each function call (rather than returning
references to the same piece of data on every call, which would be
what would happen if you didn't have that "my %dead" in there and
which would be "a bad thing" in most cases).
HTH...
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Thu, 19 Apr 2001 19:41:14 -0400
From: minorseventhSPAMBLOCK@earthlink.net (Jim Kroger)
Subject: Re: Can't open file, dies
Message-Id: <minorseventhSPAMBLOCK-1904011941140001@tritone.csbmb.princeton.edu>
Hi Uri, thanks for the response. Thanks for showing me how to use
perldoc. Looks MUCH better than man pages. Joy!
> JK> open(LOG, ">>logfile") || die "can not create \n";
> JK> open(LOG) || die "can not open \n";
>
> hmm, what FILE are you trying to open there?
>
That's just it. I assumed it would know I want logfile since I thought I
attached that to the filehandle previously.
> read
> perldoc -f open
> perldoc opentut
>
> and see.
> also if you have put $! in the die message it might have clude you in too.
Right, will do.
>
>
> JK> open(LOG, ">>logfile") || can not open \n";
>
> hmm, what is different about this open and the one that fails. i see a
> major one, do you?
>
Hm, if you mean the missing die " then that is just a typo from my
transcription of my code..sorry bout that. Only other thing is "open"
instead of "create."
> JK> the script works as intended. So my question is, what is the use of a
> JK> handle if you have to assign it to a file each time? I'm using Learning
> JK> Perl, and I don't see a reference to or example of REopening a
file which
> JK> has previously had a handle assigned. It seems logically like my script
> JK> above should work, but obviously I'm wrong. Must I always include the
> JK> actual filename along with the handle whenever I try to open a
previously
> JK> defined output file?
>
> ahh, i see your problem, you don't understand file handles. they are not
> associated with files unless they are opened. when you close it it loses
> that association. and it never keeps track of the path to the file
> because that information is suspect (on unix it can be moved, one of
> several hard links, deleted, etc all AFTER the open occurs).
>
Exactly the answer I needed. Makes sense. Thanks. That would be a good
addition to the next edition of "Learninig.."
You should write a Perl book (or DID you???).
Jim
------------------------------
Date: Thu, 19 Apr 2001 19:43:50 -0400
From: minorseventhSPAMBLOCK@earthlink.net (Jim Kroger)
Subject: Re: Can't open file, dies
Message-Id: <minorseventhSPAMBLOCK-1904011943500001@tritone.csbmb.princeton.edu>
Thanks everyone for the help....
Can't help but wonder what a statistician uses Perl for....
Jim
------------------------------
Date: 19 Apr 2001 16:06:08 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Combining hierarchical and alphabetical sorting?
Message-Id: <m3bsps38hr.fsf@dhcp9-172.support.tivoli.com>
On Thu, 19 Apr 2001, dharding@uiuc.edu wrote:
> foreach my $child ( @{$channel_hash{$id}{kids}} ) {
Change this to:
foreach my $child ( sort @{$channel_hash{$id}{kids}} ) {
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Thu, 19 Apr 2001 17:20:33 -0500
From: xris <xris@dont.send.spam>
Subject: Re: DBI and hashref question...
Message-Id: <xris-EFADDA.17203219042001@news.evergo.net>
In article <slrn9dt1a0.g4j.rgarciasuarez@rafael.kazibao.net>,
rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote:
> DBI has a selectall_hashref method since version 1.15.
ah, very cool. wonder why it was left out of the O'Reilly Mysql book
(though that is by far the worst book I've seen from them, for all of
the typos, bad index entries, etc, so I guess I shouldn't be surprised).
guess I should get the DBI book at some point, thanks. :)
-Chris
------------------------------
Date: Thu, 19 Apr 2001 22:44:57 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Document Format [not explicitly perl related]
Message-Id: <tduqj95anrq913@corp.supernews.com>
Ronald Fischer <ronald.fischer.gp@icn.siemens.de> wrote:
> Gabriel Richards wrote:
>> I want to create a web based service that takes data users enter, feeds it
>> into a database, then creates for them a document formatted much like a
>> spreadsheet by merging this data into a template. The document has to be in
>> a popular format like PDF or xls or doc that can be easily printed. From the
>> little research I've done, it seems I would have to (using perl of course!)
>> create a PostScript file and merge the database data into that, then use
>> something like Adobe Distiller Server to create a PDF and then send that
>> back to the user. The problems are, I don't know PostScript (can be solved)
>> and Distiller Server's license says no Internet use!
> I wouldn't call XLS and DOC (which DOC) as "popular format", as it
> requires special (non-free) software to view it and runs only on some
> platforms.
They can be viewed with StarOffice last I checked. Even edited.
RTF or something similar would still be easier though.
HTML can be printed pretty easily, BTW. So can CSV files and RTF
documents. Tab-delimited, comma-delimited, etc. text files are easy
to print, too.
> Wouldn't it make sense to use HTML as document format? In this case, you
> can find several Perl modules which help you doing what you want.
I agree. HTML or XHTML makes wonderful cross-platform documents. They
don't always look exactly the same from machien to machine, but they
look enough alike to always give the same data (and if written properly,
even in the same layout although the dimensions might be different).
XML might be the answer in the near future, but I'd suggest HTML 4.01
Transitional.
Chris
--
Christopher E. Stith
For the pleasure of others, please adhere to the following
rules when visiting your park:
No swimming. No fishing. No flying kites. No frisbees.
No audio equipment. Stay off grass. No pets. No running.
------------------------------
Date: Thu, 19 Apr 2001 22:32:51 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Duplicate Emails
Message-Id: <tdupsja72kd109@corp.supernews.com>
Bart Lateur <bart.lateur@skynet.be> wrote:
> ted wrote:
> This is a slightly cleaned up version:
> my %done;
> foreach (@all_emails) {
> next if $done{$_}++;
> # do some stuff here #
> }
> Note that, for this particular problem, e-mail addresses should be
> reduced to their bare minimum, AKA the "canonical form", and also, make
> their case consisent, perhaps lower case, because e-mail addresses are
> case insensitive.
Not quite. Email addresses are not case insensitive. According to the
RFC, the _hostname_ is case insensitive. The private part is cased
per the target system, and must be maintained by all software handling
SMTP mail.
**Bzzzarp** We now return you to your regularly scheduled Perl,
already in progress.
Chris
--
Christopher E. Stith
Where there's a will, there's a lawyer.
------------------------------
Date: Fri, 20 Apr 2001 00:15:46 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ .: Bundled Distributions
Message-Id: <ScLD6.1316$T3.195744768@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
Bundled Distributions
When included as part of the Standard Version of Perl, or as part of its
complete documentation whether printed or otherwise, this work may be
distributed only under the terms of Perl's Artistic License. Any
distribution of this file or derivatives thereof *outside* of that
package require that special arrangements be made with copyright holder.
Irrespective of its distribution, all code examples in these files are
hereby placed into the public domain. You are permitted and encouraged
to use this code in your own programs for fun or for profit as you see
fit. A simple comment in the code giving credit would be courteous but
is not required.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep comming up. If you are some how irritated by
seeing these postings you are free to ignore them or add the sender
to your killfile. If you find errors or other problems with these
postings please send corrections or comments to the posting email
address.
If you are not able to find this or other Perl documentation from
your installation you may access it via the web by following the
appropriate links from one of the addresses listed below.
http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search
http://www.perldoc.com
http://www.cpan.org
http://www.perl.com
Answers to questions about LOTS of other stuff, mostly not related to
Perl, can be found at
news:news.answers
and in the many thousands of other useful Usenet news groups.
Please note that the FAQ text posted by this server has been modified
from that distributed in the stable Perl release. It has been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ is available on request.
The perlfaq manual pages contain the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
When included as an integrated part of the Standard
Distribution of Perl or of its documentation (printed or
otherwise), this work is covered under Perl's Artistic
License. For separate distributions of all or part of
this FAQ outside of that, see the perlfaq manpage.
Irrespective of its distribution, all code examples here
are public domain. You are permitted and encouraged to
use this code and any derivatives thereof in your own
programs for fun or for profit as you see fit. A simple
comment in the code giving credit to the FAQ would be
courteous but is not required.
This work is provided in the hope that it will be useful but does
not represent a commitment of any kind on the part of the contributers,
authors or their agents.
--
This space intentionally left blank
------------------------------
Date: Thu, 19 Apr 2001 22:48:04 GMT
From: "Mark" <moverho1@nycap.rr.com>
Subject: Re: help needed with sorting Hash
Message-Id: <EWJD6.2335$gl.442888@typhoon.nyroc.rr.com>
how about reversing the values and the keys
@2ed = reversed @1st
then sort by the value which is now the key
"Alan Barclay" <gorilla@elaine.furryape.com> wrote in message
news:987280700.227911@elaine.furryape.com...
In article <3AD5F51D.1A5C53B5@netscape.net>,
kelli norman <kellikellin@netscape.net> wrote:
>such friendly people out there!
>
>there is no way to actually make a hash have it's keys in sorted order,
>but if you just want to print the values in order:
Actually there is. Use the Tie::IxHash module.
------------------------------
Date: 19 Apr 2001 16:35:27 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: hex to binary conversion
Message-Id: <m37l0g374w.fsf@dhcp9-172.support.tivoli.com>
On Wed, 18 Apr 2001, rayj00@yahoo.com wrote:
> How can I turn 99(hex) into 10011001??
perl -e '$_="99";printf "%0b\n", hex'
(Use sprintf instead if you want to store it in a variable.)
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Fri, 20 Apr 2001 00:13:50 GMT
From: gil@nospam-keskydee.com (Gil G.)
Subject: Perl & PHP programmer available.
Message-Id: <3adf7e98.3166055@news-server>
Hello,
I can help you with your scripts.
Strong work ethics, good references, reasonable rates.
please see my freelance page: http://keskydee.com/freelance.php
Thanks, please excuse this somewhat off-topic post.
Sincerely,
Gil.
------------------------------
Date: Thu, 19 Apr 2001 22:17:48 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: possible to pass a parameter from href to cgi script?
Message-Id: <tdup0cqli8dsbb@corp.supernews.com>
Jana Cole (quikscor@ix.netcom.com) wrote:
: I would like to have two text links call the same cgi script. The
: form generated by the cgi script would have slightly different fields
: depending on which link was clicked. Can I pass an identifying
: parameter in the link's HTML somehow?
Sure, just use a GET parameter in the url:
<a href="http://foo.com/cgi/blah.pl?mode=1">Run it in mode 1</a>
<a href="http://foo.com/cgi/blah.pl?mode=2">Run it in mode 2</a>
Then just test the 'mode' parameter in blah.pl.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "When the going gets weird, the weird turn pro."
| - Hunter S. Thompson
------------------------------
Date: 19 Apr 2001 17:29:51 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Slighty OT: Perl Books...
Message-Id: <9bn7af$d8k$1@ichaos.ichaos-int>
"RobbieB" <robbie@totaln.com> said:
>Thanks for the quick reply man, I might look into that, and, with $50 or so
>to spare, can anyone recommend a har copy book that would fulfil my needs as
>posted in the first message of this thread?
Hmm.. I'd think "Object Oriented Perl" by Damian Conway should be
a good one to add to that (Perl bookshelf).
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ UH++++$ UL++++ P++@ L+++ E(-) W+$@ N++ !K w !O
!M V PS(+) PE Y+ PGP(+) t- 5 !X R tv--- b+ !DI D G e+ h--- r+++ y+++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: Thu, 19 Apr 2001 18:17:33 +0100
From: "John Herbert" <j.herbert@oxagen.co.uk>
Subject: TRANSMITTING A REQUEST TO A WEB PAGE with lwp etc
Message-Id: <3adf1db8$1@news2lo.highwayone.net>
Hi, I want to know how to submit something over the web, say a word. And the
web sight does a search on the word.
some code I have been playing with is here, but does not do anything yet.
#!/usr/bin/perl -w
use HTML::TreeBuilder;
use URI::URL;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Request::Common;
use HTTP::Request::Form;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new();
my $url = url( 'www.yahoo.com');
my $req = HTTP::Request->new(POST => "$url");
my $res = $ua->request($req);
if ($res->is_success) {
print $res->as_string;
} else {
print "Failed: ", $res->status_line, "\n";
}
my $tb = HTML::TreeBuilder->new();
$tb->parse($res->content);
my @forms = @{$tb->extract_links(qw(FORM))};
my $f = HTTP::Request::Form->new($forms[0][0], $url);
Thanks in advance, John.
------------------------------
Date: Thu, 19 Apr 2001 20:30:08 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: TRANSMITTING A REQUEST TO A WEB PAGE with lwp etc
Message-Id: <comdog-B0592C.20300819042001@news.panix.com>
In article <3adf1db8$1@news2lo.highwayone.net>, "John Herbert"
<j.herbert@oxagen.co.uk> wrote:
> Hi, I want to know how to submit something over the web, say a word. And the
> web sight does a search on the word.
> some code I have been playing with is here, but does not do anything yet.
there are already modules to do this. see
http://search.cpan.org
:)
--
brian d foy <comdog@panix.com>
------------------------------
Date: Fri, 20 Apr 2001 08:14:00 +0800
From: "Just in" <justin.devanandan.allegakoen@intel.com>
Subject: two associative arrays printed at the same time
Message-Id: <9bnv06$kh7@news.or.intel.com>
Dear all,
Say if I had two associative arrays with the same keys (but different
values).
How could I print them at the same time?
Could I do something like this:-
while(($key, $val, $key2, $val2) = each(%hash1, %hash2))
Yeap, I know that doesn't work, but is there a correct structure?
(FAQ shows me how to assign and print one at a time).
Thanks
Justin (Just another nobody who uses PERL (albeit badly), to numb the pain
of his job.)
------------------------------
Date: Thu, 19 Apr 2001 20:37:03 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: two associative arrays printed at the same time
Message-Id: <comdog-645808.20370319042001@news.panix.com>
In article <9bnv06$kh7@news.or.intel.com>, "Just in"
<justin.devanandan.allegakoen@intel.com> wrote:
> Say if I had two associative arrays with the same keys (but different
> values).
> How could I print them at the same time?
of course. if they have the same keys just pull out the
keys from one then print the value from each.
foreach my $key ( keys %castaway )
{
print "$castaway{$key} $coconet{$key}\n";
}
--
brian d foy <comdog@panix.com>
------------------------------
Date: Fri, 20 Apr 2001 09:01:15 +0800
From: "Just in" <justin.devanandan.allegakoen@intel.com>
Subject: Re: two associative arrays printed at the same time
Message-Id: <9bo1or$mgj@news.or.intel.com>
Err . . . yeah, thats the solution.
I really do have a bad understanding of associative arrays - i previously
thought that would print the keys - silly me
Thanks a lot
"brian d foy" <comdog@panix.com> wrote in message
news:comdog-645808.20370319042001@news.panix.com...
> In article <9bnv06$kh7@news.or.intel.com>, "Just in"
> <justin.devanandan.allegakoen@intel.com> wrote:
>
> > Say if I had two associative arrays with the same keys (but different
> > values).
> > How could I print them at the same time?
>
> of course. if they have the same keys just pull out the
> keys from one then print the value from each.
>
> foreach my $key ( keys %castaway )
> {
> print "$castaway{$key} $coconet{$key}\n";
> }
>
> --
> brian d foy <comdog@panix.com>
>
------------------------------
Date: Fri, 20 Apr 2001 00:24:06 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: unicode-impressions
Message-Id: <MPG.154983f5b3a00948989827@news.inode.at>
Last week I had a lot of questions regarding unicode in this two groups
(comp.infosystems.www.authoring.html,comp.lang.perl.misc) and found
important help (especially by Alan Flavell. Thanx again).
I put the info and two testscripts on my webpage, so if anyone is
interested.
http://www.goldfisch.at/knowledge/unicode.html
Comments are welcome (and of course I've very little time ;)
peter
--
pilsl@
goldfisch.at
------------------------------
Date: Thu, 19 Apr 2001 19:37:09 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: use strict & require...
Message-Id: <slrn9dutl5.40i.tadmc@tadmc26.august.net>
Matt <mnm@mnm.com> wrote:
>If I use this
>
>use strict;
>$0 =~ s:\\:/:g;
>my $root = $1 if ($0 =~ /(.*)\/[^\/]+/);
>require "$root/inc/global.pl";
>
>Then try to print a var created in the global.pl file I get the "Global
>symbol bla requires..." errors message. Can you get round this?
Yes.
Look up the message:
perldoc perldiag
---------------
=item Global symbol "%s" requires explicit package name
(F) You've said "use strict vars", which indicates that all variables
must either be lexically scoped (using "my"), declared beforehand using
"our", or explicitly qualified to say which package the global variable
is in (using "::").
---------------
If it requires an explicit package name, then provide an explicit
package name.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Apr 2001 15:42:17 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: What is wrong here?
Message-Id: <m3g0f439li.fsf@dhcp9-172.support.tivoli.com>
On 19 Apr 2001, joe+usenet@sunstarsys.com wrote:
> % cat global.pm
> our $test = "http://1.2.3.4"
> % perl -wle 'BEGIN{require "global.pm"} print $test'
> http://1.2.3.4
> %
While this does work, I think that it gives the mistaken impression
that having that "our" declaration in the required file has any effect
-- it really doesn't. Stick a "use strict" on that script and you
still have a problem:
perl -wle 'use strict;BEGIN{require "global.pm"} print $test'
Variable "$test" is not imported at -e line 1.
Global symbol "$test" requires explicit package name at -e line 1.
Execution of -e aborted due to compilation errors.
This is because, among other things, "our" is lexically scoped.
--
Ren Maddox
ren@tivoli.com
------------------------------
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 724
**************************************