[28391] in Perl-Users-Digest
Perl-Users Digest, Issue: 9755 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 22 18:05:50 2006
Date: Fri, 22 Sep 2006 15: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)
Perl-Users Digest Fri, 22 Sep 2006 Volume: 10 Number: 9755
Today's topics:
An interactive interpreter/shell? <robb@acm.org>
Re: An interactive interpreter/shell? usenet@DavidFilmer.com
Re: An interactive interpreter/shell? usenet@DavidFilmer.com
CGI.pm and param <cacheung@consumercontact.com>
Re: CGI.pm and param <mritty@gmail.com>
Re: CGI.pm and param usenet@DavidFilmer.com
Re: CGI.pm and param <mritty@gmail.com>
Re: CGI.pm and param <cacheung@consumercontact.com>
Re: CGI.pm and param <cacheung@consumercontact.com>
Re: CGI.pm and param <cacheung@consumercontact.com>
Re: Convert file to excel <nobull67@gmail.com>
Re: Convert file to excel <tadmc@augustmail.com>
Re: differences between hashes and arrays ? <news@lawshouse.org>
Re: differences between hashes and arrays ? <mritty@gmail.com>
Re: differences between hashes and arrays ? <uri@stemsystems.com>
Re: differences between hashes and arrays ? <tadmc@augustmail.com>
Re: differences between hashes and arrays ? <mritty@gmail.com>
Re: explaining how memory works with tie()ed hashs xhoster@gmail.com
Re: Help with plotting <emschwar@pobox.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Sep 2006 13:46:39 -0700
From: "robb@acm.org" <robb@acm.org>
Subject: An interactive interpreter/shell?
Message-Id: <1158957999.764763.150240@h48g2000cwc.googlegroups.com>
Hi,
Is there a shell out there that has functionality like Python's
interactive interpreter? I've seen references to a few things out
there (two different projects named psh?) But they don't look like
they're currently being worked on, or are up to date.
Thanks,
Robb
------------------------------
Date: 22 Sep 2006 14:00:28 -0700
From: usenet@DavidFilmer.com
Subject: Re: An interactive interpreter/shell?
Message-Id: <1158958828.177078.201450@e3g2000cwe.googlegroups.com>
robb@acm.org wrote:
> Is there a shell out there
perldoc -q shell
Is there a Perl shell?
--
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 22 Sep 2006 14:05:27 -0700
From: usenet@DavidFilmer.com
Subject: Re: An interactive interpreter/shell?
Message-Id: <1158959127.187996.282520@b28g2000cwb.googlegroups.com>
robb@acm.org wrote:
> Is there a shell out there
perldoc -q shell
Is there a Perl shell?
--
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 22 Sep 2006 12:02:46 -0700
From: "garhone" <cacheung@consumercontact.com>
Subject: CGI.pm and param
Message-Id: <1158951766.696383.313450@m7g2000cwm.googlegroups.com>
I'm trying to view the contents of my CGI object, directly and using
param.
I encounter a problem with scrolling lists.
Here's my scrolling list: 'slist' => ['foo', 'bar', 'fu', 'foobar',
'fubar'];
When I use Data::Dumper on $q, the CGI object, I'll see
...
,'slist' => ['foo', 'bar', 'fu', 'foobar', 'fubar'],
...
If I try to access 'slist' directly, I can see all of it:
print Dumper $q->{'slist'};
I get
$VAR1 = 'foo'
$VAR2 = 'bar'
$VAR3 = 'fu'
$VAR4 = 'foobar'
$VAR5 = 'fubar'
But if I try
my @a = $q->param('slist');
print Dumper @a;
I get
$VAR1 = 'foo'
and that's it.
Can anyone tell me why this is the case? How can I get
$q->param('slist') to return all the contents of 'slist' instead of
just the first element?
Thanks in advance
------------------------------
Date: 22 Sep 2006 12:11:20 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: CGI.pm and param
Message-Id: <1158952280.363621.275010@h48g2000cwc.googlegroups.com>
garhone wrote:
> I'm trying to view the contents of my CGI object, directly and using
> param.
> I encounter a problem with scrolling lists.
>
> Here's my scrolling list: 'slist' => ['foo', 'bar', 'fu', 'foobar',
> 'fubar'];
That is not a scrolling list. That is a key/value pair, where the key
is the string 'slist', and the value is a reference to an anonymous
array. You are asking us to take your word for the fact that you are
using this key/value pair to correctly populate a scrolling list widget
of an HTML form. Please don't do that. Post a SHORT but COMPLETE
script that demonstrates your error.
> When I use Data::Dumper on $q, the CGI object, I'll see
> ...
> ,'slist' => ['foo', 'bar', 'fu', 'foobar', 'fubar'],
> ...
>
> If I try to access 'slist' directly, I can see all of it:
> print Dumper $q->{'slist'};
>
> I get
> $VAR1 = 'foo'
> $VAR2 = 'bar'
> $VAR3 = 'fu'
> $VAR4 = 'foobar'
> $VAR5 = 'fubar'
I find that vaguely unlikely, as $q->{'slist'} is a single item, a
scalar value. So it's rather not possible for Data::Dumper to show you
five different values. Please post real code and real output. Maybe
you meant you did something like
my @values = @{$q->{'slist'}};
print Dumper(@values);
> But if I try
> my @a = $q->param('slist');
> print Dumper @a;
>
> I get
> $VAR1 = 'foo'
>
> and that's it.
>
> Can anyone tell me why this is the case?
Because param() is working the way it was intended.
> How can I get
> $q->param('slist') to return all the contents of 'slist' instead of
> just the first element?
It's not returning the first element. It's returning all values of
your scrolling list that were selected by the user filling out your
form. That is what param() returns. That is what it is intended to
return.
If you want to get a list of all possible options for this scrolling
list, you've already seen how to do it - access the relevant hash entry
in the CGI.pm object.
If you can tell us *why* you think you want param() to return something
other than what it was intended to return, perhaps we can show you a
better way.
Paul Lalli
------------------------------
Date: 22 Sep 2006 12:12:48 -0700
From: usenet@DavidFilmer.com
Subject: Re: CGI.pm and param
Message-Id: <1158952368.285051.28430@b28g2000cwb.googlegroups.com>
garhone wrote:
> Can anyone tell me why this is the case? How can I get
> $q->param('slist') to return all the contents of 'slist' instead of
> just the first element?
It's been a long time, but I think it's something like this:
foreach (param('slist')) {
...
}
If you had posted a short but complete program to reproduce your
question (per the group's posting guidelines) then I could have tested
and debugged the solution. Since you didn't do that, though, I'm not
able to be as helpful as I would like.
--
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 22 Sep 2006 12:17:37 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: CGI.pm and param
Message-Id: <1158952657.576313.239430@d34g2000cwd.googlegroups.com>
usenet@DavidFilmer.com wrote:
> garhone wrote:
> > Can anyone tell me why this is the case? How can I get
> > $q->param('slist') to return all the contents of 'slist' instead of
> > just the first element?
>
> It's been a long time, but I think it's something like this:
>
> foreach (param('slist')) {
There is no difference between using param() in a list context in a
foreach loop and using param() in a list context in an array
assignment.
Paul Lalli
------------------------------
Date: 22 Sep 2006 12:42:32 -0700
From: "garhone" <cacheung@consumercontact.com>
Subject: Re: CGI.pm and param
Message-Id: <1158954152.102115.129700@h48g2000cwc.googlegroups.com>
First, thanks David and Paul for your help.
Second, I sincerely apologize for not posting any real code. Under
normal circumstances, I would most certainly post my code. I should
have mentioned this in the first place, that I am posting on behalf of
someone else, who showed me the problem and I have no access to the
actual code.
Also, my posting was probably further blundered by my lack of knowledge
of CGI.
I appreciate your help and I will pass on your replies, as well as the
advice to post the problem himself.
Once again, thanks.
usenet@DavidFilmer.com wrote:
> garhone wrote:
> > Can anyone tell me why this is the case? How can I get
> > $q->param('slist') to return all the contents of 'slist' instead of
> > just the first element?
>
> It's been a long time, but I think it's something like this:
>
> foreach (param('slist')) {
> ...
> }
>
> If you had posted a short but complete program to reproduce your
> question (per the group's posting guidelines) then I could have tested
> and debugged the solution. Since you didn't do that, though, I'm not
> able to be as helpful as I would like.
>
> --
> David Filmer (http://DavidFilmer.com)
------------------------------
Date: 22 Sep 2006 12:44:11 -0700
From: "garhone" <cacheung@consumercontact.com>
Subject: Re: CGI.pm and param
Message-Id: <1158954251.004196.289870@m73g2000cwd.googlegroups.com>
First, thanks David and Paul for your help.
Second, I sincerely apologize for not posting any real code. Under
normal circumstances, I would most certainly post my code. I should
have mentioned this in the first place, that I am posting on behalf of
someone else, who showed me the problem and I have no access to the
actual code.
Also, my posting was probably further blundered by my lack of knowledge
of CGI.
I appreciate your help and I will pass on your replies, as well as the
advice to post the problem himself.
Once again, thanks.
usenet@DavidFilmer.com wrote:
> garhone wrote:
> > Can anyone tell me why this is the case? How can I get
> > $q->param('slist') to return all the contents of 'slist' instead of
> > just the first element?
>
> It's been a long time, but I think it's something like this:
>
> foreach (param('slist')) {
> ...
> }
>
> If you had posted a short but complete program to reproduce your
> question (per the group's posting guidelines) then I could have tested
> and debugged the solution. Since you didn't do that, though, I'm not
> able to be as helpful as I would like.
>
> --
> David Filmer (http://DavidFilmer.com)
------------------------------
Date: 22 Sep 2006 12:45:18 -0700
From: "garhone" <cacheung@consumercontact.com>
Subject: Re: CGI.pm and param
Message-Id: <1158954318.895065.298670@m73g2000cwd.googlegroups.com>
First, thanks David and Paul for your help.
Second, I sincerely apologize for not posting any real code. Under
normal circumstances, I would most certainly post my code. I should
have mentioned this in the first place, that I am posting on behalf of
someone else, who showed me the problem and I have no access to the
actual code.
Also, my posting was probably further blundered by my lack of knowledge
of CGI.
I appreciate your help and I will pass on your replies, as well as the
advice to post the problem himself.
Once again, thanks.
usenet@DavidFilmer.com wrote:
> garhone wrote:
> > Can anyone tell me why this is the case? How can I get
> > $q->param('slist') to return all the contents of 'slist' instead of
> > just the first element?
>
> It's been a long time, but I think it's something like this:
>
> foreach (param('slist')) {
> ...
> }
>
> If you had posted a short but complete program to reproduce your
> question (per the group's posting guidelines) then I could have tested
> and debugged the solution. Since you didn't do that, though, I'm not
> able to be as helpful as I would like.
>
> --
> David Filmer (http://DavidFilmer.com)
------------------------------
Date: 22 Sep 2006 11:08:49 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Convert file to excel
Message-Id: <1158948529.494758.220760@i3g2000cwc.googlegroups.com>
Deepu wrote:
> The output generated is:
>
> YES NO UNKNOWN
> FILE1 10 8 14
> FILE2 6 7 20
> FILE3 18 10 10
> FILE4 20 12 10
> FILE5 10 10 10
>
> Now i am trying to save this table in a file so that it can be read by
> Excel and create bar chart.
Excel can read CSV files.
There's also a module on CPAN to write Excel files but it can't do
fancy stuff like include macros.
> Is there any way possible to automate this flow.
You can drive Excel via OLE. (f you know the OLE commands you want
then Win32::OLE will let you do them).
Alternatively you could write an Excel macro that runs your Perl script.
------------------------------
Date: Fri, 22 Sep 2006 13:55:18 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Convert file to excel
Message-Id: <slrneh8ccm.ob7.tadmc@magna.augustmail.com>
Deepu <pradeep.bg@gmail.com> wrote:
> #!/usr/bin/perl
use warnings;
use strict;
> @dirList= qw(FILE1 FILE2 FILE3 FILE4 FILE5);
> foreach $dir (@dirList) {
Calling something that is not a directory "dir" is likely to lead
to easily avoided confusion.
> open (PH, "$dir") || die "Can not open:$dir";
perldoc -q vars
What's wrong with always quoting "$vars"?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 22 Sep 2006 19:14:29 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: differences between hashes and arrays ?
Message-Id: <1158948867.91722.0@demeter.uk.clara.net>
Paul Lalli wrote:
> Jack wrote:
>> Hi folks I am not an expert in perl but correct me if I am wrong -
>
> You're wrong. :-)
>
>> is it true you can use a hash and work with it just as you would an
>> array
>
> No.
Of course all the material about the difference in the ways that hashes
and arrays is perfectly correct, but there is one sense in which the OP
is correct - or at least has some method in his madness. Look:
# -------------------------------------------
#! /usr/bin/perl
use strict; use warnings;
use Data::Dumper;
my @array = ("one",111,"two",22);
# Or we could even have coded my %hash = ("one",111,"two",22);
my %hash = @array;
print Dumper(\%hash);
# --------------------------------------------
F:\>tryit.pl
$VAR1 = {
'one' => 111,
'two' => 22
};
--
Henry Law <>< Manchester, England
------------------------------
Date: 22 Sep 2006 11:36:57 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: differences between hashes and arrays ?
Message-Id: <1158950216.965477.188290@m73g2000cwd.googlegroups.com>
Henry Law wrote:
> Paul Lalli wrote:
> > Jack wrote:
> >> Hi folks I am not an expert in perl but correct me if I am wrong -
> >
> > You're wrong. :-)
> >
> >> is it true you can use a hash and work with it just as you would an
> >> array
> >
> > No.
>
> Of course all the material about the difference in the ways that hashes
> and arrays is perfectly correct, but there is one sense in which the OP
> is correct - or at least has some method in his madness. Look:
>
> # -------------------------------------------
> #! /usr/bin/perl
>
> use strict; use warnings;
>
> use Data::Dumper;
>
> my @array = ("one",111,"two",22);
> # Or we could even have coded my %hash = ("one",111,"two",22);
> my %hash = @array;
None of this shows "using a hash and array in the same way". This is
populating an array with a list of values, and then populating a hash
with the list of values that are currently contained in an array.
%hash and @array have nothing to do with each other before or after
this statement.
Make sure you read and understand
perldoc -q difference
"What is the difference between a list and an array"
Paul Lalli
------------------------------
Date: Fri, 22 Sep 2006 16:31:35 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: differences between hashes and arrays ?
Message-Id: <x77izvabiw.fsf@mail.sysarch.com>
>>>>> "PL" == Paul Lalli <mritty@gmail.com> writes:
>> why arent folks using hashes instead of arrays since (I believe) they
>> are faster to access and take up the same or less memory than arrays..
PL> Faster to access, yes. Same or less memory, no.
hmm, in general arrays have faster lookups than hashes. me thinks you
confused the OP's statement. and arrays definitely use less storage
(even excluding the key itself) for each element.
PL> These are not apples to apples. You use a hash and an array for
PL> completely different purposes.
they are apples and bananas. :)
PL> If you have an example of a program or algorithm you're working on, we
PL> could help you get rid of some of your misperceptions. . . .
or he should learn more perl before asking such deep questions. :)
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: Fri, 22 Sep 2006 13:46:43 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: differences between hashes and arrays ?
Message-Id: <slrneh8bsj.ob7.tadmc@magna.augustmail.com>
Henry Law <news@lawshouse.org> wrote:
> Paul Lalli wrote:
>> Jack wrote:
>>> Hi folks I am not an expert in perl but correct me if I am wrong -
>>
>> You're wrong. :-)
>>
>>> is it true you can use a hash and work with it just as you would an
>>> array
>>
>> No.
>
> Of course all the material about the difference in the ways that hashes
> and arrays is perfectly correct, but there is one sense in which the OP
> is correct - or at least has some method in his madness. Look:
>
> # -------------------------------------------
> #! /usr/bin/perl
>
> use strict; use warnings;
>
> use Data::Dumper;
>
> my @array = ("one",111,"two",22);
Change that line to:
my @array = ("two",22,"one",111);
and run the program again.
> # Or we could even have coded my %hash = ("one",111,"two",22);
> my %hash = @array;
>
> print Dumper(\%hash);
> # --------------------------------------------
> F:\>tryit.pl
> $VAR1 = {
> 'one' => 111,
> 'two' => 22
> };
You get the _same_ output!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 22 Sep 2006 14:09:16 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: differences between hashes and arrays ?
Message-Id: <1158959356.188481.300270@i3g2000cwc.googlegroups.com>
Uri Guttman wrote:
> >>>>> "PL" == Paul Lalli <mritty@gmail.com> writes:
>
>
> >> why arent folks using hashes instead of arrays since (I believe) they
> >> are faster to access and take up the same or less memory than arrays..
>
> PL> Faster to access, yes. Same or less memory, no.
>
> hmm, in general arrays have faster lookups than hashes. me thinks you
> confused the OP's statement.
Or I confused my answer. :-) What I meant was that:
my $there = $hash{$key} ? 1 : 0;
is faster than:
my $there = 0;
for my $elem (@array) {
if ($elem eq $value) {
$there = 1;
next;
}
}
Paul Lalli
------------------------------
Date: 22 Sep 2006 18:07:03 GMT
From: xhoster@gmail.com
Subject: Re: explaining how memory works with tie()ed hashs
Message-Id: <20060922140839.975$ba@newsreader.com>
"botfood" <botfood@yahoo.com> wrote:
> Jim Gibson wrote:
> > > ----------------
> > > the machine running the script is a webserver on a remote host...
> > > they dont give access to any place I can watch memory.
> >
> > That makes it tough. However, you can do yourself a favor by setting up
> > a local Perl installation and running your tests on it. My guess is
> > that the regular expression engine doesn't vary very much from platform
> > to platform.
> > --------------------------------
>
> however, Berkley DB and memory management is probably different between
> win32 and Linux, so it wouldnt give me any more than a rough ballpark.
Often a rough ballpark is enough.
> My test server at home is not Apache, I use Xitami, so I cant really
> emulate the SizeLimit stuff that was a problem on the web server......
> kinda shooting in the dark.
You probably don't need to emulate SizeLimit. You just need to know what
it is.
> best guess at this point is that s// on a string that is 20k 'words' of
> 20 characters, *probably* eats up more memory that the host server
> wants to allocate for any single process.
I doubt it. Or at least, if this is the case, then you are living so close
to the edge that any random thing is doing to push you over it, anyway.
It is easy enough to write a 5 line CGI which constructs a string of 20k
words and try a realistic s// on it, dump it on your providers server, and
see if it runs afoul of SizeLimit or not. Then try it again with 40k, 60k,
etc just to see how much breathing room you have.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 22 Sep 2006 09:54:57 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Help with plotting
Message-Id: <877izvsxpq.fsf@localhost.localdomain>
Michele Dondi <bik.mido@tiscalinet.it> writes:
> On Thu, 21 Sep 2006 21:26:19 GMT, "Mumia W. (reading news)"
> <paduille.4058.mumia.w@earthlink.net> wrote:
>
> >I'm lucky to be using Debian. Debian Linux is probably the biggest
> >collection of free software in existence, and PDL::Graphics::PLplot is
> >included in Debian as part of Debian's "pdl" package.
>
> OTOH they're sometimes too picky for my tastes. While developing
> something on a debian box I had been needing a module which relied on
> a certain package. I had a hard time trying to install and put the
> module to work until I realized it wanted a -devel part of the package
> too.
But this is true of Redhat and Suse, or at least their enterprise
distros, with which I have some passing familiarity. RHEL4 update 4
has 255 -devel packages, each with its own non-devel. Offhand, I
haven't checked how many packages don't have -devel equivalents, but
it's clearly not uncommon there either.
-=Eric
------------------------------
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 9755
***************************************