[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] How do you use Safe.pm?



(This question has been posted several times to both comp.lang.perl.misc
and comp.lang.perl.modules, but to no avail. This is why I am posting it
to this mailing list).

I have written a MacPerl script (which will later be ported to Unix)
that parses the contents of a form, sequentially reads the records of a
text file containing lamp data (lamp type, lamp style, and lamp height),

and stores all the file's records that match the criteria defined in an
HTML form.

The form looks more or less like this :

<FORM>

Lamp type:<SELECT
NAME="type"><OPTION>halogen<OPTION>street-lamp<OPTION>lamp</SELECT>

Style :<SELECT
NAME="style"><OPTION>Louis-XVI<OPTION>Louis-XVII<OPTION>Louis-XVIII</SELECT>

Height   <SELECT NAME="opHeight">
                <OPTION> >
                <OPTION> <
                <OPTION> =
</SELECT>
<INPUT TYPE=TEXT NAME="height" VALUE="0">

</FORM>

The text file looks like this :
Halogen\tLouis-XVI\t30\n
...

The Perl code that I have written stores the contents of the form in
scalars, reads in each record in the file, puts the values into scalars
($mytype, $mystyle, $myheight) and does the following eval:

$evalString = (($mytype eq $type) && ($mystyle eq $style) && ($myheight
$opHeight $height));

# For example, the user is looking for Louis XIV halogen lamps whose
height is > 10 inches. We must therefore find
# records where (("halogen" eq "halogen") && ("Louis-XVI" et
"Louis-XVI") && (11 or 12 or ... > 10))

# is $evalString true?
if ($evalString) {
 # put the record in an array; i.e., that record matches the criteria in

the form
}
 
I have read in various Perl books that eval should be used in CGI
scripts because they are unsafe. I have also read that Safe.pm can help
alleviate this problem. However, documentation on Safe.pm is scarce in
books, on the Net, and elsewhere, and detailled examples almost non
existent.

Could someone please tell me where I can find a simple example of how to
use Safe.pm and explain to me how I can use it in the case described
above?

Many thanks.

Philippe de Rochambeau


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch