[17628] in Perl-Users-Digest
Perl-Users Digest, Issue: 5048 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 6 18:06:56 2000
Date: Wed, 6 Dec 2000 15:05:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976143916-v9-i5048@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 6 Dec 2000 Volume: 9 Number: 5048
Today's topics:
Re: and- Profanity Check (Tad McClellan)
ANNOUNCE: Template Toolkit version 2.00 (Andy Wardley)
Applications of unary plus (was: Sorting the result of <W.Hielscher@mssys.com>
Re: Beginner's question <square-sun@terra.es>
Re: Beginner's question dtbaker_dejanews@my-deja.com
Re: Beginner's question <square-sun@terra.es>
Can't locate File/Spec.pm in @INC CPAN Dead? <see_sig@msg.bottom>
Re: changing file permissions with a perl command (not <jeff@yoak.com>
Re: Duplicate Unix's time program on Windows <ted_graham@my-deja.com>
Re: Duplicate Unix's time program on Windows (Tad McClellan)
Emailed answers (was Re: Problem with warn,next,if comb (Tad McClellan)
Re: find function nodo70@my-deja.com
Find::Find untaint_skip broken? (Michael Fuhr)
For or while problem in iterating program. <kyle@iol.ie>
Re: For or while problem in iterating program. <stephenk@cc.gatech.edu>
Getting multiple random lines <peliknish@my-deja.com>
Re: Getting multiple random lines <iltzu@sci.invalid>
HASH OF LISTS - Question WA Support
Help - passing hash array into a subroutine (Stephen Patterson)
Re: Help - passing hash array into a subroutine (Abigail)
Re: Help - passing hash array into a subroutine (Tad McClellan)
HELP: regexing html rkasprow@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 6 Dec 2000 15:18:44 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: and- Profanity Check
Message-Id: <slrn92t7p4.qf6.tadmc@magna.metronet.com>
kcount <kcount@ardenhouse.com> wrote:
>foreach $dirtyword (@badwords) {
> if ($FORM{'body'} =~ m/$dirtyword/i) {
> # do whatever you want with the body of the form here
> last; #break out of the loop
> }
>}
Please don't try and re-answer FAQs. Just provide a pointer to
the answer.
That is the same code that the FAQ points out as "extremely inefficient"
and "slow but obvious way".
With just your answer, that is what they're stuck with. With a
pointer to the FAQ, they can see that faster alternatives exist
and make an informed decision.
There is a reason for having FAQ lists.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 06 Dec 2000 15:55:31 GMT
From: abw@cre.canon.co.uk (Andy Wardley)
Subject: ANNOUNCE: Template Toolkit version 2.00
Message-Id: <t2taf2dlgjsd1@corp.supernews.com>
After a long and generally healthy beta test period, version 2.00 of the
Template Toolkit is finally released. It can be downloaded from any
CPAN site:
http://www.cpan.org/modules/by-module/Template/
Installation
------------
Unpack the distribution archive to create an installation directory
and perform the usual incantation for installing a Perl module. e.g.
tar zxf Template-Toolkit-2.00.tar.gz
cd Template-Toolkit-2.00
perl Makefile.PL
make
make test
make install
Don't forget to read the README file which contains all the information
you need to get started. You may also like to consult the Changes and
TODO files.
Description
-----------
The Template Toolkit is a collection of modules which implement a
fast, flexible, powerful and extensible template processing system.
It was originally designed and remains primarily useful for generating
dynamic web content, but it can be used equally well for processing
any other kind of text based documents: HTML, XML, POD, PostScript,
LaTeX, and so on.
It can be used as a stand-alone Perl module or embedded within an
Apache/mod_perl server for generating highly configurable dynamic web
content. A number of Perl scripts are also provided which can greatly
simplify the process of creating and managing static web content and
other offline document systems.
Version 2 is a near-total rewrite which adds many new features while
remaining *almost* fully backwardly compatible with version 1 (see
'VERSION COMPATABILITY' in the README file). The internal design and
architecture have been greatly improved and the template language
offers a number of powerful new directives, while retaining all but
the broken, buggy, undocumented or experimental features that had
crept into versions 0.* and 1.* over the years. Version 2 also offers
important performance benefits, running significantly faster and using
less memory than version 1. This can only be described as a Good
Thing.
Key Features
------------
* simple but powerful language syntax and semantics
* promotes a clear separation between application functionality and
presentation elements
* variable substitution allows binding to any Perl data types
(scalars, hashes, lists, subs, objects)
* conditional blocks (IF/UNLESS/ELSIF/ELSE, SWITCH/CASE)
* loops and iterators (FOREACH, WHILE)
* file/template inclusion (INSERT, INCLUDE, PROCESS, WRAPPER)
* definition of local template components (BLOCK)
* post-processing filters (FILTER)
* plugin module architecture for easy extensibility (USE)
* embedded Perl can be optionally enabled (PERL/RAWPERL)
* full exception handling (TRY/THROW/CATCH/FINAL)
* user-defined macros (MACRO)
* definition of template metadata (META)
* virtual methods for complex data types (e.g. list.size, hash.keys, etc.)
* numerous configuration options
* modular OO architecture allows extensive customisation
* fast LALR(1) parser modules compiles templates according to a
YACC-like grammar.
* templates compiled to Perl code for efficient runtime execution
* in-memory and on-disk caching of compiled templates
* simple front end module (Template.pm) for ease of use
* numerous plugin modules: CGI, DBI, XML, URL, Date, Table, etc
* standard filters for html, case folding, regex search and replace, etc.
Copyright
---------
Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved
Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
This is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
------------------------------
Date: Wed, 06 Dec 2000 20:31:34 +0100
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Applications of unary plus (was: Sorting the result of a function)
Message-Id: <3A2E9416.8EB481D3@mssys.com>
Abigail wrote:
> On Tue, 05 Dec 2000 13:37:33 +0100, Wolfgang Hielscher (W.Hielscher@mssys.com) wrote in comp.lang.perl.misc <URL: news:<3A2CE18D.AB183D98@mssys.com>>:
> ++
> ++ What I was trying to say was that IMO 'sort +f()' demonstrates the
> ++ practical use of the unary plus in a more "realistic" or "natural"
> ++ situation than
>
> I use unary plus quite often; most of the time in hash keys:
>
> $hash {+shift} = "foo";
Yet another fine and useful application I like more than
chdir +($foo) * 20
(And I should remember it for my next golf match as a substitute for
$hash {shift()} ...)
Cheers
Wolfgang
------------------------------
Date: Wed, 06 Dec 2000 19:52:46 GMT
From: Nick <square-sun@terra.es>
Subject: Re: Beginner's question
Message-Id: <mVu9LuABZpL6Ew81@terra.es>
In article <90jrq0$o4v$1@hermes.nz.eds.com>, Peter Sundstrom
<peter.sundstrom@eds.com> writes
>
>Nick <square-sun@terra.es> wrote in message
>news:F5wvK7AjAVL6Ewao@terra.es...
>> Is it possible to get a Perl interpreter to run on a Win98 machine so I
>> don't have to go online to test scripts?
>
>Go to http://www.activestate.com/
>
>BTW, your subject line is meaningless. A better subject line would have
>been "Is Perl available for Win98"
>
>
Thanks.
Apologies for the useless subject line - I'll do better in future.
--
Nick
news@square-sun.co.uk
Chainsaw sculpture - Wooden books - Pictures
http://www.square-sun.co.uk
------------------------------
Date: Wed, 06 Dec 2000 20:32:44 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Beginner's question
Message-Id: <90m7pc$rib$1@nnrp1.deja.com>
your next question will probably be "how do I test perl cgi scripts at
home?"
the answer is that you need a local webserver running on your PC to
handle the browser transactions. A real easy free one is at
www.xitami.com
D
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 06 Dec 2000 19:52:50 GMT
From: Nick <square-sun@terra.es>
Subject: Re: Beginner's question
Message-Id: <7l163EBuepL6EwcD@terra.es>
In article <90k6pi$e3i$1@pip.cs.utexas.edu>, Logan Shaw
<logan@cs.utexas.edu> writes
>In article <t2r5hb4k7rsp25@corp.supernews.com>,
>Randy Harris <harrisr@bignet.net> wrote:
>>Wolfgang Denk <wd@denx.muc.de> wrote in message
>>news:G549Cp.LG6.7.denx@denx.muc.de...
>>> Nick <square-sun@terra.es> writes:
>>> >Is it possible to get a Perl interpreter to run on a Win98 machine so
>>I
>>> >don't have to go online to test scripts?
>>>
>>> No, that's absolutely impossible.
>>
>>Of course he can get Perl for Win98. Why would you say that?
>
>Read the rest of the post where he says...
>
>>> You cannot run it on any system when it is not online.
>
>In other words, Mr. Denk was trying to point out the misuse of the
>terminology "on-line". "on-line" doesn't mean "connected to the
>Internet". It means "running" or "operational" or "available".
>
>Thus, not having "to go online to test scripts" means not having to
>cause some device to become operational in order to test scripts.
>
>That, of course, is not possible. You need a functioning computer to
>run Perl scripts.
>
> - Logan
"Online" to many non-professionals like myself means connected to the
net. I am obviously going to have to pick up the correct usage of these
terms if I frequent this newsgroup :-)
--
Nick
news@square-sun.co.uk
Chainsaw sculpture - Wooden books - Pictures
http://www.square-sun.co.uk
------------------------------
Date: 6 Dec 2000 15:54:08 -0600
From: MikeV <see_sig@msg.bottom>
Subject: Can't locate File/Spec.pm in @INC CPAN Dead?
Message-Id: <18558928.11b7b70@mycomputer>
>>> I did=20
[root@vanecek CPAN]# perl -MCPAN -e shell
cpan> install Errno
>>> which installed OK, but saw this message -
There's a new CPAN.pm version (v1.59) available!
You might want to try
install CPAN
reload cpan
without quitting the current session. It should be a seamless upgrade
while we are running...
>>> so I did=20
cpan> install CPAN
Running make for A/AN/ANDK/CPAN-1.59.tar.gz
=46etching with Net::FTP:
/usr/lib/perl5/CPAN/sources/authors/id/A/AN/ANDK/CPAN-1.59.tar.gz
CPAN-1.59/
CPAN-1.59/lib/
CPAN-1.59/lib/CPAN/
CPAN-1.59/lib/CPAN/Nox.pm
CPAN-1.59/lib/CPAN/Admin.pm
CPAN-1.59/lib/CPAN/FirstTime.pm
CPAN-1.59/lib/Bundle/
CPAN-1.59/lib/Bundle/CPAN.pm
CPAN-1.59/lib/CPAN.pm
CPAN-1.59/Todo
CPAN-1.59/ChangeLog
CPAN-1.59/t/
CPAN-1.59/t/loadme.t
CPAN-1.59/t/vcmp.t
CPAN-1.59/MANIFEST
CPAN-1.59/Makefile.PL
CPAN-1.59/cpan
CPAN-1.59/README
CPAN.pm: Going to build A/AN/ANDK/CPAN-1.59.tar.gz
Checking if your kit is complete...
Looks good
Warning: prerequisite File::Spec 0 not found at (eval 1) line 221.
Writing Makefile for CPAN
mkdir ./blib
mkdir ./blib/lib
mkdir ./blib/arch
mkdir ./blib/arch/auto
mkdir ./blib/arch/auto/CPAN
mkdir ./blib/lib/auto
mkdir ./blib/lib/auto/CPAN
mkdir ./blib/man3
cp lib/CPAN/FirstTime.pm ./blib/lib/CPAN/FirstTime.pm
cp lib/CPAN/Admin.pm ./blib/lib/CPAN/Admin.pm
cp lib/CPAN.pm ./blib/lib/./CPAN.pm
cp lib/Bundle/CPAN.pm ./blib/lib/Bundle/CPAN.pm
cp lib/CPAN/Nox.pm ./blib/lib/CPAN/Nox.pm
Manifying ./blib/man3/CPAN::FirstTime.3
Manifying ./blib/man3/CPAN.3
Manifying ./blib/man3/CPAN::Admin.3
/usr/bin/pod2man: bad option in paragraph 16 of lib/CPAN/Admin.pm: ``-e''
should be [CB]<-e>
Manifying ./blib/man3/Bundle::CPAN.3
Manifying ./blib/man3/CPAN::Nox.3
mkdir ./blib/script
cp cpan ./blib/script/cpan
/usr/bin/perl -I/usr/lib/perl5/mips-linux/5.00404 -I/usr/lib/perl5
-MExtUtils::MakeMaker -e "MY->fixin(shift)" ./blib/script/cpan
/usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=3D1 /usr/bin/perl -I./blib/arch -I./blib/lib
-I/usr/lib/perl5/mips-linux/5.00404 -I/usr/lib/perl5 -e 'use =
Test::Harness
qw(&runtests $verbose); $verbose=3D0; runtests @ARGV;' t/*.t
t/loadme............Can't locate File/Spec.pm in @INC (@INC contains:
./blib/arch ./blib/lib /usr/lib/perl5/mips-linux/5.00404
/usr/lib/perl5/mips-linux/5.00404 /usr/lib/perl5/mips-linux/5.00404
/usr/lib/perl5 /usr/lib/perl5/mips-linux/5.00404
/usr/lib/perl5/mips-linux/5.00404 /usr/lib/perl5
/usr/lib/perl5/site_perl/mips-linux /usr/lib/perl5/site_perl/mips-linux
/usr/lib/perl5/site_perl . /usr/lib/perl5/mips-linux/5.00404 =
/usr/lib/perl5
/usr/lib/perl5/site_perl/mips-linux /usr/lib/perl5/site_perl .) at
blib/lib/CPAN.pm line 25.
BEGIN failed--compilation aborted at blib/lib/CPAN.pm line 25.
BEGIN failed--compilation aborted at t/loadme.t line 7.
dubious
Test returned status 2 (wstat 512, 0x200)
DIED. FAILED test 1
Failed 1/1 tests, 0.00% okay
t/vcmp..............Can't locate File/Spec.pm in @INC (@INC contains:
./blib/arch ./blib/lib /usr/lib/perl5/mips-linux/5.00404
/usr/lib/perl5/mips-linux/5.00404 /usr/lib/perl5/mips-linux/5.00404
/usr/lib/perl5 /usr/lib/perl5/mips-linux/5.00404
/usr/lib/perl5/mips-linux/5.00404 /usr/lib/perl5
/usr/lib/perl5/site_perl/mips-linux /usr/lib/perl5/site_perl/mips-linux
/usr/lib/perl5/site_perl . /usr/lib/perl5/mips-linux/5.00404 =
/usr/lib/perl5
/usr/lib/perl5/site_perl/mips-linux /usr/lib/perl5/site_perl .) at
blib/lib/CPAN.pm line 25.
BEGIN failed--compilation aborted at blib/lib/CPAN.pm line 25.
BEGIN failed--compilation aborted at t/vcmp.t line 4.
dubious
Test returned status 2 (wstat 512, 0x200)
Undefined subroutine &Test::Harness::WCOREDUMP called at
/usr/lib/perl5/Test/Harness.pm line 222.
/usr/bin/make test -- OK
Running make install
Installing /usr/lib/perl5/./CPAN/FirstTime.pm
Installing /usr/lib/perl5/./CPAN/Admin.pm
Installing /usr/lib/perl5/./CPAN/Nox.pm
Installing /usr/lib/perl5/./CPAN.pm
Installing /usr/lib/perl5/./Bundle/CPAN.pm
Installing /usr/lib/perl5/man/man3/./CPAN::FirstTime.3
Installing /usr/lib/perl5/man/man3/./CPAN.3
Installing /usr/lib/perl5/man/man3/./CPAN::Admin.3
Installing /usr/lib/perl5/man/man3/./Bundle::CPAN.3
Installing /usr/lib/perl5/man/man3/./CPAN::Nox.3
Installing /usr/bin/./cpan
Writing /usr/lib/perl5/mips-linux/5.00404/auto/CPAN/.packlist
Appending installation info to =
/usr/lib/perl5/mips-linux/5.00404/perllocal.pod
/usr/bin/make install -- OK
cpan> reload cpan
Can't locate File/Spec.pm in @INC (@INC contains: /root/.cpan
/usr/lib/perl5/mips-linux/5.00404 /usr/lib/perl5
/usr/lib/perl5/site_perl/mips-linux /usr/lib/perl5/site_perl .) at (eval =
15)
line 25, <GEN31> chunk 1.
BEGIN failed--compilation aborted at (eval 15) line 25, <GEN31> chunk 1.
0 subroutines redefined
>>> Now I am getting this message when I do=20
[root@vanecek /root]# perl -MCPAN -e shell
Can't locate File/Spec.pm in @INC (@INC contains:
/usr/lib/perl5/mips-linux/5.00404 /usr/lib/perl5
/usr/lib/perl5/site_perl/mips-linux /usr/lib/perl5/site_perl .) at
/usr/lib/perl5/CPAN.pm line 25.
BEGIN failed--compilation aborted at /usr/lib/perl5/CPAN.pm line 25.
BEGIN failed--compilation aborted.
>>> Now any CPAN activity causes a problem.=20
What do I do now??
--=20
Mike V.
I do not list an e-mail address because I do not
want to receive spam. Thank you for posting your
reply in this group so all may read the response.
------------------------------
Date: Wed, 06 Dec 2000 15:06:24 +0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: changing file permissions with a perl command (not from unix promt!)
Message-Id: <90m69401k32@news1.newsguy.com>
[ posted and emailed ]
In article <BCMW5.42170$GU1.5569@news.siol.net>, "Bostjan Kocan"
<webmajster@fiver.si> wrote:
> Yes I upload them with my FTP software (BuletProofFTP).... but I need to
> change permissions of 200 files. I can't do that at once because they
> are in various directories and crawling from one to another and changing
> permissions one by one is a everyday pain.... I need to automate this
> process... Well I don't need to do it with perl but need to do it
> somehow...
>
If that is a viable option, it shouldn't be a "pain." Perl is not really
the best tool here... or at least not the most terse.
find . -type f | xargs chmod 666
will change all the regular files to 666 in and under the current
directory.
>> > Please don't give me 'perldoc -f chmod' because I don't have the
>> > telnet access to server and cannot execute that command but you can
>> > send me a
> copy
>> > of what that 'perldoc -f chmod' command returns after it's executed.
So you knew the Perl answer, but aren't willing to look into it? Others
have pointed out several places you can get the documentation, but if you
are going to program Perl, is there really a good reason you can't
install perl locally and have access to all of the documentation
yourself? Your newsreader claims to be Outlook Express, so perl exists
for the platform you are using for posting.
Cheers,
Jeff
------------------------------
Date: Wed, 06 Dec 2000 19:59:59 GMT
From: Ted <ted_graham@my-deja.com>
Subject: Re: Duplicate Unix's time program on Windows
Message-Id: <90m5ro$prk$1@nnrp1.deja.com>
Thanks all! I didn't want to use Time::HiRes as it might now be
available on the next platform where I use Perl. I'm a consultant and
I roam a fair bit. But since I can use time on Unix and I'll usually
be using ActiveState on Windows, this will work.
Thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 6 Dec 2000 15:31:44 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Duplicate Unix's time program on Windows
Message-Id: <slrn92t8hg.qf6.tadmc@magna.metronet.com>
Ted <ted_graham@my-deja.com> wrote:
>I didn't want to use Time::HiRes as it might now be
>available on the next platform where I use Perl.
You can probably install it wherever you need it though.
Perl FAQ, part 8:
"How do I keep my own module/library directory?"
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 6 Dec 2000 15:12:22 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Emailed answers (was Re: Problem with warn,next,if combinations)
Message-Id: <slrn92t7d6.qf6.tadmc@magna.metronet.com>
Warren L Dodge <warren.dodge@tektronix.com> wrote:
>Email is best for me as far as answers.
^^^^^^
Perhaps.
But this newsgroup is not for you. It is for us.
We don't serve you. We serve us. If, in the course of
serving ourselves, you happen to get your question
answered, that is just a happy coincidence. :-)
Answers posted here are available to the entire community.
Emailed answers are being withheld from the community.
Your request is rather too selfish.
(asking for a _copy_ via email is OK, but that isn't what you
asked, and you probably wouldn't get one anyway.
)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 06 Dec 2000 21:27:31 GMT
From: nodo70@my-deja.com
Subject: Re: find function
Message-Id: <90mavq$ubp$1@nnrp1.deja.com>
Please help. I haven't figure out how.
Thanks,
noDo
In article <90k15m$31d$1@nnrp1.deja.com>,
nodo70@my-deja.com wrote:
> Anyone know why it only find only one time and exit out of for loop
> base on snip code below? What I try to do is check what files missing
> from new folder compare to old folder (only certain folder like under
> fg folder name). Thanks.
>
> #!/usr/local/bin/perl -w
> use Cwd;
> use File::Find;
> $curDir = cwd();
> $oldDir = $ARGV[0];
> $newDir = $ARGV[1];
>
> opendir(DIR, "$oldDir") || die("Can't find $oldDir directory !!!");
> @files = readdir(DIR);
> closedir(DIR);
> chdir "$oldDir";
> foreach $subDir (sort @files) {
> undef @realFiles;
> if ( -d $subDir ) {
> if ( ! (($subDir =~ /^..$/i) or ($subDir=~ /^.$/i) )) {
> $nextDir .= $oldDir . "\/" . $subDir . '/fg';
> chdir "$nextDir";
> find(\&wanted,'.');
> foreach $file (@realFiles) {
> $newDirFile = $newDir . "\/" . $subDir . '/fg/' . $file;
> unless (-e $newDirFile) {
> print '.';
> push @deletedFiles, $file;
> }
> }
> next;
> }
> }
> }
>
> sub wanted {
> unless (-d $_) {
> $_ = $File::Find::name;
> s/^.\///; # get rid of leading "./"
> push @realFiles, $_;
> }
> }
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 6 Dec 2000 13:20:50 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Find::Find untaint_skip broken?
Message-Id: <90m732$c65@flatland.dimensional.com>
I recently posted this to comp.lang.perl.modules but haven't seen any
replies, so perhaps somebody here can tell me if I'm missing something
or if I've found a bug in File::Find.
I'm trying to run the following program (Perl 5.6.0, tested on several
operating systems):
#!/usr/bin/perl -Tw
use File::Find;
use strict;
BEGIN { $ENV{"PATH"} = "/bin:/usr/bin"; }
sub wanted { print "$File::Find::name\n"; }
find({wanted => \&wanted, untaint => 1, untaint_skip => 1}, ".");
When the script encounters a directory name that fails to match
File::Find's untaint_pattern (e.g., a subdirectory name that has a
space), it dies with the following message:
Insecure dependency in chdir while running with -T switch at
/usr/libdata/perl5/File/Find.pm line 449.
Based on the descriptions of untaint and untaint_skip in the File::Find
manual page, I'd expect the program to skip the bad directory name instead
of dying from the taint checking:
`untaint'
If find is used in taint-mode (-T command line switch
or if EUID != UID or if EGID != GID) then internally
directory names have to be untainted before they can be
cd'ed to. Therefore they are checked against a regular
expression untaint_pattern. Note, that all names passed
to the user's wanted() function are still tainted.
`untaint_skip'
If set, directories (subtrees) which fail the
untaint_pattern are skipped. The default is to 'die' in
such a case.
Here's the relevant section of code from Find.pm:
unless ($no_chdir or $dir_rel eq '.') {
my $udir= $dir_rel;
if ($untaint) {
$udir = $1 if $dir_rel =~ m|$untaint_pat|;
unless (defined $udir) {
if ($untaint_skip == 0) {
die "directory ("
. ($p_dir ne '/' ? $p_dir : '')
. "/) $dir_rel is still tainted";
}
}
}
unless (chdir $udir) { # <----- line 449, where the program dies
warn "Can't cd to ("
. ($p_dir ne '/' ? $p_dir : '')
. "/) $udir : $!\n";
next;
}
$CdLvl++;
}
Correct me if I'm wrong, but I see a couple of problems with this
code:
1. The following statement will set $udir to an untainted value if the
pattern matches, but it will leave $udir with its previously-set
tainted value if the pattern doesn't match:
$udir = $1 if $dir_rel =~ m|$untaint_pat|;
BTW, $untaint_pat defaults to qr|^([-+@\w./]+)$| so $1 comes from
anything that matches ([-+@\w./]+).
2. Even if $udir were set to an undefined value by the above statement
to indicate that $dir_rel failed the pattern match, there's no code to
skip it if $untaint_skip is true.
Am I missing something, or is this code broken?
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
------------------------------
Date: Wed, 06 Dec 2000 21:22:56 GMT
From: Kyle Parfrey <kyle@iol.ie>
Subject: For or while problem in iterating program.
Message-Id: <3A2EBC72.8373BDF6@iol.ie>
Hello there perl people.
I am trying to write a program that
1)takes a list of numbers , one number per line
2) for each number checks to see if it is less than a stated value.
counts the number of times it is less then the value, prints
the value and number of times the column numbers are less than it
3) adds 0.0001 to the value and starts the process again.
giving.
vaule1 count
value(1+0.0001) count
etc.
down an output file.
The script I wrote is below , but it doesn't work, I think there is a
conflict between the for statement and the inside while. I also tried
this with two while statements. All I get are values and 0's, even
though
the no's in the columns are all less then one of the values used.
Any help appreciated.
Kyle
#!/usr/bin/perl
use strict
print "Produces a distribution diagram for a time series.\n";
print "\n";
my $start;
my $end;
my $now;
$start = 0.7;
$end = 0.8;
$now = $start;
my $counter;
$counter = 0;
my $filename;
$filename = $ARGV[0];
my $newfile;
$newfile = $filename."_distrib";
my $false = 0;
my $true = 1;
print "$newfile is output file.\n";
open (READIN, "$filename");
open (WRITEOUT, ">$newfile");
for ($now , $now <= $end, $now = $now + 0.001) {
while (<READIN>) {
chomp($_);
if ($_ < $now) {
$counter = $counter + 1;
}
else {
}
}
print WRITEOUT "$now $counter\n";
$counter = 0;
}
close (READIN);
close (WRITEOUT);
------------------------------
Date: Wed, 06 Dec 2000 17:53:26 -0500
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: For or while problem in iterating program.
Message-Id: <3A2EC366.FD1419B@cc.gatech.edu>
Kyle Parfrey wrote:
> Hello there perl people.
> I am trying to write a program that
> 1)takes a list of numbers , one number per line
> 2) for each number checks to see if it is less than a stated value.
> counts the number of times it is less then the value, prints
> the value and number of times the column numbers are less than it
> 3) adds 0.0001 to the value and starts the process again.
> giving.
> vaule1 count
> value(1+0.0001) count
> etc.
> down an output file.
> The script I wrote is below , but it doesn't work, I think there is a
> conflict between the for statement and the inside while. I also tried
> this with two while statements. All I get are values and 0's, even
> though
> the no's in the columns are all less then one of the values used.
>
> Any help appreciated.
> Kyle
>
If I understand correctly, your code should, given a list of numbers,
display:
How many numbers are < 0.7 ,
how many numbers are <0.7001 ,
etc.
How many numbers are < 0.8
Assuming that, my comments are dispersed throughout your code below:
>
> #!/usr/bin/perl
>
Should be #!/user/bin/perl -w
>
> use strict
>
> print "Produces a distribution diagram for a time series.\n";
> print "\n";
>
> my $start;
> my $end;
> my $now;
> $start = 0.7;
> $end = 0.8;
> $now = $start;
> my $counter;
> $counter = 0;
>
> my $filename;
> $filename = $ARGV[0];
> my $newfile;
> $newfile = $filename."_distrib";
> my $false = 0;
> my $true = 1;
>
> print "$newfile is output file.\n";
>
> open (READIN, "$filename");
> open (WRITEOUT, ">$newfile");
>
For both of these, you should use:
open(FILEHANDLE,$filename) or die "Can't open $filename: $!";
You shouldn't continue of the file doesn't open properly.
>
> for ($now , $now <= $end, $now = $now + 0.001) {
>
Here is part of your problem. Use semicolons between statements, not
commas.
>
> while (<READIN>) {
> chomp($_);
>
> if ($_ < $now) {
> $counter = $counter + 1;
> }
> else {
> }
>
> }
> print WRITEOUT "$now $counter\n";
> $counter = 0;
> }
>
Here is your other problem. Using while(<READIN>) reads the file once,
but will not return to the beginning. Technically you can use seek to
restart, but if you're using the same file data multiple times, it would
be better to put them all in an array:
chomp(my @numbers = <READIN>);
(chomp in list context applies to all elements)
Then you could use foreach(@numbers) instead of the while statement.
>
> close (READIN);
> close (WRITEOUT);
BTW, you might want to use grep instead of manually iterating over the
array each time.
perldoc perlrun
perldoc perlsyn
perldoc perlop
perldoc -f grep
--
Stephen Kloder | "I say what it occurs to me to say.
stephenk@cc.gatech.edu | More I cannot say."
Phone 404-874-6584 | -- The Man in the Shack
ICQ #65153895 | be :- think.
------------------------------
Date: Wed, 06 Dec 2000 19:18:23 GMT
From: Kurt Oxen <peliknish@my-deja.com>
Subject: Getting multiple random lines
Message-Id: <90m3do$nha$1@nnrp1.deja.com>
Hi,
I’ve got a script that draws a random word from a list of words in
a .txt file (thanks to Godzilla!). Now I want to modify it so it
draws three words. Actually, I’ve done this, but in way that’s clearly
inefficient. So I’m hoping someone can clue me in to a more efficient
way. Here’s the script that gets one word:
#!/usr/bin/perl -w use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
#name of the directory and files I get the words from
@ARGV = map { "path/to/wordlist/" . $_ }
qw(wordlist.txt);
$/ = "\n"; #delimiter
### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $line;
#### see "perldoc -q 'random line'"
rand ($.) < 1 && ($line = $_) while (<>);
print "Content-type: text/html\n\n";
print "$line <br>";
###- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Substituting the following lame code between the dotted lines is the
only way I’ve gotten it to get three words:
my $line;
my $line2;
my $line3;
rand ($.) < 1 && ($line = $_) while (<>);
@ARGV = map { "$HOME/www/words/" . $_ }
qw(ospd.txt);
rand ($.) < 1 && ($line2 = $_) while (<>);
@ARGV = map { "$HOME/www/words/" . $_ }
qw(ospd.txt);
rand ($.) < 1 && ($line3 = $_) while (<>);
print "Content-type: text/html\n\n";
print "$line <br>";
print "$line2 <br>";
print "$line3 <br>";
There’s a better way to do this than re-initializing @ARGV twice,
right?
I guess I'm having trouble figuring this out because I don't really
understand the line...
rand ($.) < 1 && ($line = $_) while (<>);
If anyone would care to translate that line into english for me that
would be great.
Thanks,
kurt
---
figgs
figgs
http://www.beagleton.com/
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 6 Dec 2000 21:51:44 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Getting multiple random lines
Message-Id: <976131869.3482@itz.pp.sci.fi>
In article <90m3do$nha$1@nnrp1.deja.com>, Kurt Oxen wrote:
>
> rand ($.) < 1 && ($line = $_) while (<>);
>
>If anyone would care to translate that line into english for me that
>would be great.
It reads the file one line at a time. Each line will be stored in
$line with the probability of 1 out of the number of lines read so
far. So the first line will always be stored in $line, the second
will overwrite it 1/2 the times the routine is run, the third will
overwrite the previous value of $line 1 out of 3 times, and so on.
The algorithm can easily be adapted to pick $n random lines:
my @lines = (undef) x $n; # pre-extend array to desired length
while (<>) {
for my $line (@lines) {
$line = $_ if rand $. < 1;
}
}
Choosing $n _unique_ random lines in a similar way gets a bit more
challenging, however. Fortunately, we've just been discussing how
to get unique random integers, and the algorithms can be combined.
my @lines = (undef) x $n;
my $last;
while (<>) {
my $used = 0;
for my $i (0 .. $#lines) {
($last, $lines[$i]) = ($lines[$i], $used++ ? $last : $_)
if rand($.-$i) < 1;
}
}
Now that I've written it, I'm not totally sure if the distribution
produced really is uniform or not. As far as I can test, it seems
to be, but a rigorous proof would be nice. (Hey look, bricktext!)
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: Wed, 06 Dec 2000 21:04:20 GMT
From: WA Support
Subject: HASH OF LISTS - Question
Message-Id: <3a2ea217.2950352282@news.wildapache.net>
Hello,
If I define a hash of list, say like:
%HoL = (
flintstones => [ "fred", "barney" ],
jetsons => [ "george", "jane", "elroy" ],
simpsons => [ "homer", "marge", "bart" ],
);
I can print $HoL{flintstones}[0] and get "fred", so I know the hash is
loading.
How do I pass reference to the hash with an input statement?
I have tried:
print '<input type=hidden name=structures value="',$HoL'">';
but does not appear to work.
Also, once I do get the hash properly passed to the program that is
servicing the form, how do I pass the hash to a subroutine?
I have tried:
&parseform($HolL;
and delcare $HoL in sub parseform with:
($HoL) = shift;
but nothing is passing through.
Any help would be greatly appreciated!
Thanks,
Murrah Boswell
------------------------------
Date: Wed, 06 Dec 2000 19:06:31 GMT
From: spam@s.patterson.freeuk.com (Stephen Patterson)
Subject: Help - passing hash array into a subroutine
Message-Id: <X6wX5.23936$eT4.1564091@nnrp3.clara.net>
Is there a way to pass an entire hash array into a subroutine preserving the
indexing in the hash?
--
If Patrick Henry thought that taxation without representation was bad,
he should see how bad it is with representation.
-- -- -- -- -- -- -- -- -- --
Stephen Patterson s.patterson@SPAMOFFfreeuk.com (Remove SPAMOFF to reply)
------------------------------
Date: 6 Dec 2000 20:16:13 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Help - passing hash array into a subroutine
Message-Id: <slrn92t7kd.80s.abigail@tsathoggua.rlyeh.net>
On Wed, 06 Dec 2000 19:06:31 GMT, Stephen Patterson (spam@s.patterson.freeuk.com) wrote in comp.lang.perl.misc <URL: news:<X6wX5.23936$eT4.1564091@nnrp3.clara.net>>:
++ Is there a way to pass an entire hash array into a subroutine preserving the
++ indexing in the hash?
Yes. In the most obvious way.
Abigail
------------------------------
Date: Wed, 6 Dec 2000 15:01:51 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help - passing hash array into a subroutine
Message-Id: <slrn92t6pf.qf6.tadmc@magna.metronet.com>
Stephen Patterson <spam@s.patterson.freeuk.com> wrote:
>Is there a way to pass an entire hash array into a subroutine preserving the
>indexing in the hash?
Depends on what "indexing" means to you.
If it means "associations" then Abigail's followup will suffice,
since the second paragraph in perlsub.pod starts talking about
hashes as subroutine arguments.
How you could possibly have failed to look at the docs for
subroutines when you have a subroutine question is beyond
my understanding...
If, OTH, it means "hash ordering" then her followup may not
work. In which case you could pass a reference to the hash
instead.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 06 Dec 2000 22:41:10 GMT
From: rkasprow@my-deja.com
Subject: HELP: regexing html
Message-Id: <90mfa4$2d3$1@nnrp1.deja.com>
I am trying to code a regular expression to remove the following line
of code. It is verbatim and has a new line in there (not a typo). There
is not a space between color="#ffffff" & face="sans-serif.
<font color="#ffffff"
face="sans-serif, Arial, Helvetica" size="-2">
My regexes are:
$var_line =~ s/<font color=\"#ffffff\"[^<>]*?>/DELETED/sgi;
$var_line =~ s/<font[^<>]*?>/DELETED/gsi;
$var_line =~ s/<\/font>/DELETED/igs;
I cannot, for the life of me, get the regex to work. I have the feeling
that it's the newline causing the error.
The ultimate goal is to have a regex that CUTS all the <font> tags out
of a .html document, newline or not, leaving no font formatting.
Please supply a regex that can cut out the code.
HELP !!!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 5048
**************************************