[18854] in Perl-Users-Digest
Perl-Users Digest, Issue: 1022 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 30 18:11:01 2001
Date: Wed, 30 May 2001 15:10:23 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <991260622-v10-i1022@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 30 May 2001 Volume: 10 Number: 1022
Today's topics:
Re: Perl request nobull@mail.com
Re: Perl request <mjcarman@home.com>
Re: Perl request <pne-news-20010530@newton.digitalspace.net>
Re: Perl request <bart.lateur@skynet.be>
Problems with CGI-script and stylesheets... <Rene.Scheibe@gmx.net>
Rounding <david_jerzycki@agilent.com>
Re: Rounding <addi@umich.edu>
Re: Rounding (Randal L. Schwartz)
Re: Search and Replace <mischief@velma.motion.net>
Re: Secure Mail with Perl? An ENCRYPTION Algorithm is n <mischief@velma.motion.net>
Re: Silly pipe() question <goldbb2@earthlink.net>
troubleshooting socket problem(s) <he.is@bigfoot.com>
Variablen durch Formular <ludmilla.markowska@gmx.net>
Re: Variablen durch Formular <fh@florentin-hauber.de>
Re: Variablen durch Formular <achim.grolms@web.de>
Re: Variablen durch Formular <ludmilla.markowska@gmx.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 May 2001 19:31:17 +0100
From: nobull@mail.com
Subject: Re: Perl request
Message-Id: <u9d78qbsei.fsf@wcl-l.bham.ac.uk>
WGSGNUAYHTTE@spammotel.com (Teffy) writes:
> I need a "program" that will use the filenames in one directory to
> delete files in another directory.
Sounds like just the sort of thing shell script is ideal for, but then
again Perl ain't bad.
> The "program" may be a Perl script, batch file, or ??? that will run
> on Windows 2000 Pro.
If this were Unix I'd say to do it in shell:
cd /another/directory; rm `cd /one/directory; echo *`
You can get real shells in Windows I guess I'd go for Perl. Then
again you've posted this to a Perl newsgroup so I guess you'd guessed
that.
> I have done alot of programming mostly in FORTRAN on a VAX, but don't
> have experience with Windows outside of the GUI.
Yes, I recommed you learn Perl.
perl -e"chdir '/one/directory'; @files=glob('*'); chdir '/another/directory'; unlink @files;"
BTW: You really do use '/' not '\' as the direcotry component
separator.
Be warned if you mistype /another/directory you'll delete all the
files in /one/directory.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 30 May 2001 13:58:03 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Perl request
Message-Id: <3B1542BB.9A609815@home.com>
Teffy wrote:
>
> I need a "program" that will use the filenames in one directory to
> delete files in another directory.
Then write one, or hire someone to do it for you. This newsgroup is a
place to discuss Perl, not a free script-writing service. By asking for
someone to do your work for free you've just irritated many of the
people here. Expect to be chastised for it.
[Program requirements snipped.]
That looks pretty simple. Why don't you try to do it yourself? If you
have problems (and can't find a solution after checking the
documentation) then post a help request here. Most of the people in this
ng are quite happy to offer assistance, but only if you've made an
effort yourself first.
-mjc
------------------------------
Date: Wed, 30 May 2001 21:57:03 +0200
From: Philip Newton <pne-news-20010530@newton.digitalspace.net>
Subject: Re: Perl request
Message-Id: <vkhahtsa38slet2to272dbmcni90o6luoi@4ax.com>
On 30 May 2001 10:52:39 -0700, WGSGNUAYHTTE@spammotel.com (Teffy) wrote:
> I need a "program" that will delete those files in ORIGINALS that
> don't appear in KEEPERS.
You want us to mail you our rate cards? :)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Wed, 30 May 2001 20:41:51 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl request
Message-Id: <akmaht824g10v7cl866enf7jss7jgsudn1@4ax.com>
Teffy wrote:
>I need a "program" that will delete those files in ORIGINALS that
>don't appear in KEEPERS.
> for example, after the "program" runs, ORIGINALS will contain:
> pic_002.raw
> pic_002.thm
Go through all the files in the ORIGINAL directory. Drop the directory
path and the file extension. Check if the file exists in KEEPERS with
the ".jpg" extension. If it doesn't, unlink the file-under-test.
You can keep a list of basenames of files that need to be kept, in a
hash, for a speed boost. For example:
%keepers = ( pic_002 => 1 );
--
Bart.
------------------------------
Date: Wed, 30 May 2001 22:44:47 +0200
From: "Rene Scheibe" <Rene.Scheibe@gmx.net>
Subject: Problems with CGI-script and stylesheets...
Message-Id: <9f3m18$249k4$1@ID-65612.news.dfncis.de>
I have a website which autoloads a cgi-script
written in perl. The output of the script is the
following:
Content-type: text/html
<HTML>
<HEAD>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<link rel="stylesheet" href="css/menue_left.css">
</HEAD>
<BODY>
Externe IP: 217.80.140.34
</BODY>
</HTML>
My problem is that the browser doesn't use the stylesheet-file.
But when I copy the code by hand to an html-file and put it on
my apache-webserver everything works fine.
Can you tell me something about it.
Yes I know it's not really content of this NG.
------------------------------
Date: Wed, 30 May 2001 12:38:49 -0600
From: dave jerzycki <david_jerzycki@agilent.com>
Subject: Rounding
Message-Id: <3B153E39.F10395CC@agilent.com>
Is there any function or procedure within perl (5.0) to round?
I can seem to locate any.
I have two scalars I divide by to get a percentage.
The figure comes out to 3.62509923334717
I'd like it to be just 3.62
use integer of course screws things up.
I'm using the print function to print the data to a file, so I can't
use any
formating as in printf.
Is there some other way around this?
------------------------------
Date: Wed, 30 May 2001 18:44:12 GMT
From: Arnar M Hrafnkelsson <addi@umich.edu>
Subject: Re: Rounding
Message-Id: <m34ru2k76q.fsf@steypa.ast.is>
dave jerzycki <david_jerzycki@agilent.com> writes:
> Is there any function or procedure within perl (5.0) to round?
> I can seem to locate any.
> I have two scalars I divide by to get a percentage.
> The figure comes out to 3.62509923334717
> I'd like it to be just 3.62
> use integer of course screws things up.
> I'm using the print function to print the data to a file, so I can't
> use any
> formating as in printf.
> Is there some other way around this?
$r = sprintf("%.2f", $x);
-- Arnar
------------------------------
Date: 30 May 2001 12:03:10 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Rounding
Message-Id: <m1zobufymp.fsf@halfdome.holdit.com>
>>>>> "dave" == dave jerzycki <david_jerzycki@agilent.com> writes:
dave> Is there any function or procedure within perl (5.0) to round?
dave> I can seem to locate any.
You've not tried:
perldoc -q round
apparently.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Wed, 30 May 2001 20:16:29 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Search and Replace
Message-Id: <thal8tpv0h7c85@corp.supernews.com>
David Aslanian <davidaslanian@hotmail.com> wrote:
[snip some unattributed text quoted by the previous poster]
[snip]
> while(<c:\\*.html>) { # double \\ are escaped backslashes
Why? Why not just use a forward slash instead?
Chris
--
Parking for people we like only. All other vehicles will be vandalized.
------------------------------
Date: Wed, 30 May 2001 20:41:35 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Secure Mail with Perl? An ENCRYPTION Algorithm is needed...
Message-Id: <thamnvpva48g34@corp.supernews.com>
Neil Smith <smug@rocketmail.com> wrote:
> "Lars" <Lars.Plessmann@gmx.de> wrote in message
> news:3b138dd6.7429886@news.btx.dtag.de...
>> I've written a CGI scipt which should send an email notification.
>> This mail contains secret data.
>> Is there any possibility to encrypt the mail in my perl script?
>>
>> Will be mails encrypted automatically if you have a server that
>> supports SSL?
>> If not, maybe you can refer to a good encryption algorithm? I have to
>> encode creditcard numbers and things like that!
> No, unfortunately emails won't be encrypted on an SSL server. In these
> cases, SSL has been installed onto the webserver, encrypting traffic between
> the web browser and the server.
It is techically possible to have an SSL-enabled SMTP server. They
aren't in the widest use, though, and this has nothing to do with
Perl.
The best bet is to use an encryption module from CPAN. There are
modules for PGP, IDEA, Blowfish, and other methods of encryption.
http://www.cpan.org
Chris
--
Parking for people we like only. All other vehicles will be vandalized.
------------------------------
Date: Wed, 30 May 2001 18:08:09 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Silly pipe() question
Message-Id: <3B156F49.CC84E79C@earthlink.net>
nobull@mail.com wrote:
>
> Benjamin Goldberg <goldbb2@earthlink.net> writes:
>
> > I suppose that this might seem to be a silly question, but...
> >
> > Why does the builtin function pipe() take two target operands,
> > rather than taking no arguments and returning a two-element list?
>
> History. In the days when most filehandles were written as naked
> symbols it made sense to say;
>
> pipe READER, WRITER;
Yes, I realize that, but it would be more perl-ish for pipe to return a
two element list. Not that I would suggest eliminating the two-argument
version, but simply extending the syntax slightly. Perl is entirely
capable of counting the number of arguments a function was called with;
there's no reason it can't have both pipe(R, W), and (*R, *W) = pipe;
> > I would prefer to be able to do these:
> > my ($read_fh, $write_fh) = pipe;
> > or local (*READER, *WRITER) = pipe;
> > or my @p = pipe;
>
> Nobody is preventing you writing an alternative function with those
> semantics.
But it wouldn't be a builtin, which is what I'm after.
> > I know where the original syntax comes from... the C function
> > pipe takes as an argument a pointer to two ints, and fills them in
> > with filedescriptors... but the only reason it was done that way
> > (AFAIKS) is that C functions can only return a single value. Perl
> > has no difficulty at all returning a list with multiple values.
> > Also, it should have no difficulty differentiating the different
> > number of arguments, to do The Right Thing.
>
> Seems to me like there's little gain here.
It's an alternate syntax, which might in some cases be more readable.
Saying there's "little to gain" is like saying that because we have:
if( foo ) { bar }
we therefor don't need:
bar if( foo );
Since we have one, we don't *need* the other... but nonetheless, we have
both, and both are used ... whichever makes the code clearer is used.
And we *do* gain, even though the effects are the same... it helps us
write code whose form reflects it's function.
Just because it works as is, doesn't make the best and only way to do
it.
For instance, consider
read( $fh, $buf, $len );
We can write this as:
$buf = do { local $/ = \$len; <$fh>; }
Is the read($buf) syntax so much better than the $buf = <$fh> syntax
that we shouldn't have the latter?
Suppose that fork() took a scalar as an argument and filled it in with
the child pid or 0? (i.e. fork($pid) rather than $pid=fork()) I'm sure
this could be/could have been done, but having it return a value in a
normal way is much better, most of the time, anyway.
I'm not suggesting we remove the old syntax from pipe, just that we add
a new syntax to it.
--
The longer a man is wrong, the surer he is that he's right.
------------------------------
Date: Wed, 30 May 2001 20:46:34 GMT
From: Derek Shaw <he.is@bigfoot.com>
Subject: troubleshooting socket problem(s)
Message-Id: <3B155C29.FC5B04E4@bigfoot.com>
Overview:
attempting to get a 319-line perl script known as redirex
(http://www.fourmilab.ch/webtools/redirex/) to work under slackware Linux
(kernel 2.2.13). I think it's slackware 4. Perl is v 5.005_03
Config file for redirex has several hard-coded variables in it, which
the author included with a disclaimer (shown below).
running everything as root.
Details:
The slackware Linux is BSD-ish. The .h files referred to (as a lookup
point) in the redirex.conf file do not contain many of the variables.
I must admit that I gave up following the includes, as I was getting
nowhere.
The current redirex.conf file follows, and following that are a couple of
the .h files from the Linux box. The current failure message is:
can't setsockopt: Protocol not available
this appears to come from line 94 of the redirex script, and involves
some of those hard-coded vars (that I can't find in the .h files)
setsockopt(S, $SOL_SOCKET, $SO_REUSEADDR, pack('i', 1))
|| die "can't setsockopt: $!\n";
I am at a loss as to what to do get this working. Thanks in advance for
any help!.
d.
--------------
The relevant bits of the redirex.conf file:
# Configuration file for redirex version 1.0
#
# If your system doesn't use standard System V values for
# the following (as is the case for some BSD-derived systems
# such as SunOS 4.x), replace them with the correct values
# from your /usr/include/sys/socket.h and /usr/include/sys/errno.h
# files. The proper Perl way to do is to include .ph files created
# by h2ph from the corresponding C include files, but I've found
# many Perl installations have not set up these files correctly.
# Hard coding is ugly, but it avoids having to fight with the Perl
# installation just to get this program running. The comment gives
# the directory in C notation, usually below /usr/include, where
# the definition can usually be found.
$AF_INET = 2; # Internet address family <sys/socket.h>
$PF_INET = $AF_INET; # Internet protocol <sys/socket.h>
## $SOCK_STREAM = 2; # Stream socket type <sys/socket.h>
$SOCK_STREAM = 1; # Stream socket type <bits/socket.h>
$SOL_SOCKET = 0xFFFF; # Socket option mask <sys/socket.h>
$SO_REUSEADDR = 0x0004; # Option: reuse address <sys/socket.h>
$EINTR = 4; # Interrupted system call status <sys/errno.h>
$ECHILD = 10; # No children status <sys/errno.h>
$EPROTO = 71; # Protocol error <sys/errno.h>
# Default port to listen to. If the -p switch is used
# to specify another port, this value will not be used.
#$defaultport = 9080; # For testing
$defaultport = 80; # Standard HTTP port (must be super-user to bind)
...snip.
the socket.h, errno.h and included files from the Linux box:
CONTENTS of /usr/include/bits/socket.h (see include statement in /usr/include/sys/socket.h)
/* System-specific socket constants and types. Linux version.
Copyright (C) 1991,92,94,95,96,97,98,99 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef __BITS_SOCKET_H
#define __BITS_SOCKET_H
#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
#endif
#define __need_size_t
#define __need_NULL
#include <stddef.h>
#include <limits.h>
#include <sys/types.h>
/* Type for length arguments in socket calls. */
typedef unsigned int socklen_t;
/* Types of sockets. */
enum __socket_type
{
SOCK_STREAM = 1, /* Sequenced, reliable, connection-based
byte streams. */
...snip
CONTENTS of /usr/include/sys/errno.h
#include <errno.h>
(yes, that's all there is to that file)
Since I fear I have already included too much, I will omit the contents of
both the redirex script and /usr/include/sys/socket.h, unless someone thinks
it would help.
--
Derek Shaw
Victoria, BC.
email address is a bit-bucket. Substitute derekshaw for he.is
------------------------------
Date: Wed, 30 May 2001 20:06:47 +0200
From: "Ludmilla Markowska" <ludmilla.markowska@gmx.net>
Subject: Variablen durch Formular
Message-Id: <9f3cj2$emc$01$1@news.t-online.com>
Hallo,
ich bastele gerade an einem Script, mit dem man über eine Website u.a neue
Zonendateien für einen DNS-Server anlegen kann, das Script, das an der
Consolo gut funktioniert sieht (stark gekürzt) so aus:
#!/usr/bin/perl -w
# adddom
use CGI qw(:standart);
use strict;
# print("\n\nZONE DOMAIN anlegen\----------\n\n");
#my $domain = domain;
#print("DOMAIN: ");
$domain = <STDIN>;
chomp($domain);
system <"touch $domain.hosts">;
open ZONE, ">$domain.hosts" or
die "I can't open zonendatei";
print ZONE <<"EOH";
zone \"$domain\" \{
type master\;
file \"\/var\/named\/$domain\"\;
\}\;
EOH
das Formular dazu:
...
<form action="/cgi-bin/addzone-cgi.pl">
<p>Bitte geben Sie den Domainnamen ein:
<input name="domain" size="50"></p>
<input type="submit" value="Abschicken">
</form>
...
Problem, es gibt einen "Internal Server Error".
Kann mir jemand sagen, was ich da falsch mache?
danke für euere Hilfe
ludmilla
------------------------------
Date: Wed, 30 May 2001 20:55:48 +0200
From: "Florentin Hauber" <fh@florentin-hauber.de>
Subject: Re: Variablen durch Formular
Message-Id: <9f3flq$7sb$04$1@news.t-online.com>
Hallo!
> Problem, es gibt einen "Internal Server Error".
> Kann mir jemand sagen, was ich da falsch mache?
Was steht denn im Error-Log?
Gruß
Flo
------------------------------
Date: Wed, 30 May 2001 21:05:55 +0200
From: Achim Grolms <achim.grolms@web.de>
Subject: Re: Variablen durch Formular
Message-Id: <9f3gaj$l00$00$2@news.t-online.com>
In de.comp.lang.perl.cgi Ludmilla Markowska <ludmilla.markowska@gmx.net> wrote:
> Hallo,
> ich bastele gerade an einem Script, mit dem man über eine Website u.a neue
> Zonendateien für einen DNS-Server anlegen kann, das Script, das an der
> Consolo gut funktioniert sieht (stark gekürzt) so aus:
> #!/usr/bin/perl -w
> # adddom
> use CGI qw(:standart);
> use strict;
> # print("\n\nZONE DOMAIN anlegen\----------\n\n");
> Problem, es gibt einen "Internal Server Error".
Und der steht im Errorlog drinnen.
> Kann mir jemand sagen, was ich da falsch mache?
FAQ lesen :
http://www.worldmusic.de/perl/
Auf Anhieb sehe Ich, daß ein gültiger
Content-Heder fehlt.
HTH, Achim
f'up nach dclpc gesetzt.
------------------------------
Date: Wed, 30 May 2001 22:20:53 +0200
From: "Ludmilla Markowska" <ludmilla.markowska@gmx.net>
Subject: Re: Variablen durch Formular
Message-Id: <9f3kee$o5h$02$1@news.t-online.com>
Hallo,
danke erstmal!
Klar habe ich die doku gelesen, wollte das ganze halt gerne etwas kürzen,
wenn möglich.
So klappt es aber:
#!/usr/bin/perl -w
use CGI qw(:standard);
use strict;
my $domain = param('domain');
my $antwort = <<HERE_ANTWORT;
<html>
...
</html>
HERE_ANTWORT
print header, $antwort;
system <"mkdir $domain">;
system <"touch $domain.hosts">;
open ZONE, ">$domain.hosts" or
die "I can't open zonendatei";
print ZONE <<"EOH";
zone \"$domain\" \{
type master\;
file \"\/var\/named\/$domain\"\;
\}\;
EOH
Nur verstehe ich trotzdem nicht, warum man die Variable "domain" aus dem
Formular nicht einfach so in das Script einsetzen kann?
Wäre nett wenn mir trotzdem jemand helfen könnte!
gruss
ludmilla
------------------------------
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 1022
***************************************