OOP

J

JC

Hi.
I'm familiar with OOP, and I use it in VB, but I don't have that talent
in PERL. For example, I write a good bit of code, using syntax like:
if($FORM{'calculate_shipping'} eq "") {
&show_calc_shipping;
}
else {
$ship_data = &calc_shipping;
}
That's easy, but I don't understand the following:
$rateReqEl->setAttribute('USERID', 'xxxxxxxx');
$rateReqEl->setAttribute('PASSWORD', 'xxxxxxxx');
$rateReqDoc->appendChild($rateReqEl); $

Even my CGI book doesn't talk like that. Where's a good place to learn
this dialect? I need to interact with the USPS servers, and this is how
their documents tell me to query (using Perl XML parser and libwww-perl).

Thanks,
-jc
 
B

Ben Morrow

JC said:
Hi.
I'm familiar with OOP, and I use it in VB, but I don't have that talent
in PERL. For example, I write a good bit of code, using syntax like:
if($FORM{'calculate_shipping'} eq "") {
&show_calc_shipping;
}
else {
$ship_data = &calc_shipping;
}

This is not a good piece of code. Don't call subs with & unless you need
it's side-effects.
That's easy, but I don't understand the following:
$rateReqEl->setAttribute('USERID', 'xxxxxxxx');
$rateReqEl->setAttribute('PASSWORD', 'xxxxxxxx');
$rateReqDoc->appendChild($rateReqEl); $

Even my CGI book doesn't talk like that. Where's a good place to learn
this dialect? I need to interact with the USPS servers, and this is how
their documents tell me to query (using Perl XML parser and libwww-perl).

Start by reading perldoc perltoot.

Ben
 
U

Uri Guttman

J> I'm familiar with OOP, and I use it in VB, but I don't have that
J> talent in PERL. For example, I write a good bit of code, using syntax
J> like:
J> if($FORM{'calculate_shipping'} eq "") {
J> &show_calc_shipping;
J> }
J> else {
J> $ship_data = &calc_shipping;
J> }
J> That's easy, but I don't understand the following:
J> $rateReqEl->setAttribute('USERID', 'xxxxxxxx');
J> $rateReqEl->setAttribute('PASSWORD', 'xxxxxxxx');
J> $rateReqDoc->appendChild($rateReqEl); $

J> Even my CGI book doesn't talk like that. Where's a good place to
J> learn this dialect? I need to interact with the USPS servers, and
J> this is how their documents tell me to query (using Perl XML parser
J> and libwww-perl).

perldoc perlobj

the book object oriented perl is a classic

uri
 
T

Tassilo v. Parseval

Also sprach JC:
I'm familiar with OOP, and I use it in VB, but I don't have that talent
in PERL. For example, I write a good bit of code, using syntax like:
if($FORM{'calculate_shipping'} eq "") {
&show_calc_shipping;
}
else {
$ship_data = &calc_shipping;
}
That's easy, but I don't understand the following:
$rateReqEl->setAttribute('USERID', 'xxxxxxxx');
$rateReqEl->setAttribute('PASSWORD', 'xxxxxxxx');
$rateReqDoc->appendChild($rateReqEl); $

Those are method calls where the part before the arrow is the object
upon which to call the method.
Even my CGI book doesn't talk like that. Where's a good place to learn
this dialect? I need to interact with the USPS servers, and this is how
their documents tell me to query (using Perl XML parser and libwww-perl).

I'd start with perlboot.pod from the standard perldocs. If you want to
know more, follow the suggested reading in the "SEE ALSO" section of
this manpage.

Tassilo
 
S

Suresh Govindachar

JC said:
Hi.
I'm familiar with OOP, and I use it in VB, but I don't have that talent
in PERL. For example, I write a good bit of code, using syntax like:
if($FORM{'calculate_shipping'} eq "") {
&show_calc_shipping;
}
else {
$ship_data = &calc_shipping;
}
That's easy, but I don't understand the following:
$rateReqEl->setAttribute('USERID', 'xxxxxxxx');
$rateReqEl->setAttribute('PASSWORD', 'xxxxxxxx');
$rateReqDoc->appendChild($rateReqEl); $

Even my CGI book doesn't talk like that. Where's a good place to learn
this dialect? I need to interact with the USPS servers, and this is how
their documents tell me to query (using Perl XML parser and libwww-perl).

Thanks,
-jc

Book for OOP Perl: Object Oriented Perl by Damian Conway

(For a simple comparison of an OO hello world in
cpp and in perl: http://www.sonic.net/~suresh/thinking_oo )

--Suresh
 
T

Tore Aursand

I'm familiar with OOP, and I use it in VB, but I don't have that talent
in PERL. For example, I write a good bit of code, using syntax like:
if($FORM{'calculate_shipping'} eq "") {
&show_calc_shipping;
}
else {
$ship_data = &calc_shipping;
}

Are you decoding CGI data manually? You really should use the CGI module
for that kind of work.

And don't call sub-routines with a '&' unless you really know what you're
doing.
That's easy, but I don't understand the following:
$rateReqEl->setAttribute('USERID', 'xxxxxxxx');
$rateReqEl->setAttribute('PASSWORD', 'xxxxxxxx');
$rateReqDoc->appendChild($rateReqEl); $

'$rateReqEl' and '$rateReqDoc' are objects, while the part after the '->'
is the object's method.

Check out the OOP documentation for more details;

perldoc perlboot
perldoc perltoot
 
M

Michel Rodriguez

JC said:
[...] I don't understand the following:
$rateReqEl->setAttribute('USERID', 'xxxxxxxx');
$rateReqEl->setAttribute('PASSWORD', 'xxxxxxxx');
$rateReqDoc->appendChild($rateReqEl); $

Even my CGI book doesn't talk like that. Where's a good place to learn
this dialect? I need to interact with the USPS servers, and this is how
their documents tell me to query (using Perl XML parser and libwww-perl).

Once you have learned the basics of OO Perl, you will need to understand
what this specific piece of code does: setAttribute and appendChild look
very much like methods from the XML::DOM module. $rateReqEl is an
XML::DOM::Element and $rateReqDoc is an XML::DOM::Document.

As XML::DOM should be installed on your system you can do a perldoc
XML::DOM or man XML::DOM to read the docs for the module. Alternatively
you can read it at http://search.cpan.org/dist/XML-DOM/ (where you can
also download the latest version of the module)

It is possible that your code uses XML::LibXML instead of XML::DOM
(which would be a good thing as XML::LibXML is more recent and a lot
more powerful), as it has the same methods (they come straight out of
the DOM) in which case look at http://search.cpan.org/dist/XML-LibXML

You can tell which module your code use by searching for use XML::DOM or
use XML::LibXML.
 
J

JC

Thanks for replying to my original post and for pointing me in some
directions. As I mentioned, I code alot with PERL, but I'm pretty much
self-taught, so I'm sure that I learned incorrectly and am at a very
intro level, still.
And don't call sub-routines with a '&' unless you really
know what you're doing.

Nope, I don't know enough to know otherwise.
XML::DOM
XML::DOM::Document

Nope, don't know what these mean. I starting learning at
www.cgi101.com, in 1999, and have since used an HTML version of a perl.1
man page for PERL v. 4, Teach Yourself CGI Programming with PERL 5, and
other people's code. I'm limping, but thanks for the help.

-jc
 
J

JC

Tad said:
No you don't.
You code a lot with Perl.
Perl is not an acronym.

Why do you waste your time to "correct" me?
PERL = Practical Extraction and Report Language.

Get a life, or a girlfriend.
-jc
 
J

Jürgen Exner

JC said:
Why do you waste your time to "correct" me?
PERL = Practical Extraction and Report Language.

Get a life, or a girlfriend.

Mabye because apparently you don't know that this "explanation" is wrong and
a "reverse acronym"?
Maybe you don't even know that there is a FAQ about it:
"What's the difference between "perl" and "Perl"?"

However, Tad jumped the gun a bit, too.
He couldn't know if maybe you are programming a lot in some other
programming language PERL which is different from Perl?

jue
 
B

Beable van Polasm

JC said:
Thanks for replying to my original post and for pointing me in some
directions. As I mentioned, I code alot with PERL, but I'm pretty
much self-taught, so I'm sure that I learned incorrectly and am at a
very intro level, still.


Nope, I don't know enough to know otherwise.

Call subroutines with parentheses, like this:

mysub();

sub mysub
{
print "doidy doidy doidy\n";
}
Nope, don't know what these mean.

These are module names. Take a look at http://search.cpan.org and
type these names in. Search for documentation on installing modules,
like "perldoc perlmodinstall" for example. Using modules will make
writing programs easier.
 
T

Tad McClellan

JC said:
Why do you waste your time to "correct" me?


1) because you are wrong.

2) because it is not a waste of time to help you clear up
your misunderstanding.

3) because I assumed you would _want_ to be correct.

4) so people don't continue to snicker at you because you can't
even spell the name of the language you are using.


If you prefer to have your ignorance laughed at, that is certainly
up to you.

I just wanted to give you the opportunity to be taken seriously.

PERL = Practical Extraction and Report Language.


Errr, that pretty much proves my point.

Larry chose the name first, the expansion came later.

If you wanted to prove your incorrect point, it would go in
the other direction, the expansion would lead to the name:

Practical Extraction and Report Language = PERL

Get a life,


Get multiple interconnected brain cells.

or a girlfriend.


While I have a great wife, I doubt that she is great enough to go
along with that suggestion...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top