I agree completely with ajt's worries about the security of what you're doing, but I'd also like to raise a couple of points about your use of CGI.pm.

CGI.pm has two APIs - an object oriented interface and a functional interface. Although the majority of references seem to use the OO interface, I think that the functional interface is simpler to use.

In the functional interface you import a set of functions into your program's namespace. You do this by passing optional arguments into the use CGI statement like this:

use CGI qw(:standard);

:standard defines a particular set of functions that will cover most of your CGI needs. Having imported the functions you can just use them without having to create an object. Like this:

use CGI qw(:standard); my $name = param('name'); print header, start_html, h1('Test Page'); print p("The name is $name"); print end_html;

On the other hand, if you use the OO interface you need to create a CGI object and then access all of the functions thru that object. Like this:

use CGI; my $q = CGI-new; my $name = $q->param('name'); print $q->header, $q->start_html, $q->h1('Test Page'); print $q->p("The name is $name"); print $q->end_html;

It's not that much more typing, but I think that the functional version looks neater.

I mention this, because you use the functional way of loading CGI.pm but then go on to use the OO interface thoughout your script. This shows that you may be slightly confused.

Oh, and one more thing about the OO interface. Using syntax like:

my $q = new CGI;

instead of

my $q = CGI->new;

Is going to work fine 999 times out of a 1000, but it can occasionally lead to very hard to track down bugs. Read what Damian Conway says about the indirect object syntax in Object Oriented Perl for a full description of the problems.

Blessed Be
The Pixel


In reply to Re: Easy Script Editor by pixel
in thread Easy Script Editor by George_Sherston

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.