OOP to standard

G

Guy

What would be the standard way of writing the following object oriented perl
code?

use CGI;
$CGI::DISABLE_UPLOADS = 1;
$CGI::pOST_MAX=102_400; # 100KB ex: 1024 x 100

And why is there an underscore in 102_400?

Guy
 
A

A. Sinan Unur

What would be the standard way of writing the following object
oriented perl code?

use CGI;
$CGI::DISABLE_UPLOADS = 1;
$CGI::pOST_MAX=102_400; # 100KB ex: 1024 x 100

use CGI;
$CGI::DISABLE_UPLOADS = 1;
$CGI::pOST_MAX = 100 * 1024; # no need for the silly comment.
And why is there an underscore in 102_400?

That is just a convenient way of formatting numbers in Perl.

See "Scalar value constructors" in perldoc perldata.

In fact, it looks like you should read all of the FAQ and most of the
other documents bundled with Perl before writing any more code.

Sinan


--
A. Sinan Unur <[email protected]>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
 
T

Tad J McClellan

Guy said:
What would be the standard way of writing the following object oriented perl
code?

use CGI;
$CGI::DISABLE_UPLOADS = 1;
$CGI::pOST_MAX=102_400; # 100KB ex: 1024 x 100


There is no object orientation in any of that code.

If you think that there is, then you have a conceptual misunderstanding
somewhere.

If you can explain why you think that that code is object-oriented
then we could probably help to clear up your misunderstanding.

So, why do you think that the above is object-oriented?

And why is there an underscore in 102_400?


Why is there a comma in 102,400?

You really must get a better grasp on fundamentals before proceeding.

Reading about Perl's data types before writing Perl programs
would be a Really Good Idea:

perldoc perldata

... You are allowed to use underscores ...
 
G

Guy

Tad J McClellan said:
There is no object orientation in any of that code.

If you think that there is, then you have a conceptual misunderstanding
somewhere.

If you can explain why you think that that code is object-oriented
then we could probably help to clear up your misunderstanding.

So, why do you think that the above is object-oriented?

I was refering to O'Reilly's "CGI Programming with Perl 2e", by Guelich...,
p87 says:
CGI.pm like Perl is powerful yet flexible.
It supports two styles of usage:
a standard interface
and an OO interface...

further on p88:
Here is an example. The OO syntax:
use strict;
use CGI;
my $q = new CGI;
my $name = $q->param( "name" );
print $q->header( "text/html" );
The standard Syntax looks like this:
use strict;
use CGI qw ( :standard );
my $name = param( "name" );
print header( "text/html" );

So I just figured that when you have [use CGI;] instead of [use CGI qw(
:standard )] it meant it was OO. I guess that's not quite right.
Guy
 
G

Gunnar Hjalmarsson

Guy said:
I was refering to O'Reilly's "CGI Programming with Perl 2e", by Guelich...,
p87 says:
CGI.pm like Perl is powerful yet flexible.
It supports two styles of usage:
a standard interface
and an OO interface...

further on p88:
Here is an example. The OO syntax:
use strict;
use CGI;
my $q = new CGI;
my $name = $q->param( "name" );
print $q->header( "text/html" );
The standard Syntax looks like this:
use strict;
use CGI qw ( :standard );
my $name = param( "name" );
print header( "text/html" );

So I just figured that when you have [use CGI;] instead of [use CGI qw(
:standard )] it meant it was OO. I guess that's not quite right.

You can always use the OO interface.

use CGI qw( :standard );

means that you import a bunch of subroutine names into your script,
which makes it possible to use the standard interface as well. You are
then free to mix them to your liking.
 
T

Tad J McClellan

Guy said:
Tad J McClellan said:
There is no object orientation in any of that code.

If you think that there is, then you have a conceptual misunderstanding
somewhere.

If you can explain why you think that that code is object-oriented
then we could probably help to clear up your misunderstanding.

So, why do you think that the above is object-oriented?

I was refering to O'Reilly's "CGI Programming with Perl 2e", by Guelich...,
p87 says:
CGI.pm like Perl is powerful yet flexible.
It supports two styles of usage:
a standard interface
and an OO interface...

further on p88:
Here is an example. The OO syntax:
use strict;
use CGI;
my $q = new CGI;
my $name = $q->param( "name" );
print $q->header( "text/html" );
The standard Syntax looks like this:
use strict;
use CGI qw ( :standard );
my $name = param( "name" );
print header( "text/html" );

So I just figured that when you have [use CGI;] instead of [use CGI qw(
:standard )] it meant it was OO. I guess that's not quite right.
^^^^^^^^^^^^^^^

It is not right at all.

There must exist an object for it to be object oriented!

i.e. there must be a bless() somewhere (often buried in a constructor
as with CGI->new() above) to create an object in Perl.

You appear to not yet have a handle on what a "package" is in Perl.

perldoc perlmod

should help with that. Packages are used for both functional and
object-oriented modules.

All the
use CGI qw ( :standard );
does it to import some symbols (function names) into your program's
namespace. You can use a functional style *without* importing
anything too, but then you need to use the fully qualified name
of the function. eg:

use CGI;
my $name = CGI::param( "name" );
 

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,214
Messages
2,571,111
Members
47,703
Latest member
robert.marryson

Latest Threads

Top