Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > and why can't I do my own CGI?

Reply
Thread Tools

and why can't I do my own CGI?

 
 
hudson
Guest
Posts: n/a
 
      08-17-2003
I think you are very wrong here in what you are saying. I just came to
say...hey...there are not really a lot of examples of using soap with
perl without the module and bam! I got slammed.

And using soap via IO::Socket is so easy. So I posted up my little
piece of code and people started calling me names.
 
Reply With Quote
 
 
 
 
hudson
Guest
Posts: n/a
 
      08-17-2003
>you use the io::socket module? why not use real sockets. real
>programmers do that.


hey uri....I'm all ears...please tell me about it.

can you do real sockets in perl? or are you talking C function
calls....

about my promise to learn C...it will take me a couple of years maybe.
 
Reply With Quote
 
 
 
 
hudson
Guest
Posts: n/a
 
      08-17-2003
>
><sigh>


OK...sorry to make you sign...
>
>Yes. Look up the following Perl builtin functions:
>
> accept, bind, connect, getpeername, getsockname, getsockopt, listen,
> recv, send, setsockopt, shutdown, socket, socketpair.
>
>It's good to write things like soap, CGI, and socket stuff by hand from
>scratch, but *only* as a programming exercise; never for the real world,
>even if you only use it on your own play systems. I've done socket
>programming in C, and in Perl using the above functions, and in Perl
>using IO::Socket. I've done CGI programming by hand, using my own code
>to parse the input data, and I've used CGI.pm. I've never done Soap in
>any language; but you can be sure I'd use a module. In all cases, it is
>instructive and illustrative to code it by hand, to understand what's
>going on under the hood, but for anything approaching the real world, an
>off-the-shelf module will almost certainly do the job better and more
>efficiently than you (or I) can.
>
>That said, one can't improve the state of Perl modules without knowing
>what's going on under the hood and grokking the internals of the existing
>modules. There are times when a wheel simply needs to be reinvented,
>because the existing wheel is inadequate (example: Module::Build coming
>out over the existing ExtUtils::MakeMaker). But -- not to sound
>condescending -- "it is not yet time for you to leave, Grasshopper."
>
>


perl is kind of built from other things, isn't it? sed, awk, C,
etc....maybe the correct way to learn perl is to understand
computers...since isn't that what those built in functions you are
talking about come from:

accept, bind, connect, getpeername, getsockname, getsockopt, listen,
recv, send, setsockopt, shutdown, socket, socketpair.

that's all from a sleepy grasshopper

 
Reply With Quote
 
Tassilo v. Parseval
Guest
Posts: n/a
 
      08-17-2003
Also sprach hudson:

> perl is kind of built from other things, isn't it? sed, awk, C,
> etc....maybe the correct way to learn perl is to understand
> computers...since isn't that what those built in functions you are
> talking about come from:
>
> accept, bind, connect, getpeername, getsockname, getsockopt, listen,
> recv, send, setsockopt, shutdown, socket, socketpair.


I think you can turn that around even. Understand computers (at least
some essential concepts relating to operating systems) by using and
learning Perl. Perl is suitable for that (and to some degrees more
suitable than other scripting languages) because it offers some very
low-level constructs (the ones you quoted above plus - among others -
the IPC-stuff as layed out in perlipc.pod) without negelecting the
high-level stuff.

Since you said you planned on picking up C: I owe to Perl everything I
learnt about C. Perl was my first language I became fluent with and
after a while I became interested in the Perl-internals and started
doing XS (essentially, writing Perl modules in C with the help of the
PerlAPI). It's an odd way of learning C because XS doesn't have the
reputation of being particularly beginners-friendly. But, alas, anything
can happen when doing Perl.

And then C helped me to understand more of Perl. I never understood how
to use pack() and unpack() till I realized how closely they ressemble
the way C handles different data-types and converts them into each
other. C:

/* an 'int' is four bytes on my machine */
unsigned char c[4] = { 255, 255, 255, 255 };
unsigned int *i = (int*)c;

Perl:

$i = unpack "L", chr(255).chr(255).chr(255).chr(255);

Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus}) !JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexi ixesixeseg;y~\n~~dddd;eval
 
Reply With Quote
 
Jonathan Stowe
Guest
Posts: n/a
 
      08-17-2003
Hudson <(E-Mail Removed)> wrote:
>>Reinventing wheels is for cavemen.

>
> thank you Eric.
>
> you know what...parsing CGI is kind of a bitch...maybe I should just
> load in part of a module and not use the whole thing.


You might want to examine the code of CGI.pm: although the actual file is
quite large it employs a number of techniques to keep the load and parse
time to a minimum - whilst the entire file must be read by perl, on the most
part only those methods that are actually used are parsed and compiled, so
splitting the file up is unlikely to lead to a great improvement in
performance and is likely to introduce new bugs.

/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
 
Reply With Quote
 
Chris Mattern
Guest
Posts: n/a
 
      08-18-2003
hudson wrote:
>>Nothing appears to be hard for you. So what do you want from this group?
>>If things are really that simple but you nonetheless consult the group
>>for help, perhaps they are still too tall an order for you.
>>

>
>
> bah....I just thought this was the "abuse me please" channel. anyway,
> as other people have mentioned before, this group does seem a bit
> dogmatic on certain topics
>


They insist on code that works. How narrow-minded, indeed.

Chris Mattern

 
Reply With Quote
 
hudson
Guest
Posts: n/a
 
      08-20-2003
Thanks Tassilo,

I just read several books about unix and C and I am amazed at how much
it helped me understand Perl, so I totally agree with you.

 
Reply With Quote
 
hudson
Guest
Posts: n/a
 
      08-20-2003
>One issue you didn't mention, which seems to me to be very relevant in
>practice: even the simplest of hand-coded scripts has a tendency to
>add features during its life. Maybe to support POST when it was
>originally only to support GET - maybe to support file-upload when it
>originally didn't - maybe to support re-writing an incomplete form and
>prompting for required fields that had been left blank or wrongly
>completed - and so on. If started off the right way, then CGI.pm
>allows such features to be bolted on almost for free. If started off
>with hand-coding, then such a script rapidly becomes an insecure and
>unmaintainable quivering heap. I know - I've made just that mistake
>for myself, in the early days.


this was a great post for me, since I can really relate to it
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using own classloader inside J2EE to load and unload own classes. Stefan Siegl Java 1 07-02-2013 05:05 AM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Allowing access to my own computers within my own network =?Utf-8?B?VHJldm9y?= Wireless Networking 2 07-20-2006 09:05 PM
I have built my own (simple) thread manager [TM], but just found java 5 has its own. Saverio M. Java 0 07-03-2006 08:52 AM



Advertisments