[7538] in Perl-Users-Digest
Perl-Users Digest, Issue: 1164 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 13 03:37:42 1997
Date: Sun, 12 Oct 97 19:14:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 12 Oct 1997 Volume: 8 Number: 1164
Today's topics:
Can someone look at this and tell me why it doesn't wor franklin@nospamingideas4you.com
Re: exp1 ? exp2 : exp 3 -- whats wrong? <bholzman@mail.earthlink.net>
Re: exp1 ? exp2 : exp 3 -- whats wrong? <ajohnson@gpu.srv.ualberta.ca>
Re: Getting File Information Quickly (Tad McClellan)
Re: How can I use perl to communicate with rstatd? (Jeremy D. Zawodny)
How does "die" work? <yingxue@ee.tamu.edu>
How to do hashes in CGI.pm - help needed please! <Rosie@dozyrosy.demon.co.uk>
howto: implement a mailing list? (Lam_Sai_Tung)
Re: Include gif without <image src= <sawyer@ibm.net>
Re: need tricky regex reljr@sigg.com
Perl Info! <tlowney@gonzaga.edu>
Re: Perl Info! (Jeremy D. Zawodny)
Re: Problem with unix command <bholzman@mail.earthlink.net>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 12 Oct 97 20:45:31 -0400
From: franklin@nospamingideas4you.com
Subject: Can someone look at this and tell me why it doesn't work!!
Message-Id: <3441705f$1$senaxyva$mr2ice@news.alltel.net>
foreach $CheckLog (@CheckLog) {
($PassFileName, $PassFile, $UserMaxLowDir) =
split(/:/,$CheckLog);
if ($PassFileName == $LogValue) {
if ($PassFile==$PassValue) {
$Logged=1;
$BaseDir = $UserMaxLowDir;
}
}
}
The two if statements don't work. it just passes through them like it's
not like thier not even there. --
-----------------------------------------------------------
Coming Soon,
"Discussion Groups" the power of the news groups packed into the manageablity of a mail list.
Virtual Computer Shopper
VCS Manager: Franklin Smith
E-Mail Address: franklin@ideas4you.com
Web Site: http://www.ideas4you.com/vcs
Ideas Unlimited Consulting
http://www.ideas4you.com
We do custom REXX and Paradox programming, Web Site Construction and Management, and Computer Hardware and Software Sales and Service.
Books Unlimited
BU Mangaer: Jim Smith
E-Mail Address: jimsmith@ideas4you.com
http://www.ideas4you.com/bu
-----------------------------------------------------------
------------------------------
Date: Sun, 12 Oct 1997 21:03:13 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
Subject: Re: exp1 ? exp2 : exp 3 -- whats wrong?
Message-Id: <34417351.54148C83@mail.earthlink.net>
Tushar Samant wrote:
>
> Surprised? It parses as
>
> (1? $a="a" : $b) = "b";
>
> and the left hand side happens to be asignable, and assigning
> to it assigns to $a.
>
> There's no "explanation" for why this works this way and your
> other expression works "right". The only answer is: that's how
> they get parsed.
Duh. Thanks for pointing that out-- I can't believe I didn't think
about how it would parse...
Benjamin Holzman
------------------------------
Date: Sun, 12 Oct 1997 20:24:44 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: exp1 ? exp2 : exp 3 -- whats wrong?
Message-Id: <3441866C.351AFDD5@gpu.srv.ualberta.ca>
Benjamin Holzman wrote:
>
> [posted & mailed]
>
> Janning Vygen wrote:
> >
[snip]
> >
> > # second condition
> > $flag==1 ? $color="blue" :
> > $color="red"; # output
> > should be "2:blue" but it is "2: red" !!!!!!!
> > print "2: $color \n";
[snip]
>
> I didn't believe this until I tried it, but it looks like this is a bug,
> at least in perl 5.003_07 for Win32 Build 306. Although the right-hand
> side of a (?:) expression isn't supposed to be evaluated if the
> condition is false, I'm guessing the optimizer is getting in the way
I think the explanation is as follows:
the ?: is right associative and of slightly higher precendence
than = so it gets parsed as
($flag==1?$color='blue':$color)='red';
and this assigns 'red' to $color because the ?: operator can
be assignable as in:
$flag?$a:$b = 'red';
assigns 'red' to $a if $flag else assigns 'red' to $b
so the original condition 2 above should be written as
$flag==1?($color='blue'):($color='red');
or more simply as Benjamin points out:
$color=$flag?'blue':'red';
regards
andrew
------------------------------
Date: Sun, 12 Oct 1997 15:36:29 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Getting File Information Quickly
Message-Id: <dccr16.9f2.ln@localhost>
franklin@nospamingideas4you.com wrote:
: What I need quick access
: to is file size,
$size = -s 'filename';
: if it's a directory or not, etc...
print "it is a directory\n" if -d 'filename';
: stat() function but the problem is the only thing I can see in that
: information that may tell me wether or not it's a directory is $nlink.
nlink has nothing to do with the type of file.
mode does though, just like the perlfunc man page says.
[
big sig.
Sheesh. Sheesh. Sheesh.
]
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 12 Oct 1997 23:48:40 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: How can I use perl to communicate with rstatd?
Message-Id: <34416161.24528339@woody.wcnet.org>
[original author automagically cc'd via e-mail]
On Sun, 12 Oct 1997 01:24:46 -0400, Ed Finch <efinch@vais.net> wrote:
>I would like to write a perl script to query/interact with the rstatd
>daemon on a remote system. I've searched the man pages, etc. but am
>unable to find any detailed information. How can this be done? Are there
>existing scripts? Archives/man pages/etc. of the information I need?
Unfortunately, I don't have *the* solution in hand, but about two
years ago, I asked the same question. Someone mailed me a script that
did the job (on SunOS 4.1.3_U1 at the time) quite nicely. I'm sure I
don't have it anymore, but it was less than a page long and just had
to speak UDP and do a little bit of pack()/unpack() and sprintf() to
format the data correctly.
Don't know if that's much of a help, but hey...
Jeremy
--
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>
"That's an example of how Perl can bring school yard cruelty to new heights."
-- Jon Orwant at the 1st Annual Perl Conference
------------------------------
Date: Sun, 12 Oct 1997 15:55:47 -0500
From: Yingxue Li <yingxue@ee.tamu.edu>
Subject: How does "die" work?
Message-Id: <Pine.SOL.3.96.971012153742.10489A-100000@eesun1.tamu.edu>
Hi, all:
In one of my cgi program, I used code like:
die "Content_type:text/html\n\n Please input data in every field"
unless($statement);
I expected it would export the message to browser when statement was not
true, but it didn't. Instead, it exported a server error message to
browser. When I checked the error_log of server, the message
(text/html\n\n,...) was there, following by "script headers premature".
I know there are some other ways to solve the problem, but, can "die" do
it?
Another stupid question, huh?
Li
------------------------------
Date: Sun, 12 Oct 1997 22:20:37 +0100
From: Rosemary I H Powell <Rosie@dozyrosy.demon.co.uk>
Subject: How to do hashes in CGI.pm - help needed please!
Message-Id: <VwI14PAl8TQ0EwZS@dozyrosy.demon.co.uk>
I feel very stupid asking this question because I'm sure that I am
missing something simple:
I have just started using CGI.pm instead of cgi-lib.pl and am having
difficulty working out how to get a list of all the parameters as
key/value pairs.
With cgi-lib.pl I can do something like:
foreach $input (values (%form_data) ) {
$form_data{$key} = $value;
}
CGI.pm documentation gives examples of how to get the names of all the
parameters:
@names = $query->param
or how to get the value(s) of a SINGLE named parameter:
@values = $query->param('foo')
$value = $query->param('foo')
But how do I get names and values into a hash where both are unknown
quantities??? I just can't see/understand how to do this and I'm getting
my knickers in a right old twist...If someone could show me the code to
match my cgi-lib example I would be truly grateful.
Thanks in advance,
Rosemary
-------------------------------------------------------------------
| Rosemary I.H.Powell EMail: Home: rosemary@dozyrosy.demon.co.uk |
| Work: r.i.h.powell@rl.ac.uk |
| http://www.netlink.co.uk/users/dozyrosy/ |
| http://www.dozyrosy.demon.co.uk/ |
-------------------------------------------------------------------
------------------------------
Date: 13 Oct 1997 01:38:01 GMT
From: stlam@ee.cuhk.hk (Lam_Sai_Tung)
Subject: howto: implement a mailing list?
Message-Id: <61ru1p$end@eng-ser1.erg.cuhk.edu.hk>
hi all,
I want to make a mailing list by having a account in a ISP.
I think I will use .forward
A web interface for the user to add, remove from the mailisg,
the cgi script edit the .forward file
I think i will work. but I want to append a text in each message,
showing the web address.
how to?
can u explain how .forward work? which program read the .forward file?
besides,
Is there other method to implement a mailing list? how?
I found some method from the newsgroups: /etc/aliases, procmail,
any know where to find a summary or faq about implementation of mailing list?
Thanks for help.
Please forward a reply to my mailbox, thanks.
--
Stlam
stlam@ee.cuhk.edu.hk
------------------------------
Date: Sun, 12 Oct 1997 17:48:17 -0700
From: Tim Sawyer <sawyer@ibm.net>
Subject: Re: Include gif without <image src=
Message-Id: <34416FD1.58568226@ibm.net>
Alan J. Flavell wrote:
> Oh no, questions about CGI programming belong on
> comp.infosystems.www.authoring.cgi, as people never tire of repeating
> here.
...
> If you'd consulted Nick Kew's CGI FAQ, for example, you'd have found
> this: http://www.webthing.com/tutorials/cgifaq.3.html#17
I know it gets real old answering the same stupid questions over and
over again. Sorry about that. I hate to post, and avoid it as much as
possible, because I never know if I'm goan' piss someone off, make
myself look like an idiot, or what. So I spent the whole damn weekend
figuring out what you told me in a few words. It really can be helpful
to us new bees when those in the know lend a hand. Thanks for pointing
me to the correct news group and FAQ.
--
- Tim -
------------------------------
Date: Sun, 12 Oct 1997 17:22:16 -0600
From: reljr@sigg.com
Subject: Re: need tricky regex
Message-Id: <876694318.13471@dejanews.com>
In article <343E70BC.2C8817D3@vpop.net>,
Matthew Reimer <mreimer@vpop.net> wrote:
>
> I need a single regex to pull out two pieces of information from a
> stream that looks like the text at the end of this message.
>
> Can someone suggest a regex that would handle this?
>
> Matt
Here is a regex, yes a simple regex that works on many variations
of Matt's problem without resorting to other techniques he did not
ask for.
m{
(?:
<H3>(.*?)</H3>
.*?
(?:(?:<a\shref=(.*?)>)|(?=<H3>.*?</H3>))
)+
}xigs
reljr@sigg.com
Robert Lee
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Sun, 12 Oct 1997 16:58:20 -0700
From: Tammy Lowney <tlowney@gonzaga.edu>
Subject: Perl Info!
Message-Id: <Pine.HPP.3.95.971012165754.386C-100000@barney.gonzaga.edu>
I am new to the perl language and would like some information sources on
where to get started (books, websites...). Any suggestions would be
appreciated. Thanks!!
------------------------------
Date: Mon, 13 Oct 1997 00:41:03 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Perl Info!
Message-Id: <34416e19.27784251@woody.wcnet.org>
[original author automagically cc'd via e-mail]
On Sun, 12 Oct 1997 16:58:20 -0700, Tammy Lowney <tlowney@gonzaga.edu>
wrote:
>I am new to the perl language and would like some information sources on
>where to get started (books, websites...). Any suggestions would be
>appreciated. Thanks!!
http://www.perl.com/
Jeremy
--
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>
"That's an example of how Perl can bring school yard cruelty to new heights."
-- Jon Orwant at the 1st Annual Perl Conference
------------------------------
Date: Sun, 12 Oct 1997 16:10:13 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: nguyent@uvil204.fr.ec.ps.net
Subject: Re: Problem with unix command
Message-Id: <34412EA5.D6941596@mail.earthlink.net>
[posted & mailed]
nguyent@uvil204.fr.ec.ps.net wrote:
>
> Dear all,
> I'm a new one in perl. Can somme one help me.
> I want to execute the unix command "dfspace" but I don't why my my
> perl script don't work with Netscape.
> here is my script:
> =========================================================
> $buffer = $ENV{"QUERY_STRING"};
> $flop = `echo $buffer|cut -d"=" -f2`;
> @junk = `remsh $flop /usr/sbin/dfspace` ;
Oh dear. You've got much bigger problems than not being able to execute
'dfspace', (which is probably due to permissions problems; remember that
the remsh command is being executed as the u/gid of the web server).
You have about the widest security hole imagineable in your script.
You're taking tainted data directly from a web browser and immediately
feeding it to a shell. What if a client hit your script with the string
"hi mom|rm -fr /"? *shudder*
First, you should immediately disable any cgi scripts you may have
already written, if possible.
Second, RUN, do not walk, to
http://www.perl.com/CPAN/doc/FAQs/cgi/www-security-faq.html
Read and understand, paying particular attention to chapters 6 & 7.
Third, consider using CGI.pm to simplify everything about writing cgi
scripts.
Then, rewrite any scripts you may have already written to reflect your
new-found knowledge.
Now, as far as the script you're trying to write here goes, a better
approach would probably be to keep the list of machines in a file on the
server, generate html with a selection list of machines, and pass back
to the cgi script an index into that list, so you don't have to work too
hard to validate the content. What you're trying to do can be fairly
complicated, whether you're using perl or not, so you should take some
time to do some research and reading before you start coding.
> print "Content-type:text/html\n\n";
> print <<EndOfHtml;
>
> <html><head><title>Tester une commande UNIX </title></head>
> <body>
> <h2>Disk space: $flop </h2>
> <hr>
> EndOfHtml
> ;
> print "<pre>";
> print @junk;
> print "</pre>";
> =========================================================
>
> Thanks in advance for your help.
> Tung.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 1164
**************************************