[24664] in Perl-Users-Digest
Perl-Users Digest, Issue: 6828 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 3 14:47:08 2004
Date: Tue, 3 Aug 2004 11:46:36 -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 Tue, 3 Aug 2004 Volume: 10 Number: 6828
Today's topics:
Re: The Perl Journal Vols 1 - 18, & 20 <matthew.garrish@sympatico.ca>
Re: The Perl Journal Vols 1 - 18, & 20 <gregs@trawna.com>
Re: The Perl Journal Vols 1 - 18, & 20 <matthew.garrish@sympatico.ca>
Transpose data into a 2 dimensional array. (deepak p)
Re: Transpose data into a 2 dimensional array. <jgibson@mail.arc.nasa.gov>
Re: Undefined subroutine CGI::Vars <nanae@nanae.perusion.com>
Re: Undefined subroutine CGI::Vars <tadmc@augustmail.com>
Re: Undefined subroutine CGI::Vars (krakle)
Re: Undefined subroutine CGI::Vars <noonehere@fakoaddresso.como>
Re: Undefined subroutine CGI::Vars <me@privacy.net>
Re: Undefined subroutine CGI::Vars (krakle)
Re: Undefined subroutine CGI::Vars <spamtrap@dot-app.org>
Re: Undefined subroutine CGI::Vars (krakle)
Re: Undefined subroutine CGI::Vars <spamtrap@dot-app.org>
Re: Undefined subroutine CGI::Vars (krakle)
Re: Undefined subroutine CGI::Vars <spamtrap@dot-app.org>
Re: Undefined subroutine CGI::Vars <spamtrap@dot-app.org>
Re: Undefined subroutine CGI::Vars <noonehere@fakoaddresso.como>
Re: Undefined subroutine CGI::Vars <spamtrap@dot-app.org>
Re: Undefined subroutine CGI::Vars <spamtrap@dot-app.org>
Re: Undefined subroutine CGI::Vars <noonehere@fakoaddresso.como>
Re: Undefined subroutine CGI::Vars <noonehere@fakoaddresso.como>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 26 Jul 2004 19:17:33 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: The Perl Journal Vols 1 - 18, & 20
Message-Id: <aigNc.16797$i_2.618140@news20.bellglobal.com>
"Ray Sutton" <rlsutton@chartermi.net> wrote in message
news:cf239c11.0407261251.6527063c@posting.google.com...
> I have original Perl Journals #1 through #18 and #20. I will sell them
> only as a set. They are in perfect condition. A real bargain at $75
> plus shipping. Contact me at rlsutton@chartermi.net. Thank you.
But all the best articles were in issue #19. Just doesn't seem worth the
price without it...
Matt
------------------------------
Date: Tue, 27 Jul 2004 13:24:14 -0400
From: Greg Schmidt <gregs@trawna.com>
Subject: Re: The Perl Journal Vols 1 - 18, & 20
Message-Id: <8y6n3w9i8xfr.dlg@trawna.com>
On Mon, 26 Jul 2004 19:17:33 -0400, Matt Garrish wrote:
> "Ray Sutton" <rlsutton@chartermi.net> wrote in message
> news:cf239c11.0407261251.6527063c@posting.google.com...
>> I have original Perl Journals #1 through #18 and #20. I will sell them
>> only as a set. They are in perfect condition. A real bargain at $75
>> plus shipping. Contact me at rlsutton@chartermi.net. Thank you.
>
> But all the best articles were in issue #19. Just doesn't seem worth the
> price without it...
Just guessing here.... you had an article in issue 19? :-)
--
Greg Schmidt gregs@trawna.com
Trawna Publications http://www.trawna.com/
------------------------------
Date: Tue, 27 Jul 2004 18:50:58 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: The Perl Journal Vols 1 - 18, & 20
Message-Id: <f%ANc.23219$i_2.997197@news20.bellglobal.com>
"Greg Schmidt" <gregs@trawna.com> wrote in message
news:8y6n3w9i8xfr.dlg@trawna.com...
> On Mon, 26 Jul 2004 19:17:33 -0400, Matt Garrish wrote:
>
> > "Ray Sutton" <rlsutton@chartermi.net> wrote in message
> > news:cf239c11.0407261251.6527063c@posting.google.com...
> >> I have original Perl Journals #1 through #18 and #20. I will sell them
> >> only as a set. They are in perfect condition. A real bargain at $75
> >> plus shipping. Contact me at rlsutton@chartermi.net. Thank you.
> >
> > But all the best articles were in issue #19. Just doesn't seem worth the
> > price without it...
>
> Just guessing here.... you had an article in issue 19? :-)
>
No, I just don't like reading advertisements in a technical newsgroup... : )
Matt
------------------------------
Date: 2 Aug 2004 15:00:18 -0700
From: deepak10000@hotmail.com (deepak p)
Subject: Transpose data into a 2 dimensional array.
Message-Id: <9e77c6b2.0408021400.28eb9024@posting.google.com>
Hello Perl Gurus,
Can someone show me how to transpose data into a 2 dimensional array.
I searched for examples similar to my need in the newsgroup, but could
not find one thats close :-( I have listed sample data .txt file
below. Assume all data lines are unique and sorted. I appreciate your
time and providing me education.
Kind regards,
Deepak
AAA|a01|BBB|b01|0
AAA|a01|BBB|b02|5
AAA|a01|BBB|b03|2
AAA|a02|BBB|b01|1
AAA|a02|BBB|b02|2
AAA|a02|BBB|b03|2
AAA|a03|BBB|b01|5
AAA|a03|BBB|b02|4
AAA|a03|BBB|b03|2
..
..
Would like output result file to be transposed like.
Res|a01|a02|a03
b01|0|1|5
b02|5|2|4
b03|2|2|2
Later, I need to put it into an html table such as AAA spans
horizontally across 2 table cells of the first row and BBB spans
vertically across the first column.
|AAA|AAA|AAA|
|a01|a02|a03
BBB|b01|0|1|5
BBB|b02|5|2|4
BBB|b03|2|2|2
------------------------------
Date: Mon, 02 Aug 2004 18:07:08 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Transpose data into a 2 dimensional array.
Message-Id: <020820041807088867%jgibson@mail.arc.nasa.gov>
In article <9e77c6b2.0408021400.28eb9024@posting.google.com>, deepak p
<deepak10000@hotmail.com> wrote:
> Hello Perl Gurus,
>
> Can someone show me how to transpose data into a 2 dimensional array.
> I searched for examples similar to my need in the newsgroup, but could
> not find one thats close :-( I have listed sample data .txt file
> below. Assume all data lines are unique and sorted. I appreciate your
> time and providing me education.
You can store data in a two-dimensional array using syntax such as
$array[$i][$j]. Perl will autovivify this as an array of array
references. You can then do any manipulation you want on the elements
of this array, including transposing, which usually means exchanging
rows for columns.
>
> AAA|a01|BBB|b01|0
> AAA|a01|BBB|b02|5
> AAA|a01|BBB|b03|2
> AAA|a02|BBB|b01|1
> AAA|a02|BBB|b02|2
> AAA|a02|BBB|b03|2
> AAA|a03|BBB|b01|5
> AAA|a03|BBB|b02|4
> AAA|a03|BBB|b03|2
> ..
> ..
>
> Would like output result file to be transposed like.
>
> Res|a01|a02|a03
> b01|0|1|5
> b02|5|2|4
> b03|2|2|2
This is not a simple transposing of your input data. There is
additional processing going on. You probably need to use a
"hash-of-hashes" (HOH), where you have elements such as
$hash{'a01']->{'b01'} = 0;
$hash{'a01']->{'b02'} = 5;
$hash{'a01']->{'b03'} = 2;
After reading the data and storing it into an HOH, you can print it out
anyway you want.
Here is one try:
#!/usr/local/bin/perl
use strict;
my %hash;
while (<DATA>) {
chomp;
my @columns = split(/\|/);
${$hash{$columns[1]}}{$columns[3]} = $columns[4];
}
my @akeys = sort keys %hash;
my @bkeys = sort keys %{$hash{$akeys[0]}};
print "Res";
print "|$_" for @akeys;
print "\n";
for my $bkey ( @bkeys ) {
print "$bkey";
for my $akey ( @akeys ) {
print '|', ${$hash{$akey}}{$bkey};
}
print "\n";
}
__END__
AAA|a01|BBB|b01|0
AAA|a01|BBB|b02|5
AAA|a01|BBB|b03|2
AAA|a02|BBB|b01|1
AAA|a02|BBB|b02|2
AAA|a02|BBB|b03|2
AAA|a03|BBB|b01|5
AAA|a03|BBB|b02|4
AAA|a03|BBB|b03|2
__OUTPUT__
Res|a01|a02|a03
b01|0|1|5
b02|5|2|4
b03|2|2|2
>
> Later, I need to put it into an html table such as AAA spans
> horizontally across 2 table cells of the first row and BBB spans
> vertically across the first column.
>
> |AAA|AAA|AAA|
> |a01|a02|a03
> BBB|b01|0|1|5
> BBB|b02|5|2|4
> BBB|b03|2|2|2
I leave this as an exercise for the reader. :)
------------------------------
Date: Mon, 26 Jul 2004 14:43:43 -0000
From: Perusion Hostmaster <nanae@nanae.perusion.com>
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <slrncga64t.ion.nanae@bill.heins.net>
In article <7d8Nc.19215$9J5.8463@fe2.news.blueyonder.co.uk>, Mark wrote:
> I want to store my request variables as a hash and have the code:
>
[snip]
> use CGI qw(:cgi-lib);
[snip]
I bet if you lose this line it will work.
The docs say that you should "use CGI qw/:cgi-lib/" if you want
to import Vars as a function -- not if you want to use it as
an object method.
--
Few blame themselves until they have exhausted all other possibilities.
-- anonymous
------------------------------
Date: Mon, 26 Jul 2004 11:13:07 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <slrncgabcj.our.tadmc@magna.augustmail.com>
Mark <noonehere@fakoaddresso.como> wrote:
> use CGI qw(:standard);
> use CGI qw(:cgi-lib);
[snip]
> my $q = new CGI;
Object oriented interfaces do not need to import anything into
your name space, so don't import anything into your namespace. :-)
use CGI;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 26 Jul 2004 12:42:06 -0700
From: krakle@visto.com (krakle)
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <237aaff8.0407261142.3da31463@posting.google.com>
"Mark" <noonehere@fakoaddresso.como> wrote in message news:<7d8Nc.19215$9J5.8463@fe2.news.blueyonder.co.uk>...
> I want to store my request variables as a hash and have the code:
>
> use CGI qw(:standard);
> use CGI qw(:cgi-lib);
> #during development, put Perl errors to the browser
> use CGI::Carp qw(fatalsToBrowser);
> use strict;
> my $q = new CGI;
> my $params = $q->Vars();
>
> but the server is giving me an error message:
>
> Undefined subroutine CGI::Vars
>
I see lot's of problems.. The format your using CGI.pm is OO yet you
call it as function. You are also calling cgi-lib. And you are using a
scalar to stora Vars when it should be a hash to collect all. Try:
#!/usr/bin/perl -Tw
use strict;
use CGI; # Object Oriented Interface
my $q = new CGI;
my %params = $q->Vars; # Now you can use $params{name} for value of
name
------------------------------
Date: Mon, 26 Jul 2004 23:40:58 GMT
From: "Mark" <noonehere@fakoaddresso.como>
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <eEgNc.24695$9J5.23024@fe2.news.blueyonder.co.uk>
"Tad McClellan" wrote...
> Mark wrote:
>
[snip]
>
> Object oriented interfaces do not need to import anything into
> your name space, so don't import anything into your namespace. :-)
>
> use CGI;
Thanks. I took out the two imports so the code is now:
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use strict;
my $q = new CGI;
my $grandtotal= sprintf("%.2f", ($q->param('grandtotal')));
$params = $q->Vars;
now I get the error.
Execution /orderform.cgi aborted due to compilation errors.
If I replace the last line with
my $params = $q->Vars;
then I get as previously:
Undefined subroutine CGI::Vars
so I am not sure which is in error.
Perhaps my web host does not have the right library installed? They list the
following CGI modules as installed:
CGI::Apache
CGI::Carp
CGI::Cookie
CGI::Fast
CGI::Pretty
CGI::Push
CGI::Switch
CGI::Util
In order to successfully log orders made from my shopping cart script I have
to be able to use the (unknown amount of) POST variables in hidden form
fields. I can't see an easy way of doing this unless I can assign them to a
hash variable. Any suggestions?
Thanks
Mark
------------------------------
Date: Tue, 27 Jul 2004 19:52:39 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <2mmfu4Fo5fljU1@uni-berlin.de>
"Mark" <noonehere@fakoaddresso.como> wrote in message
news:eEgNc.24695$9J5.23024@fe2.news.blueyonder.co.uk...
> Thanks. I took out the two imports so the code is now:
>
> use CGI;
> use CGI::Carp qw(fatalsToBrowser);
> use strict;
> my $q = new CGI;
> my $grandtotal= sprintf("%.2f", ($q->param('grandtotal')));
> $params = $q->Vars;
>
> now I get the error.
>
> Execution /orderform.cgi aborted due to compilation errors.
Due to you not declaring $params
>
> If I replace the last line with
>
> my $params = $q->Vars;
>
> then I get as previously:
>
> Undefined subroutine CGI::Vars
>
> so I am not sure which is in error.
You must have a pretty old version of Perl/CGI module installed on your
webserver.
------------------------------
Date: 28 Jul 2004 15:34:52 -0700
From: krakle@visto.com (krakle)
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <237aaff8.0407281434.195ed469@posting.google.com>
"Mark" <noonehere@fakoaddresso.como> wrote in message news:<eEgNc.24695$9J5.23024@fe2.news.blueyonder.co.uk>...
> "Tad McClellan" wrote...
> > Mark wrote:
> >
>
> [snip]
>
> >
> > Object oriented interfaces do not need to import anything into
> > your name space, so don't import anything into your namespace. :-)
> >
> > use CGI;
>
>
> Thanks. I took out the two imports so the code is now:
>
> use CGI;
> use CGI::Carp qw(fatalsToBrowser);
> use strict;
> my $q = new CGI;
> my $grandtotal= sprintf("%.2f", ($q->param('grandtotal')));
> $params = $q->Vars;
my %params = $q->Vars;
>
> now I get the error.
Read my other reply to this. Geesh.
------------------------------
Date: Thu, 29 Jul 2004 01:40:03 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <J62dnYlelOguEJXcRVn-ow@adelphia.com>
krakle wrote:
> "Mark" <noonehere@fakoaddresso.como> wrote in message news:<eEgNc.24695$9J5.23024@fe2.news.blueyonder.co.uk>...
>
>> $params = $q->Vars;
>
>
> my %params = $q->Vars;
Calling Vars() in scalar context is valid, and returns a tied hash
reference.
Unlike the hash you get when you call Vars() in array context, the hash
reference you get by calling it in scalar context is not read-only. It
can also be used to set parameters for output, which is used in self-
referential CGIs that include forms and/or links back to themselves in
the HTML they output.
> Read my other reply to this. Geesh.
Read 'perldoc CGI'. Geesh.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 30 Jul 2004 13:03:38 -0700
From: krakle@visto.com (krakle)
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <237aaff8.0407301203.6ec1b690@posting.google.com>
Sherm Pendley <spamtrap@dot-app.org> wrote in message news:<J62dnYlelOguEJXcRVn-ow@adelphia.com>...>
> Read 'perldoc CGI'. Geesh.
>
> sherm--
He wanted to know why it didn't work. I showed him a working example.
Which was tested. Being that I use it in most of my scripts... Then he
complained his script still didn't work... I pointed out exactly what
he did wrong... Using OO while CGI is called as function.
------------------------------
Date: Fri, 30 Jul 2004 17:33:58 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <sdOdndrlQP5aI5fcRVn-rQ@adelphia.com>
krakle wrote:
> I pointed out exactly what
> he did wrong... Using OO while CGI is called as function.
In the post I replied to, the only thing you "pointed out" was this:
>> $params = $q->Vars;
>
>
> my %params = $q->Vars;
>
The "error" that you're "correcting" above is not an error, nor does it
have anything to do with methods vs. functions. Calling Vars() in scalar
context is allowed, regardless of whether you call it as a method or as
a function.
The addition of "my" above *is* good advice - which is why I did not
criticize it in my reply.
You also said:
> Read my other reply to this. Geesh.
... and in that other reply:
> And you are using a
> scalar to stora Vars when it should be a hash to collect all.
That is false, and repetition won't make it true. Using a scalar to get
a hashref is valid, supported, useful, and - most importantly - documented.
Also from your earlier reply:
>>my $q = new CGI;
>>my $params = $q->Vars();
> I see lot's of problems.. The format your using CGI.pm is OO yet you
> call it as function.
You're wrong here too. Mark is *not* calling Vars as a function in the
code he posted. He is creating a query object $q, and calling $q->Vars()
as an instance method.
Your advice here is pointless - importing functions into the local name
space won't prevent OO the methods from working. There's no reason to do
so if you intend to use OO methods, that's true, but it won't cause the
type of error he's getting.
So drop the snide attitude and whiny "Geesh" comments please. If you
want people to follow your advice, post some advice worth following.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 31 Jul 2004 22:23:24 -0700
From: krakle@visto.com (krakle)
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <237aaff8.0407312123.3b5cf511@posting.google.com>
Sherm Pendley <spamtrap@dot-app.org> wrote in message news:<sdOdndrlQP5aI5fcRVn-rQ@adelphia.com>...
> krakle wrote:
>
> > I pointed out exactly what
> > he did wrong... Using OO while CGI is called as function.
>
> In the post I replied to, the only thing you "pointed out" was this:
Since when do you reply to a snipet of post without reading the whole
thread?
>
> >> $params = $q->Vars;
> >
> >
> > my %params = $q->Vars;
> >
>
> The "error" that you're "correcting" above is not an error, nor does it
> have anything to do with methods vs. functions.
Sure it does. 1 he called CGI.pm as a method. However he is using
OO... I never said it was an error.. I simply stated a snipet that did
infact WORK and accomplish exactly what he was doing...
>
> The addition of "my" above *is* good advice - which is why I did not
> criticize it in my reply.
Good advice. Bad advice. No advice. Doesn't it all get criticized on
usenet? What's your point, lad?
>
> You also said:
>
> > Read my other reply to this. Geesh.
>
> ... and in that other reply:
>
> > And you are using a
> > scalar to stora Vars when it should be a hash to collect all.
>
> That is false, and repetition won't make it true. Using a scalar to get
> a hashref is valid, supported, useful, and - most importantly - documented.
Which code works? Mine or his? Mind. Does it accomplish his goal? Yes.
>
> Also from your earlier reply:
>
> >>my $q = new CGI;
> >>my $params = $q->Vars();
>
> > I see lot's of problems.. The format your using CGI.pm is OO yet you
> > call it as function.
>
> You're wrong here too. Mark is *not* calling Vars as a function in the
> code he posted. He is creating a query object $q, and calling $q->Vars()
> as an instance method.
He wanted help, correct? I gave him help and a working example that
accomplishes exactly what he is trying to do. If you can get that much
on usenet you are a lucky duck... Most people just criticize peoples
postings.... *snickers*.. Having fun?
>
> Your advice here is pointless
And I stop your post here. You summed it up... My working code is
worthless to the guy whose code doesn't work. Don't you love usenet
advice? Round 3.
------------------------------
Date: Sun, 01 Aug 2004 04:36:24 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <DKSdneOeu6wUNpHcRVn-jg@adelphia.com>
krakle wrote:
> And I stop your post here. You summed it up...
Yes I did, and I'll do so again. You said that Vars() must be called in
list context, not scalar context. That is false, and the fact that it is
false is clearly documented in 'perldoc CGI' - a document you clearly
are not familiar with.
Further, you claimed that the OP called Vars() as a function, but the
code he posted read 'my $params = $q->Vars()' - clearly you don't know
the difference between a function and a method.
Mark asked for help. The error he received is "Undefined subroutine";
calling Vars() in scalar context will not produce that error, and
neither will calling Vars() as a method when it has also been imported
as a function.
Calling Vars() as a function *will* produce that error, if it has not
been imported as a function. But in the code Mark posted, it *is*
imported; not only that, it's called as a method. Doing both is wrong
only in terms of style - it won't cause an error.
You were wrong on at least one point, and overall your suggestions were
useless. Calling me rude won't change those facts.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Sun, 01 Aug 2004 04:44:18 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <78Wdnda4-8L-MJHcRVn-uA@adelphia.com>
Mark wrote:
> use CGI qw(:standard);
> use CGI qw(:cgi-lib);
> #during development, put Perl errors to the browser
> use CGI::Carp qw(fatalsToBrowser);
> use strict;
> my $q = new CGI;
> my $params = $q->Vars();
>
> but the server is giving me an error message:
>
> Undefined subroutine CGI::Vars
>
> but I'm not sure why.
Is that your *real* code?
I suspect that your real code might actually be calling Vars() like this:
my $params = Vars();
In that case, your problem might come from the dual sets of 'use'
statements. A module that has already been 'use'd won't be reloaded if
another 'use' is encountered, so the second - which imports the function
you want to use - wouldn't have any effect.
So you might try one of two things. Either make sure that your real code
does call Vars() as a method, like the code you posted here does. Or,
import both groups of functions with a single use statement, like this:
use CGI qw(:standard :cgi-lib);
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Sun, 01 Aug 2004 08:53:45 GMT
From: "Mark" <noonehere@fakoaddresso.como>
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <tc2Pc.41427$28.26814@fe1.news.blueyonder.co.uk>
"Sherm Pendley" <spamtrap@dot-app.org> wrote in message
news:sdOdndrlQP5aI5fcRVn-rQ@adelphia.com...
> krakle wrote:
>
> > I pointed out exactly what
> > he did wrong... Using OO while CGI is called as function.
>
> In the post I replied to, the only thing you "pointed out" was this:
>
> >> $params = $q->Vars;
> >
> >
> > my %params = $q->Vars;
> >
>
> The "error" that you're "correcting" above is not an error, nor does it
> have anything to do with methods vs. functions. Calling Vars() in scalar
> context is allowed, regardless of whether you call it as a method or as
> a function.
>
Thanks for posting your advice which I have taken on board. Much of the
comments are moot now anyway as I emailed my host support who told me they
don't even have CGI::Vars installed anyway and won't do it (cheapskates!).
So all the code posted probably *should* work if that were not the case.
Hence the error message and my earlier suspicions were correct. I've opted
for changing the way I post my variables from the PHP server so I don't need
to use Vars just param().
[snip]
> So drop the snide attitude and whiny "Geesh" comments please.
I totally agree with you. I wish some people would try to remember what it
was like when *they* first started learning to code. It's this kind of
attitude that puts people off Usenet and totally negates any helpfulness of
the comments being offered. I tend to avoid people who post comments like
this as they often just need their egos massaged by being able to patronise
newbies. Thankfully there are people like yourself who are genuinely trying
to help people starting out in code and not just show-boating.
Thanks.
Mark
------------------------------
Date: Sun, 01 Aug 2004 05:00:02 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <7KednT0qAqaOLJHcRVn-pQ@adelphia.com>
Perusion Hostmaster wrote:
> The docs say that you should "use CGI qw/:cgi-lib/" if you want
> to import Vars as a function
That's true.
> -- not if you want to use it as an object method.
That's not. If you call a method, it shouldn't matter if it's imported
or not - importing it is unnecessary, but doing so shouldn't trigger an
"Unknown subroutine" error like the one Mark posted.
On the other paw, unnecessary imports *should* be avoided for the sake
of style and clarity. Think of the poor schmuck who'll have to alter
this code in two years - especially if that poor schmuck might be
yourself. ;-)
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Sun, 01 Aug 2004 05:12:26 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <T_udnfJr9IJmLpHcRVn-hg@adelphia.com>
Mark wrote:
> comments are moot now anyway as I emailed my host support who told me they
> don't even have CGI::Vars installed anyway and won't do it (cheapskates!).
Hmmm... That smells a little fishy. Vars() is part of the standard
CGI.pm module, and that module is standard with Perl 5.8.x and newer.
They might have a very old CGI.pm that doesn't have Vars() - in which
case they'd have to have an old Perl as well.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Mon, 02 Aug 2004 03:04:33 GMT
From: "Mark" <noonehere@fakoaddresso.como>
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <5biPc.23098$a8.5493@fe2.news.blueyonder.co.uk>
They use Perl 5.6.1 so I guess that's why.
Mark
"Sherm Pendley" <spamtrap@dot-app.org> wrote in message
news:T_udnfJr9IJmLpHcRVn-hg@adelphia.com...
> Mark wrote:
>
> > comments are moot now anyway as I emailed my host support who told me
they
> > don't even have CGI::Vars installed anyway and won't do it
(cheapskates!).
>
> Hmmm... That smells a little fishy. Vars() is part of the standard
> CGI.pm module, and that module is standard with Perl 5.8.x and newer.
> They might have a very old CGI.pm that doesn't have Vars() - in which
> case they'd have to have an old Perl as well.
>
> sherm--
>
> --
> Cocoa programming in Perl: http://camelbones.sourceforge.net
> Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Mon, 02 Aug 2004 03:12:26 GMT
From: "Mark" <noonehere@fakoaddresso.como>
Subject: Re: Undefined subroutine CGI::Vars
Message-Id: <uiiPc.23145$a8.13584@fe2.news.blueyonder.co.uk>
"Sherm Pendley" <spamtrap@dot-app.org> wrote in message
news:78Wdnda4-8L-MJHcRVn-uA@adelphia.com...
> Mark wrote:
>
> > use CGI qw(:standard);
> > use CGI qw(:cgi-lib);
> > #during development, put Perl errors to the browser
> > use CGI::Carp qw(fatalsToBrowser);
> > use strict;
> > my $q = new CGI;
> > my $params = $q->Vars();
> >
> > but the server is giving me an error message:
> >
> > Undefined subroutine CGI::Vars
> >
> > but I'm not sure why.
>
> Is that your *real* code?
*Real* code? Are you suggesting I would post *fake* code?! Would I do such a
thing? ;-)
Seriously though, it is just a straight copy and paste.
>
> I suspect that your real code might actually be calling Vars() like this:
>
> my $params = Vars();
>
> In that case, your problem might come from the dual sets of 'use'
> statements. A module that has already been 'use'd won't be reloaded if
> another 'use' is encountered, so the second - which imports the function
> you want to use - wouldn't have any effect.
>
> So you might try one of two things. Either make sure that your real code
> does call Vars() as a method, like the code you posted here does. Or,
> import both groups of functions with a single use statement, like this:
>
> use CGI qw(:standard :cgi-lib);
What I did do is tried every permutation of code I could think of based on
the various articles I read to see where the error could have lain including
what you have given me above but as every permutation brought up the same
errors I did not know where the error lay. The code I posted happened to be
where I was at at the time of posting. (I also tried both OO and method).Yes
I had read about the above in perldoc too but no wonder I was confused - it
was never going to work anyway (see previous post) CGI::Vars was definitely
not installed on the server.
Anyway no need for more replies to this topic for my benefit at least anyway
as had the Vars function been installed on the server my initial code would
have worked right from the start - the perldoc explained it well enough for
me. It was only through messing with the code to try to find the cause of
the error that led to the confused mess of my previous posts. But, of
course, if you still have matters to settle with the other posters in this
thread I will be happily lurking in the background taking notes... ;-)
Mark
>
> sherm--
>
> --
> Cocoa programming in Perl: http://camelbones.sourceforge.net
> Hire me! My resume: http://www.dot-app.org
------------------------------
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 6828
***************************************