[23251] in Perl-Users-Digest
Perl-Users Digest, Issue: 5472 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 9 18:05:51 2003
Date: Tue, 9 Sep 2003 15:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 9 Sep 2003 Volume: 10 Number: 5472
Today's topics:
Re: Counting files <jwillmore@cyberia.com>
Re: Counting files (Greg Bacon)
Re: Counting files <REMOVEsdnCAPS@comcast.net>
Re: dynamic access to multidimensional array <abigail@abigail.nl>
Re: dynamic access to multidimensional array <abigail@abigail.nl>
File locking for all my needs <mpapec@yahoo.com>
File locking, was Re: illegal seek <flavell@mail.cern.ch>
Re: How To activate command line history in debugger? <occitan@esperanto.org>
Re: illegal seek (Anno Siegel)
Re: Perl Arguements <kkeller-usenet@wombat.san-francisco.ca.us>
Re: Perl Arguements <bart.lateur@pandora.be>
Re: Perl vs TCL <REMOVEsdnCAPS@comcast.net>
Re: Perl vs TCL <bart.lateur@pandora.be>
Re: Perl vs TCL <abigail@abigail.nl>
Perl/IIS Permission Problem (Shane Freeman)
Re: Problem with simple contact script. (Tom)
Re: qr// question <mpapec@yahoo.com>
Re: qr// question <mpapec@yahoo.com>
Re: qr// question (Anno Siegel)
Re: qr// question <krahnj@acm.org>
Re: Text File Processing (Greg Carlill)
To relate a user list to a group..... (Jim Carter)
Re: To relate a user list to a group..... <mbudash@sonic.net>
Re: To relate a user list to a group..... <no@email.com>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 09 Sep 2003 18:55:37 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: Counting files
Message-Id: <20030909145541.0705af6b.jwillmore@cyberia.com>
On Tue, 09 Sep 2003 13:45:19 -0400
Shawn Corey <shawn@magma.ca> wrote:
> I have a list:
>
> file1
> file2
> dir1/file3
> dir1/file4
> dir1/subdir1/file5
> dir2/file6
> ...
>
> I want to count them like:
>
> $File{.}{file1} = count;
> $File{.}{file2} = count;
> $File{dir1}{file3} = count;
> $File{dir1}{file4} = count;
> $File{dir1}{subdir1}{file5} = count;
> $file{dir2}{file6} = count;
> ...
>
> Is the a nifty way of doing this in Perl-speak?
If you're just looking to count the entries in the list, you may want
to do ...
==untested==
my @list =
qw(file1 file2 dir1/file3 dir1/file4 dir1/subdir1/file5 dir2/file6 );
my $count = @list;
print "The number of file entries is: $count\n";
Is this what you were after?
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Trying to be happy is like trying to build a machine for which
the only specification is that it should run noiselessly.
------------------------------
Date: Tue, 09 Sep 2003 19:00:29 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Counting files
Message-Id: <vls8qd44iha8e2@corp.supernews.com>
In article <b9SdncIafYkfjMOiU-KYuQ@magma.ca>,
Shawn Corey <shawn@magma.ca> wrote:
: I have a list:
:
: file1
: file2
: dir1/file3
: dir1/file4
: dir1/subdir1/file5
: dir2/file6
: ...
:
: I want to count them like:
:
: $File{.}{file1} = count;
: $File{.}{file2} = count;
: $File{dir1}{file3} = count;
: $File{dir1}{file4} = count;
: $File{dir1}{subdir1}{file5} = count;
: $file{dir2}{file6} = count;
: ...
:
: Is the a nifty way of doing this in Perl-speak?
I don't know about nifty, but see below.
#! /usr/local/bin/perl
use strict;
use warnings;
use Data::Dumper;
use File::Find;
sub store {
my $file = shift;
my $count = shift;
return unless $file && @_;
my $hd = shift;
if (@_) {
$file->{$hd} ||= {};
store($file->{$hd}, $count, @_);
}
else {
$file->{$hd} = $$count++;
}
}
sub make_counter {
my $count = 0;
my %file;
my $sub = sub {
return unless -f;
store \%file, \$count, grep /./s,
split /\//, $File::Find::name;
};
(sub { %file }, $sub);
}
## main
die "Usage: $0 dir..\n" unless @ARGV;
my($file,$wanted) = make_counter;
find $wanted, @ARGV;
print Dumper $file->();
Hope this helps,
Greg
--
When in doubt, use brute force.
-- mjd, "Good Advice and Maxims for Programmers"
------------------------------
Date: Tue, 09 Sep 2003 15:42:46 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Counting files
Message-Id: <Xns93F1AA286528Dsdn.comcast@206.127.4.25>
Shawn Corey <shawn@magma.ca> wrote in news:b9SdncIafYkfjMOiU-KYuQ@magma.ca:
> Hi,
>
> I have a list:
>
> file1
> file2
> dir1/file3
> dir1/file4
> dir1/subdir1/file5
> dir2/file6
> ...
>
> I want to count them like:
>
> $File{.}{file1} = count;
> $File{.}{file2} = count;
> $File{dir1}{file3} = count;
> $File{dir1}{file4} = count;
> $File{dir1}{subdir1}{file5} = count;
> $file{dir2}{file6} = count;
This is "counting"?
--
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
------------------------------
Date: 09 Sep 2003 21:12:12 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: dynamic access to multidimensional array
Message-Id: <slrnblsghc.e97.abigail@alexandra.abigail.nl>
Brian McCauley (nobull@mail.com) wrote on MMMDCLXI September MCMXCIII in
<URL:news:u94qzlzzrm.fsf@wcl-l.bham.ac.uk>:
&& Abigail <abigail@abigail.nl> writes:
&&
&& > Brian McCauley (nobull@mail.com) wrote on MMMDCLXI September MCMXCIII in
&&
&& > `' sub index_AoA : lvalue {
&& > `' my $v = \shift;
&& > `' $v = \$$v->[$_] for @{shift()};
&& > `' $$v;
&& > `' }
&&
&& > Eck. Why so difficult? 'eval' makes it very easy:
&& >
&& > my $elem = do {local $" = "]["; eval "\$AoA [@ind]"};
&& > die $@ if $@;
&&
&& Thankyou! I'm planning to do a talk at YAPC::Europe::2004 about some
&& of the issues surrounding the good the bad and the ugly uses of
&& eval-string.
&&
&& I needed some good non-trivial examples where a simple eval solution
&& exists to a problem and were it looks amazingly elegant at one level
&& but is actually aborrently ugly to an experienced programmer.
I guess I'm not an experienced programmer then.
&& BTW: You should have put some smileys in there. Some people may have
&& actually thought you were serious. I trust you _were_ joking.
I wasn't. Being able to do stuff like this is what makes Perl Perl.
I really hate dogma's like "you can't use string eval". Restricting
yourself to part of the language is something for the FWP mailinglist,
but a serious programmer should use the full power of the language.
And the whining "but if @ind comes from the outside, it's dangerous"
gets old fast. 'unlink $file' is dangerous if $foo comes from the outside
as well, but that's no reason to not use unlink. I'm fully aware that if
you run on behalve of some other user (suid, CGI, etc) there are issues -
issues that go much further than string eval. But the vast majority of
the programs I write runs under the same UID as the user invoking it. If
the user wants to screw himself, he doesn't need my programs to do so.
Abigail
--
INIT {print "Perl " }
END {print "Hacker\n"}
CHECK {print "another "}
BEGIN {print "Just " }
------------------------------
Date: 09 Sep 2003 21:14:12 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: dynamic access to multidimensional array
Message-Id: <slrnblsgl4.e97.abigail@alexandra.abigail.nl>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMDCLXI
September MCMXCIII in <URL:news:bjku0b$hfm$1@mamenchi.zrz.TU-Berlin.DE>:
[]
[] That aside, the solution is cute, but it looks like cheating. From one
[] point of view, it isn't a solution at all. It doesn't solve the problem
[] of multi-level indexing but uses the solution built into the Perl interprete
[] Thus, it gives no insight into the problem.
That's like saying that using a regex to find something in a string
is cheating, as it uses a solution build into the language, and it
doesn't give insight into the problem.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'
------------------------------
Date: Tue, 09 Sep 2003 23:38:40 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: File locking for all my needs
Message-Id: <42islvscnt9m7uraqstiehvls1fl7fuukb@4ax.com>
I thought this could be usefull to someone but before you use it bear in
mind its limitations,
- probably works as expected only on Linux and other *nix like systems
- only convenient for text files
- handling very large files is not efficient
- if it isn't there, file gets created (this is a feature actually)
- ?
Function can be used in two ways, I generally use second for log files and
first for all other purposes..
#1) managing whole file at once
my @txt;
my $fh = OpenLock('/tmp/testing.txt', \@txt);
print $fh "top line\n", @txt;
close $fh;
#2) append lines to file
my $fh = OpenLock('/tmp/testing.txt');
print $fh "bottom line\n";
close $fh;
sub OpenLock {
###############################################################
#
# open rw, flock, fill @$ra, truncate file to zero, return FH
#
###############################################################
my($file, $ra) = @_;
local *FH;
open FH, "+>>$file" or die $!;
flock(FH, 2); #exclusive_lock
if ($ra) {
seek(FH, 0, 0);
@$ra = <FH>;
seek(FH, 0, 0);
truncate(FH, 0);
}
return(*FH);
}
--
Matija
------------------------------
Date: Tue, 9 Sep 2003 19:40:37 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: File locking, was Re: illegal seek
Message-Id: <Pine.LNX.4.53.0309091919240.5973@lxplus015.cern.ch>
On Tue, Sep 9, news@roaima.freeserve.co.uk inscribed on the eternal scroll:
> Hmm (puts thinking hat on). What about this (with dies omitted):
>
> open (F, "<+ somefile");
> flock F, LOCK_SH;
> # Do lots of reads
>
> flock F, LOCK_EX;
> seek F, END_OF_FILE; # Can't remember symbolic offhand
[...]
First off, it seems one can't actually do that. I don't see it
clearly ruled out in the Perl documentation, and I can't testify to it
from any personal knowledge of the internals, but if I try a man page
for flock (i.e the underlying OS implementation) it says:
A single file may not simultaneously have both shared and
exclusive locks.
So, on *that* rather popular unix-ish OS, which also claims
conformance to BSD, you'd have to let-go the shared lock before you
could get the exclusive lock, thus blowing the scheme out of the
water.
Secondly: even if it _was_ feasible, I believe there's a very high
risk of creating a deadlock situation if two simultaneous processes
apply the proposed technique. Looks to me as if it would need a
back-off strategy in most practical situations - just possibly if
you're certain that although there can be many readers there will only
ever be one read/writer at a time, the plan might work - but in view
of the problem with flock itself, I think you'd need an alternative
mechanism, maybe based on semaphore file(s)(?)
But I certainly could be wrong, I can assure you that I've made
mistakes with locking before :-}
------------------------------
Date: Tue, 9 Sep 2003 21:28:47 +0200
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: Re: How To activate command line history in debugger?
Message-Id: <20030909212847.16892c99.occitan@esperanto.org>
Saluton, Moin,
Kurt Kronschnabl <kurt.kronschnabl-nospam@ica-intercom-akademie.de> skribis:
> Daniel Pfeiffer schrieb:
> > Versuch's stattdessen mit Emacs M-x shell (M- hei=DFt normalerweise Alt=
-Taste). Das gibt Dir eine Art Terminal in einem Emacs Puffer. Wenn Du au=
f der letzten Zeile nach dem Prompt Return, M-p oder M-n benutzt ist das, d=
as was Du brauchst. Du hast aber auch die ganze Interaktion im Puffer, und=
kannst von dort Befehle nochmal abschicken oder das ganze sogar editieren =
:-)
>=20
> Sounds good, but please give me a hint how to activate this? Do I need=20
> to create a .perldb file?
M-x shell
$ perl -d /tmp/randloop
Loading DB routines from perl5db.pl version 1.19
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(/tmp/randloop:3): while( sleep 1 ) {
DB<1> s
main::(/tmp/randloop:4): print ':', rand(), "\n";
DB<1> s
:0.530385083825426
main::(/tmp/randloop:3): while( sleep 1 ) {
DB<1> s
main::(/tmp/randloop:4): print ':', rand(), "\n";
DB<1> s
:0.668097208810167
main::(/tmp/randloop:3): while( sleep 1 ) {
DB<1> q
$=20
(with highlighting for the prompts :-) When you hit Return at the end of b=
uffer, everything after the prompt gets sent. On Return elsewhere, the com=
mand on that line first gets copied to the end.
coralament / best Gr=F6tens / liebe Gr=FC=DFe / best regards / elkorajn sal=
utojn
Daniel Pfeiffer
-- GPL 3: take the wind out of Palladium's sails! --
------
-- My other stuff here too, make.pl, sawfish...: --
------
-- http://dapfy.bei.t-online.de/ --
------------------------------
Date: 9 Sep 2003 18:15:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: illegal seek
Message-Id: <bjl5cl$m2o$1@mamenchi.zrz.TU-Berlin.DE>
Vlad Tepes <minceme@start.no> wrote in comp.lang.perl.misc:
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>
> ...
>
> > But, as you say, it can't be done. To get a write lock, you'd
> > have to give up the read lock, which means someone else can change the
> > file before you do. End of story, until an OS gives us LOCK_UPGD.
>
> Are you sure about this? I've tried Chris's idea. It seems to be
> possible to upgrade the lock from LOCK_SH to LOCK_EX without unlocking
> first, but I could be missing something.
>
> Here are the two scripts I tried, followed by output from a small
> command line session:
>
> lockupgrade.pl:
>
> #!/usr/bin/perl -w
>
> use strict;
> use Fcntl qw( :flock :seek );
> $|++;
>
> open F, "+<", "lock.txt" or die "$0 open : $!";
> print "\n$0: waiting for shared lock...";
> flock F, LOCK_SH or die "$0 flocksh : $!";
> print "\n$0: got shared lock\n";
> sleep 10;
>
> print "$0: waiting for exclusive lock...\n";
> flock F, LOCK_EX or die "$0 flockex: $!";
> print "$0: got exclusive lock!\n";
> seek F, SEEK_END, 2 or die "$0 seekend: $!";
> print F "\nwritten by $0 at @{[ scalar localtime ]}\n";
> flock F, LOCK_UN or die "$0 cannot unlock: $!";
> close F or die "$0 closeex: $!";
>
> __END__
[mode code snipped]
This looks like an upgrade, and it is even called an upgrade in the
flock man page, but it isn't an upgrade in the sense that the process
seamlessly keeps a lock on the file:
A shared lock may be upgraded to an exclusive lock, and vice versa, sim-
ply by specifying the appropriate lock type; this results in the previous
lock being released and the new lock applied (possibly after other pro-
cesses have gained and released the lock).
Still end of story, no LOCK_UPGD yet.
Anno
------------------------------
Date: Tue, 9 Sep 2003 12:55:38 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Perl Arguements
Message-Id: <q7bljb.mam.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message
On 2003-09-09, Paul <pecymanski@yahoo.com> wrote:
>
> I am running this on Win 2k, the Perl is Active State 5.2.2.0.
Might adding a
use warnings;
statement be helpful?
--keith
--
kkeller-mmmspam@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAj9eMDgACgkQhVcNCxZ5ID+TiQCggO79bh0IHToJzqK+hVeGEJqh
xTYAnR1aRHuErPZ3lYTdy2an9KNqxlPA
=1eLw
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 09 Sep 2003 20:11:39 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl Arguements
Message-Id: <hvcslvgq77gb26i4c40m6ljeda92dldaf0@4ax.com>
Michael P. Broida wrote:
> We had problems on an older project under Solaris when
> one person decided to use "tcsh" instead of our "standard"
> csh. Some of his scripts didn't work correctly for the
> rest of us or for our customers. :)
That's what the shebang line is for.
--
Bart.
------------------------------
Date: Tue, 09 Sep 2003 15:38:16 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Perl vs TCL
Message-Id: <Xns93F1A965361Bsdn.comcast@206.127.4.25>
James Willmore <jwillmore@cyberia.com> wrote in
news:20030909123749.0cfa013b.jwillmore@cyberia.com:
>
> Each language has its strengths and its weaknesses.
>
What are Befunge's strengths? ;-)
--
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
------------------------------
Date: Tue, 09 Sep 2003 20:57:58 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl vs TCL
Message-Id: <h1fslv4ocpcgp2pm5bpkb32kfedrti0ggr@4ax.com>
Selwyn Leeke wrote:
>I'm thinking about writing a script in either Perl or TCL, but before
>I start, I thought it would be a good idea to find out how they
>compare to each other, so I can decide which is best for me.
I know only Perl well enough, and I must say, it wouldn't let me down
for the task you're thinking of.
My advice: check out some introductory text with some sample code for
each language, and see how comfortable it makes*you* feel. For example
DDJ (<http://ddj.com>) sometimes has special issues with nothing but
introductions on new languages, the guide on "alternative programming
languages".
<http://www.ddj.com/topics/altlang/>
Ooh I got it. Here:
<http://www.ddj.com/articles/1994/9415/>
Hmm... I have that issue lying around the house here somewhere...
Note that these texts are quite old. The perl described is still perl4
(perl5 has now been in use for close to 8 years), and AFAIK TCL now does
proper compilation too. I doubt if the article already describes that
aspect.
--
Bart.
------------------------------
Date: 09 Sep 2003 21:16:45 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Perl vs TCL
Message-Id: <slrnblsgpt.e97.abigail@alexandra.abigail.nl>
Eric J. Roode (REMOVEsdnCAPS@comcast.net) wrote on MMMDCLXI September
MCMXCIII in <URL:news:Xns93F1A965361Bsdn.comcast@206.127.4.25>:
`` James Willmore <jwillmore@cyberia.com> wrote in
`` news:20030909123749.0cfa013b.jwillmore@cyberia.com:
``
`` >
`` > Each language has its strengths and its weaknesses.
`` >
``
`` What are Befunge's strengths? ;-)
It's terse and small.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'
------------------------------
Date: 9 Sep 2003 14:46:29 -0700
From: freemans@intellicominc.com (Shane Freeman)
Subject: Perl/IIS Permission Problem
Message-Id: <9fa60f28.0309091346.1e74343c@posting.google.com>
I am having a horrible time getting the permissions set correctly
using ActivePerl and IIS 5.0. Any help would be greatly appreciated!
I currently have a site set up that has a test.cgi and a test.pl file
in the root directly. Both of them work just fine. This root
directory is accessible by anonymous internet acccount.
Inside of the root directory I have a CMS folder that contains the
same test.cgi and test.pl files. I have removed the anonymous user
account from having permission to the CMS and all sub-folders and
added another user that requires a login. When I browse to either of
these two files it prompts me for a userID and password (working
correctly). When I try and run test.pl it work correctly. When I try
to run test.cgi I receive the following error.
---
CGI Error
The specified CGI application misbehaved by not returning a complete
set of HTTP headers. The headers it did return are:
Can't open perl script "c:\websites\www.mysite.com\cms\test.cgi":
Permission denied
---
Can anybody shed any light on this problem?
Thanks in advance,
Shane
------------------------------
Date: 9 Sep 2003 11:06:13 -0700
From: tom@ztml.com (Tom)
Subject: Re: Problem with simple contact script.
Message-Id: <59b4279a.0309091006.6b135093@posting.google.com>
"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message news:<Pine.LNX.4.53.0309091121000.5973@lxplus015.cern.ch>...
> On Tue, Sep 8, Tom inscribed on the eternal scroll:
>
> > All right, one more time...
>
> With respect, this doesn't seem to be a productive line of
> development...
>
> > If this does not meet your approval, next stop... PERL 101 :(
>
> Oh no: you clearly have the ability to string Perl syntax together.
> You just don't seem to have the mindset to do it defensively enough
> for producing battle-hardened solutions. No shame in that, but there
> /are/ ready-made, tested and peer-reviewed solutions available.
>
> Staggering along from draft to draft fixing faults one at a time (and
> apparently ignoring other constructive comments that have been
> provided on the thread) just isn't going to lead to a quality
> solution. You _would_ have to choose one of the most notorious
> CGI-type applications for what appears to be more-or-less your debut
> here, which is a pity.
>
> Sorry to be so negative, but in real-world terms you really should go
> back to the drawing-board with this, rather than fiddling with a
> statement here, a statement there. On the other hand, if it was just
> a lab experiment, not intended for real-world deployment, there might
> be some useful discussion points, but the readers need to be clearly
> aware that they're not getting something that it would be safe to
> expose on their own web site.
>
> all the best
OK, for the last time...
#!/usr/bin/perl -wT
use strict;
use CGI::Carp 'fatalsToBrowser';
use CGI::ContactForm;
use CGI qw(:standard);
my %towhoms = (
loanofficer => 'loanofficer@mortgage-pros.com',
marketing => 'marketing@mortgage-pros.com',
broker => 'broker@mortgage-pros.com',
);
my $towhom = param("towhom");
if(!$towhom) { $towhom = "loanofficer" }
my $safe_towhom = $towhoms{$towhom};
contactform (
recname => $towhom,
recmail => $safe_towhom,
smtp => 'smtp.domain.com', # change me
formtmplpath => 'ContactForm_form.tmpl',
title => 'Contact PWC',
msglabel=> 'Please type in any comments or questions here:',
);
# $Id: contact.pl,v 1.4 2003/04/04 21:31:28 Gunnar Hjalmarsson Exp $
-----------------------------------------
ContactForm_form.tmpl:
<html>
<head>
<!-- LINKEXCHANGE CODE -->
<title><TMPL_VAR TITLE></title>
</head>
<body>
<hr size=5 width=90%>
<table width="55%" align="center"><tr><td align="center">
This form will email your question or comments to your selected
party.
</td></tr></table>
</center>
<p><p>
<hr size=5 width=90%>
<form action="<TMPL_VAR SCRIPTNAME>" method="post">
<center><table>
<tr>
<TD align="right">Please select to whom this email is to be
sent:</TD>
<TD><input type="radio" name="towhom" value="loanofficer"
checked="checked" />Loan Officer
<input type="radio" name="towhom" value="marketing" />Marketing
<input type="radio" name="towhom" value="broker" />Broker
</td></tr></table>
<table cellpadding="3">
<td><p<TMPL_VAR NAMEERROR>><TMPL_VAR NAMELABEL></p></td><td><input
type="text" name="name"
value="<TMPL_VAR NAME>" size="20" /> </td>
<td><p<TMPL_VAR EMAILERROR>><TMPL_VAR EMAILLABEL></p></td><td><input
type="text" name="email"
value="<TMPL_VAR EMAIL>" size="20" /></td>
</tr><tr>
<td><p<TMPL_VAR SUBJECTERROR>><TMPL_VAR SUBJECTLABEL></p></td>
<td colspan="3"><input type="text" name="subject" value="<TMPL_VAR
SUBJECT>" size="55" /></td>
</tr><tr>
<td colspan="4"><p<TMPL_VAR MESSAGEERROR>><TMPL_VAR MSGLABEL></p></td>
</tr><tr>
<td colspan="4">
<textarea name="message" rows="8" cols="65" <TMPL_VAR
SOFTWRAP>><TMPL_VAR MESSAGE></textarea>
</td>
</tr><tr>
<td colspan="4" class="halign">
<TMPL_VAR ERRORALERT>
<input class="button" type="reset" value="<TMPL_VAR RESET>"
/>
<input class="button" type="submit" value="<TMPL_VAR SEND>" /></td>
</tr><tr>
<td colspan="4"><p class="returnlink"><a href="<TMPL_VAR
RETURNLINKURL>">
<TMPL_VAR RETURNLINKTEXT></a></p></td>
</tr>
</table>
</form>
<!--REAL ESTATE PROS SEARCH AWARD CODE... -->
</body>
</html>
-----------------------------------------------------
Please note:
my $o = new CGI(\*STDIN); # in ContactForm.pm was changed to
my $o = new CGI(); # since method post is used in the input form.
Tom
ztml.com
------------------------------
Date: Tue, 09 Sep 2003 20:05:18 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: qr// question
Message-Id: <l65slv0goghbcien4g8s4fqo5aqt70f7e7@4ax.com>
X-Ftn-To: Anno Siegel
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>> >Strings will successively be turned into regexes on first use.
>>
>> Tnx, so ref knows all about them! :) Unfortunately perldoc isn't so
>> informative. :!
>
>You can think of qr/.../ values as objects of class Regexp, which has
Ah, so "Regexp" isn't actually builtin type so perldoc isn't mentioning it..
>stringification overloaded.
That makes sense.
>That describes most of their behavior, though
>things aren't really that simple.
>
> perl -Moverload -le'print "yup" if overload::Overloaded( qr//)'
>
>prints nothing.
Obviously consistency is hard thing to achieve.
--
Matija
------------------------------
Date: Tue, 09 Sep 2003 20:09:36 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: qr// question
Message-Id: <cm5slvkm8vrseoh0ohotnrqptge6j7ok6q@4ax.com>
X-Ftn-To: Sam Holden
sholden@flexal.cs.usyd.edu.au (Sam Holden) wrote:
>my %regexes;
>sub to_regex {
> $regexes{$_[0]} = qr/$_[0]/ unless exists $regexes{$_[0]};
> return $regexes{$_[0]};
>}
>
>And then when you want to match use
>
>$re = to_regex($string_of_regex);
>
>to get the regex for that string.
>
>Or with an array (or hash with tr/[]/{}/ ) of regexes you could do:
>
>$arr[$index] = qr/$arr[$index]/ unless ref $arr[$index];
>
>Before using $arr[$index] as a regex.
Tnx, last one looks most promising as it doesn't use any additional
variables.
--
Matija
------------------------------
Date: 9 Sep 2003 18:22:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: qr// question
Message-Id: <bjl5oa$m2o$2@mamenchi.zrz.TU-Berlin.DE>
Matija Papec <mpapec@yahoo.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
[qr// values]
> >That describes most of their behavior, though
> >things aren't really that simple.
> >
> > perl -Moverload -le'print "yup" if overload::Overloaded( qr//)'
> >
> >prints nothing.
>
> Obviously consistency is hard thing to achieve.
"Perl does what you want, unless you want consistency"
Anno
------------------------------
Date: Tue, 09 Sep 2003 20:17:40 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: qr// question
Message-Id: <3F5E3564.2954DEDD@acm.org>
Anno Siegel wrote:
>
> Matija Papec <mpapec@yahoo.com> wrote in comp.lang.perl.misc:
> >
> > Obviously consistency is hard thing to achieve.
>
> "Perl does what you want, unless you want consistency"
Can I quote you on that? :-)
John
--
use Perl;
program
fulfillment
------------------------------
Date: 9 Sep 2003 13:58:16 -0700
From: gregcarlill@energex.com.au (Greg Carlill)
Subject: Re: Text File Processing
Message-Id: <7a78a207.0309091258.8115f6@posting.google.com>
Hi All,
Just a quick note of thanks. I've used one of the methods suggested
here and it's working fine.
Thanks again
Greg
------------------------------
Date: 9 Sep 2003 13:50:55 -0700
From: carterave@yahoo.com (Jim Carter)
Subject: To relate a user list to a group.....
Message-Id: <9c2a26b6.0309091250.770378b3@posting.google.com>
Hi there,
I am working on windows. I have a file (names.txt) with below names:
---------------
john
jerry
bob
rob
mike
rich
sara
lisa
anita
rita
--------------
I have a list of groups in another file (groups.txt) with below entrees:
--------
Games
Books
Tour
Fun
---------
These two files can grow bigger in future.
OUTPUT:
------------------------------------
when run the perl script, foo.pl
C:\> foo.pl
It should give me
Games contains 3 people.
They are: 1. rich
2. sara
3. lisa
Books contain NONE. ### becuase no one belongs to this group.
Tour contains 4 people.
They are: 1. john
2. jerry
3. bob
4. rob
Fun contains 2 people.
They are: 1. anita
2. rita
------------------------------
I know that I should use hashes and arrays, but I a mstruggling with the code.
Can some one help me out?
Thanks,
Srini
------------------------------
Date: Tue, 09 Sep 2003 21:01:56 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: To relate a user list to a group.....
Message-Id: <mbudash-08A4F2.14015609092003@typhoon.sonic.net>
In article <9c2a26b6.0309091250.770378b3@posting.google.com>,
carterave@yahoo.com (Jim Carter) wrote:
> Hi there,
>
> I am working on windows. I have a file (names.txt) with below names:
>
> ---------------
> john
> jerry
> bob
> rob
> mike
> rich
> sara
> lisa
> anita
> rita
> --------------
>
> I have a list of groups in another file (groups.txt) with below entrees:
>
> --------
> Games
> Books
> Tour
> Fun
> ---------
>
> These two files can grow bigger in future.
>
>
> OUTPUT:
> ------------------------------------
> when run the perl script, foo.pl
> C:\> foo.pl
>
> It should give me
>
> Games contains 3 people.
> They are: 1. rich
> 2. sara
> 3. lisa
>
> Books contain NONE. ### becuase no one belongs to this group.
>
> Tour contains 4 people.
> They are: 1. john
> 2. jerry
> 3. bob
> 4. rob
>
> Fun contains 2 people.
> They are: 1. anita
> 2. rita
>
> ------------------------------
>
> I know that I should use hashes and arrays, but I a mstruggling with the code.
>
> Can some one help me out?
>
> Thanks,
> Srini
where is the file that says which group each name is in?
--
Michael Budash
------------------------------
Date: Tue, 9 Sep 2003 22:07:28 +0100
From: "Brian Wakem" <no@email.com>
Subject: Re: To relate a user list to a group.....
Message-Id: <bjlfeg$kqgvr$1@ID-112158.news.uni-berlin.de>
"Jim Carter" <carterave@yahoo.com> wrote in message
news:9c2a26b6.0309091250.770378b3@posting.google.com...
> Hi there,
>
> I am working on windows. I have a file (names.txt) with below names:
>
> ---------------
> john
> jerry
> bob
> rob
> mike
> rich
> sara
> lisa
> anita
> rita
> --------------
>
> I have a list of groups in another file (groups.txt) with below entrees:
>
> --------
> Games
> Books
> Tour
> Fun
> ---------
>
> These two files can grow bigger in future.
>
>
> OUTPUT:
> ------------------------------------
> when run the perl script, foo.pl
> C:\> foo.pl
>
> It should give me
>
> Games contains 3 people.
> They are: 1. rich
> 2. sara
> 3. lisa
>
> Books contain NONE. ### becuase no one belongs to this group.
>
> Tour contains 4 people.
> They are: 1. john
> 2. jerry
> 3. bob
> 4. rob
>
> Fun contains 2 people.
> They are: 1. anita
> 2. rita
The two files have no relation to each other (that you have told us) so how
does the script determine that theses groups contain the specified people?
>
> I know that I should use hashes and arrays, but I a mstruggling with the
code.
Clarify the question/problem and post the code you are struggling with.
> Can some one help me out?
>
> Thanks,
> Srini
--
Brian Wakem
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
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 V10 Issue 5472
***************************************