[10908] in Perl-Users-Digest
Perl-Users Digest, Issue: 4509 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 28 23:07:20 1998
Date: Mon, 28 Dec 98 20:00:15 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 28 Dec 1998 Volume: 8 Number: 4509
Today's topics:
Re: A big problem an Medium sized one and an Ickle one. (Clay Irving)
Re: About Perldoc <gellyfish@btinternet.com>
Adding a path to the @INC variable <douglasd@iig.com.au>
Re: Adding a path to the @INC variable <douglasd@iig.com.au>
Re: Adding a path to the @INC variable <gellyfish@btinternet.com>
RE: Basic Perl+WWW+CGI for newbies <davis@jersey.net>
Re: Embedding perl with Microsoft VC++ <gellyfish@btinternet.com>
Re: How do I...... beable@my-dejanews.com
How to Display multiple image files into HTML template <shadow01@shaw.wave.ca>
Re: How to Display multiple image files into HTML templ (Sam Holden)
Re: MacPerl: deleting a file (Rich Morin)
Re: My first class <gellyfish@btinternet.com>
Re: My first class <uri@sysarch.com>
Re: My first class <gellyfish@btinternet.com>
Re: Need file upload to display date, size <gellyfish@btinternet.com>
Re: Protecting my script from form data <gellyfish@btinternet.com>
Re: Protecting my script from form data (Groovy94)
Unabel to connect to Oracle using DBD <bageshpu@pa.dec.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Dec 1998 22:51:18 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: A big problem an Medium sized one and an Ickle one.
Message-Id: <769jjm$ner@panix.com>
In <3687d5bc.14663686@nntp.netcom.net.uk> mike@mjm.co.uk writes:
>On Mon, 28 Dec 1998 17:50:43 -0000, "Wallace"
><niall_wallace@yahoo.com> wrote:
>>Hi,
>>
>>I was wondering if anybody could help me with a problem,
>>
>>BIG Problem...
>>
>>I have in 2 strings the values [12/DEC/1998 and +0000].
>>
>>The first is the date and the second a time zone.
>>
>>Although the time zone is not needed
>>I need to remove the [ and ] from both of them for part of my Web Log
>>Analyser.
>>
>>I have been un able to think of a way that will work.
>>
>>The Medium Sized problem
>>
>>I have a percentage of 1.45343729537057439579749735
>>But I only want it to store 1.453 in $Percentage.
>>
>>I know how to print it using Printf but it has to be stored rounded as well.
>$Var=int((1000*$Var)+.5)/1000
>>The Ickle problem sized problem...
>>
>>I need to Round a percentage up or down
>>i.e. 0.5 goes to 1 0.4 goes to 0.
>$Var=int((10*$Var)+.5)/10
The Number::Format module has a bunch of goodies also:
Number::Format
http://www.perl.com/CPAN/authors/William_R_Ward/
>From the docs:
=item round($number, $precision)
Rounds the number to the specified precision. If C<$precision> is
omitted, the default value of 2 is used. Both input and output are
numeric (the function uses math operators rather than string
manipulation to do its job), The value of C<$precision> may be any
integer, positive or negative. Examples:
round(3.14159) yields 3.14
round(3.14159, 4) yields 3.1416
round(42.00, 4) yields 42
round(1234, -2) yields 1200
Since this is a mathematical rather than string oriented function,
there will be no trailing zeroes to the right of the decimal point,
and the C<DECIMAL_POINT> and C<THOUSANDS_SEP> variables are ignored.
To format your number using the C<DECIMAL_POINT> and C<THOUSANDS_SEP>
variables, use C<format_number()> instead.
--
Clay Irving
clay@panix.com
------------------------------
Date: 29 Dec 1998 00:53:01 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: About Perldoc
Message-Id: <76995d$232$1@gellyfish.btinternet.com>
On 28 Dec 1998 23:28:47 GMT Groovy94 <groovy94@aol.com> wrote:
> I always see everyone refer to the perl documentation by sayng perldoc -f
> something. I don't have telnet access, therefore I cannot check the
> documentation the easy way. Is there another way to check it on my comp by
> just entering -f something in a form or something? I have perl on my computer
> with all the documentation, etc.
>
perldoc is a program that allows you to view the Perl documentation from its
native POD format. perldoc -f searches for a function of the same name as the
second argument in the perlfunc documentation and displays the result.
perlfaq -q similarly searches for a keyword in the perlfaq[1-9] documents.
The entire set of documentation is available via:
<URL:http://reference.perl.com>
it is available either in an online format or for download.
I assume when you say you have Perl on your computer - you mean that you
have Perl on the computer of your ISP otherwise you would simply be able
to run perldoc from some command prompt - regardless of the operating
system (Well actually excluding the Macintosh but thats different and
has its own program for these things ).
Of course if you are running a system on your own computer for which there
is a Perl compiler you could do worse than downloading for yourself even
if it is just to get the documentation and 'perldoc'.
An alternative if your ISP is running Unix and has Perl properly setup
as regards its manpages then you might be able to find yourself a program
such as 'man2cgi' that you can run as a CGI on the system and which will
display the manpages in your browser.
For myself I think I would probably go with Downloading the documentation
from CPAN and figuring out some way of displaying and searching it or getting
the whole distribution and of those two I would recommend the latter.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Tue, 29 Dec 1998 12:17:10 +1000
From: "douglas de vine" <douglasd@iig.com.au>
Subject: Adding a path to the @INC variable
Message-Id: <769e86$f8g$1@news.mel.aone.net.au>
How do I add a path to the @INC variable which contains all the paths to
look for *pm files?
------------------------------
Date: Tue, 29 Dec 1998 12:28:06 +1000
From: "douglas de vine" <douglasd@iig.com.au>
Subject: Re: Adding a path to the @INC variable
Message-Id: <769esm$i17$1@news.mel.aone.net.au>
I found this helped me..
ftp://ftp.spu.edu/pub/CPAN/doc/manual/html/pod/perlfaq2.html#I_copied_the_Pe
rl_binary_from_on
douglas de vine wrote in message <769e86$f8g$1@news.mel.aone.net.au>...
>How do I add a path to the @INC variable which contains all the paths to
>look for *pm files?
>
>
------------------------------
Date: 29 Dec 1998 03:13:56 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Adding a path to the @INC variable
Message-Id: <769hdk$2in$1@gellyfish.btinternet.com>
On Tue, 29 Dec 1998 12:17:10 +1000 douglas de vine <douglasd@iig.com.au> wrote:
> How do I add a path to the @INC variable which contains all the paths to
> look for *pm files?
>
>
>From the lib(3pm) manpage.
NAME
lib - manipulate @INC at compile time
SYNOPSIS
use lib LIST;
no lib LIST;
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 28 Dec 1998 21:24:27 -0500
From: Rick Davis <davis@jersey.net>
Subject: RE: Basic Perl+WWW+CGI for newbies
Message-Id: <36883D5B.55797272@jersey.net>
--------------41B71763C955993180D8FDDA
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi,
Just starting to learn Perl.
This offer sounds great.
Please contact me if this offer is a valid.
Can't wait to learn more.
I'm using Redhat 5.1 distribution (Perl 5.004)
Web server not installed currently.
Will install if it will help.
Hope to hear from you,
Rick Davis
_\1/_
( O O ) Rick Davis
/---oOOO---(_)---OOOo---------/
/ / davis@jersey.net or
/ .oooO / mugger@beer.com
/ ( ) Oooo. /
/-----\ (-------------( )---/ HANG IN THERE
\_) ) / IT CAN ALWAYS GET WORSE !!!
(_/
_\1/_
( O O ) Rick Davis
/---oOOO---(_)---OOOo---------/
/ / davis@jersey.net or
/ .oooO / mugger@beer.com
/ ( ) Oooo. /
/-----\ (-------------( )---/ HANG IN THERE
\_) ) / IT CAN ALWAYS GET WORSE !!!
(_/
--------------41B71763C955993180D8FDDA
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
<PRE>Hi,
Just starting to learn Perl.</PRE>
<PRE>This offer sounds great.</PRE>
<PRE>Please contact me if this offer is a valid.</PRE>
<PRE>Can't wait to learn more.</PRE>
<PRE>I'm using Redhat 5.1 distribution (Perl 5.004)</PRE>
<PRE>Web server not installed currently.</PRE>
<PRE>Will install if it will help.</PRE>
<PRE> Hope to hear from you,</PRE>
<PRE> Rick Davis</PRE>
<PRE>
_\1/_
( O O ) Rick Davis
/---oOOO---(_)---OOOo---------/
/ / davis@jersey.net or
/ .oooO / mugger@beer.com
/ ( ) Oooo. /
/-----\ (-------------( )---/ HANG IN THERE
\_) ) / IT CAN ALWAYS GET WORSE !!!
(_/</PRE>
<PRE></PRE>
<PRE></PRE>
<PRE>
_\1/_
( O O ) Rick Davis
/---oOOO---(_)---OOOo---------/
/ / davis@jersey.net or
/ .oooO / mugger@beer.com
/ ( ) Oooo. /
/-----\ (-------------( )---/ HANG IN THERE
\_) ) / IT CAN ALWAYS GET WORSE !!!
(_/</PRE>
</HTML>
--------------41B71763C955993180D8FDDA--
------------------------------
Date: 29 Dec 1998 03:11:20 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Embedding perl with Microsoft VC++
Message-Id: <769h8o$2i7$1@gellyfish.btinternet.com>
On Tue, 29 Dec 1998 01:52:03 +0000 Geir Magnusson Jr. <gmj@netaxis.com> wrote:
> X-Mailer: Mozilla 4.5 [en] (X11; I; Linux 2.0.34 i586)
> X-Accept-Language: en
> MIME-Version: 1.0
> Newsgroups: comp.lang.perl.misc
> Subject: Re: Embedding perl with Microsoft VC++
> References: <36880D6F.2BC3220E@ltpmail.gsfc.nasa.gov>
> Content-Type: text/plain; charset=iso-8859-1
> Content-Transfer-Encoding: base64
>>
>
> I must note that I post this with trepidation that Randall Schwartz will
> reply with somthing containing a large glob of ASCII-encoded drek... :)
> (see the thread "------What should I use as a Win32 perl interpreter-----
> " If you get it, please, clue me in...)
>
Check the header above - this is why your messages appear thus to some and
this is why *I* get the 's embedded everywhere. Some newsreaders do not
do anything with Content-Type: and Content-Transfer-Encoding: headers - you
might be better setting netscape to use "Quoted printable" rather than base64
if you cant stop it from using MIME at all - I've got it here but I dont
really fancy doing a test right now. You might also try using a 'reader
like tin that is much more compliant with general standards and is no
harder to use - If you want to try it out and have any difficulty mail me
and I'll describe my setup.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Tue, 29 Dec 1998 03:10:16 GMT
From: beable@my-dejanews.com
Subject: Re: How do I......
Message-Id: <769h6p$nhq$1@nnrp1.dejanews.com>
In article <u04867.hqm.ln@magna.metronet.com>,
tadmc@metronet.com (Tad McClellan) wrote:
> I don't know of a web site that explains Regular Expressions.
You don't? well you should check this out then:
http://www.perl.com/CPAN/doc/FMTEYEWTK/regexps.html
cheers
beable van beable
--
Beable, you moron. That was a FAKE Captain Picard you were arguing with
before. -- Riboflavin
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 29 Dec 1998 02:11:26 GMT
From: "Webmaster" <shadow01@shaw.wave.ca>
Subject: How to Display multiple image files into HTML template with perl
Message-Id: <iTWh2.1494$Hp.2763@news.rdc1.on.home.com>
I have a large number of images that i want to display but not as links to
image but within a HTML file. Its impracticall to create HTML file for each
image so I've turned to perl.
My idea was to have each link be as follows
www.myhomepage.com/cgi-bin/images.pl&filename.jpg and the perl script would
pick up the name after the & sign and insert it into the allocated spot on
the template HTML file that is being kept the same.
Can some please suggest to make this possible.
Thank you.
------------------------------
Date: 29 Dec 1998 02:20:51 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How to Display multiple image files into HTML template with perl
Message-Id: <slrn78gf43.mg2.sholden@pgrad.cs.usyd.edu.au>
On Tue, 29 Dec 1998 02:11:26 GMT, Webmaster <shadow01@shaw.wave.ca> wrote:
>I have a large number of images that i want to display but not as links to
>image but within a HTML file. Its impracticall to create HTML file for each
>image so I've turned to perl.
>My idea was to have each link be as follows
>www.myhomepage.com/cgi-bin/images.pl&filename.jpg and the perl script would
>pick up the name after the & sign and insert it into the allocated spot on
>the template HTML file that is being kept the same.
>
>Can some please suggest to make this possible.
Ask a specific question and you might get your answer...
Also you won't do it using an & in the URL...
print "Content-type: text/html\r\n\r\n"; # or \n\n I 'use CGI' so I don't care
print qq{<HTML><HEAD><BODY><IMG SRC="/images/$ARV[0]"></BODY></HEAD></HTML>};
Of course that is wrong in numerous ways but is a start...
You'd be better off creating the HTML files and saving some of the load on
the web server... Of course you would create them with a script and not
by hand...
--
Sam
So I did some research. On the Web, of course. Big mistake...
--Larry Wall
------------------------------
Date: Mon, 28 Dec 1998 17:36:11 -0800
From: rdm@cfcl.com (Rich Morin)
Subject: Re: MacPerl: deleting a file
Message-Id: <rdm-2812981736110001@ip42-30.cfcl.com>
In article <768sqb$1i1$1@gellyfish.btinternet.com>, Jonathan Stowe
<gellyfish@btinternet.com> wrote:
> On Mon, 28 Dec 98 14:54:46 EST PETER@yaleads.ycc.yale.edu wrote:
> > Hi. What is the most elegant way of deleting/erasing files under MacPerl?
>
> I guess the same as with other versions of Perl - with 'unlink'.
Indeed. More generally, however, you should consider:
* Visiting the MacPerl Pages (http://www.ptf.com/macperl)
* Joining the MacPerl email list (via the MacPerl Pages)
* Perusing "MacPerl: Power and Ease" (the HTML version is
online at http://www.ptf.com/macperl/ptf_book/HTML)
c.l.p.misc has a few MacPerlies, but the MacPerl list has far more,
and substantially more interest in MacPerl-related questions (:-).
-r
------------------------------
Date: 29 Dec 1998 01:37:13 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: My first class
Message-Id: <769bo9$272$1@gellyfish.btinternet.com>
On Mon, 28 Dec 1998 22:55:06 GMT Slick! <slick@dick.com> wrote:
> I'm trying to create a class with the guidance of the Camel book, but
> I've had little success so far. I've copied all of the object
> construction and autoloading stuff pretty much straight from the Camel
> book, but no luck. The autoload bombs out on the first assignment (to
> 'w'). I went so far as to put a foreach $key(keys %self){print
> "$key\n";}; in the constructor after the bless and it dosent print
> anything, so I suspect that the constructor is part of the problem.
> On the other hand I also tried an assignment in the constructor
> post-bless '$self{w}=1; and it printed out in the foreach loop, but
> autoload still dosen't find 'w'. I get the same output every time:
>
> Can't access 'w' field in object of class CBox at
> G:\DEVSTUFF\perl\learn\oop\CBOX.PM line 4.
>
>
There are a couple problems with your code:
use CBox; # You must have this and this is what is causing your error.
> my $box;
> $box = new CBox;
>
> $box->w(2);
> $box->d(3);
> $box->l(3);
> print "Volume: $box->Volume()\n";
>
__END__
> package CBox;
> use Carp;
>
> my %fields = (
> l => undef,
> w => undef,
> d => undef,
> );
>
> sub new{
> my $that= shift;
> my $class=ref($that) || $that;
> my $self = {
> %fields,
> };
> bless $self,$class;
> return $self;
> }
>
# You could contract that to:
#sub new {
# my $class = shift;
# return bless {
# %fields
# }, $class;
#}
# You dont really need to do all of that stuff unless you want to allow both:
# new CBox and $box->new
> sub Volume{
my $self = shift; # You need this to access the objects variables;
return $self->{"l"} * $self->{"w"} * $self->{"d"};
# Alternatively (preferably ?) you can use the access methods:
# return $self->l * $self->w * $self->d;
> }
>
> sub AUTOLOAD
> {
> my $self = shift;
> my $type = ref($self) || die"$self is not an object";
> my $name = $AUTOLOAD;
> $name=~ s/.*://; #strip fully-qualified portion
> unless (exists $self->{$name}) {
> croak "Can't access '$name' field in object of class $type";
> }
> if (@_){
> return $self->{$name} = shift;
> }else{
> return $self->{$name};
# You had missed out the $ on $name above.
> }
> }
1; # You need to have this or your 'use' will fail...
__END__
Hope that helps
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 28 Dec 1998 21:17:01 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: My first class
Message-Id: <x7hfufheua.fsf@sysarch.com>
>>>>> "JS" == Jonathan Stowe <gellyfish@btinternet.com> writes:
JS> On Mon, 28 Dec 1998 22:55:06 GMT Slick! <slick@dick.com> wrote:
JS> There are a couple problems with your code:
JS> use CBox; # You must have this and this is what is causing your
JS> error.
only if the CBox moduel is in another file. it apparantly isn't or he
would have had even earlier errors. my posted answer also state that by
putting the fields definitions in a BEGIN block that would fix it.
>> print "Volume: $box->Volume()\n";
>>
JS> __END__
that does no use AFAIK. he doesn't need to end the main file.
>> sub new{
>> my $that= shift;
>> my $class=ref($that) || $that;
>> my $self = {
>> %fields,
>> };
>> bless $self,$class;
>> return $self;
>> }
>>
JS> # You could contract that to:
JS> #sub new {
JS> # my $class = shift;
JS> # return bless {
JS> # %fields
JS> # }, $class;
JS> #}
that doesn't dot the same thing exactly. what if your code is called by
a clone method? it would blow up. he does the
my $class=ref($that) || $that;
to handle that situation.
JS> # You dont really need to do all of that stuff unless you want to
JS> allow both: # new CBox and $box->new
but it is better to do that now and not worry about it later.
>> sub Volume{
JS> my $self = shift; # You need this to access the objects variables;
JS> return $self->{"l"} * $self->{"w"} * $self->{"d"};
JS> # Alternatively (preferably ?) you can use the access methods:
JS> # return $self->l * $self->w * $self->d;
but this is inside the module so using the direct access is fine and
much faster as the AUTOLOAD isn't called.
>> return $self->{$name} = shift;
>> }else{
>> return $self->{$name};
JS> # You had missed out the $ on $name above.
another reason to always use quotes and disallowing barewords in hashes.
JS> 1; # You need to have this or your 'use' will fail...
but he didn't have use. this was one file.
JS> __END__
again, not needed if the EOF is there. only if you have data or pod or
other trailing stuff, is __END__ needed.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 29 Dec 1998 02:57:30 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: My first class
Message-Id: <769geq$2hq$1@gellyfish.btinternet.com>
On 28 Dec 1998 21:17:01 -0500 Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "JS" == Jonathan Stowe <gellyfish@btinternet.com> writes:
>
> JS> On Mon, 28 Dec 1998 22:55:06 GMT Slick! <slick@dick.com> wrote:
>
> JS> There are a couple problems with your code:
>
> JS> use CBox; # You must have this and this is what is causing your
> JS> error.
>
> only if the CBox moduel is in another file. it apparantly isn't or he
> would have had even earlier errors. my posted answer also state that by
> putting the fields definitions in a BEGIN block that would fix it.
>
I had erroneously read the error as being to do with the new method and thus
everything sprang from that. I havent seen your other post yet but I have
tried it out in one file with the fields thing in a BEGIN block and two
other alterations too the Volume method and it does work fine, yes.
> >> print "Volume: $box->Volume()\n";
> >>
Except of course that print doesnt work it should have been:
print "Volume: ", $box->Volume(),"\n";
> JS> __END__
>
> that does no use AFAIK. he doesn't need to end the main file.
This springs from having it more than one file and the exigenceies of cutting
and pasting stuff from NG postings - habit of mine rather than a dictum.
<snip>
> JS> __END__
>
> again, not needed if the EOF is there. only if you have data or pod or
> other trailing stuff, is __END__ needed.
>
Yeah my .signature was ;-}
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 29 Dec 1998 02:31:46 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Need file upload to display date, size
Message-Id: <769eui$2do$1@gellyfish.btinternet.com>
On Mon, 28 Dec 1998 19:02:20 -0500 Tamara Williams Jones <tamaraw@mindspring.com> wrote:
> Confession: I am a Perl newbie relying on some education from generous
> others!
>
> I have customized a file upload script quite to my liking (generic
> snippet follows).
> However, it currently only displays the names of the files available in
> the directory in the html output. I really need it to also display the
> date and size of the file, so users can pick the latest file available
> for download.
> I know I can use the fsize and flastmod commands to do so, but don't
> know where to insert the commands - this script uses arrays, which I am
> just getting a grip on.
>
> Multiple experiments have not worked.
> If anyone could tell me where to insert these commands, I would be most
> grateful.
>
There are no fsize and flastmod commands in Perl. You can use the -s and -M
filetest operators respectively or the stat() function - you can find out
about these from the perlfunc manpage.
The following is an example piece of code that shows how you might find
this information out:
#!/usr/bin/perl
$dirname = '/home/gellyfish';
opendir(DIR,$dirname) || die "Cant open $dirname - $!\n";
@files = map { [ $_, -s, (stat($_))[9] ] }
map { $dirname . '/' . $_ }
grep { !/^\.{1,2}/ }
readdir(DIR);
closedir(DIR);
foreach (@files)
{
print $_->[0],"\t",$_->[1],"\t",scalar(localtime($_->[2])),"\n";
}
__END__
The majority of the work here is done in one statement which creates a
list of lists [multi-dimensional array] containing the filename, size and
last modified date in a reference to an anonymous array in each element of
@files. This is simply printed out then in a foreach loop.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 29 Dec 1998 02:02:56 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Protecting my script from form data
Message-Id: <769d8g$29g$1@gellyfish.btinternet.com>
On 29 Dec 1998 00:19:01 GMT Groovy94 <groovy94@aol.com> wrote:
> I am trying to protect my script from malicious form entry data. I have
> included the following code into my own modified readparse and don't think it
> works, but am not sure why.
>
By this and the regex I assume that you are fixing to allow some user input
near to a shell - this is considered to be a *bad thing* , it is better
that you should avoid allowing this anywhere where it might do any harm - if
you are going to use system() then you should perhaps consider using the
multiple argument form which will not cause a shell to be spawned. If you
are using the backticks or a piped open then you might perhaps try to
find another way of doing this.
You should read the perlsec manpages for more on security issues and Perl.
> elsif ($value =~ /([;<>\*\|'$\$\(\)\[\]\{\}:'"]) {
I believe that the only thing in that character class that you need to
escape are the square brackets themselves and those I'm not sure about.
The problem with using this kind of thing to cleanse your data is that you
might still not have achieved the desired result but have given yourself
a false sense of security - I reiterate that it is far better to simply
prevent the user input from getting anywhere it might do harm rather than
try to filter it like this.
> print <<EOHTML;
> Your data was not parsed because it contained characters
> that could possibly perform malicious tasks with this program.
> Please go back and fill out the form, ommiting any extra characters,
> such as <strong>;,<,>,*,$,/,\</strong>.
> EOHTML
> exit;
> }
>
And if you really insist on doing it this way then I dont think you want to
be telling them that :-}
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 29 Dec 1998 03:50:48 GMT
From: groovy94@aol.com (Groovy94)
Subject: Re: Protecting my script from form data
Message-Id: <19981228225048.00797.00003190@ng-fv1.aol.com>
>it is far better to simply
>prevent the user input from getting anywhere it might do harm
How wouldI do that? I am not a perl guru and read in my perl book that adding
something like I posted was a good way of stopping malicious attacks using the
program.
> if
>you are going to use system()
Did I say or hint at using system()? I am not even sure what system() is. I
know that it is best to avoid using the shell, but I wasn't aware that I
actually was...
Regards,
Gil Hildebrand, Jr.
Dynamic Scripts
Email: groovy94@aol.com
ICQ UIN: 16678754
------------------------------
Date: Mon, 28 Dec 1998 16:55:03 -0800
From: Asha Bageshpura <bageshpu@pa.dec.com>
Subject: Unabel to connect to Oracle using DBD
Message-Id: <36882867.A09519A0@pa.dec.com>
I have installed DBI and when I try to install DBD I get the following
error.
Through sqlplus I have checked connecting to oracle and it is ok
t/general...........install_driver(Oracle) failed: Can't load
'./blib/arch/auto/D
BD/Oracle/Oracle.so' for module DBD::Oracle: dlopen: cannot load
./blib/arch/auto
/DBD/Oracle/Oracle.so at
/log/perlmodules/perl4/lib/alpha-dec_osf/5.00404/DynaLoa
der.pm line 166.
at (eval 1) line 2
at t/general.t line 1
Any ideas are welcome
Thanks
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 4509
**************************************