[7419] in Perl-Users-Digest
Perl-Users Digest, Issue: 1044 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 18 14:17:35 1997
Date: Thu, 18 Sep 97 11:01:02 -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 Thu, 18 Sep 1997 Volume: 8 Number: 1044
Today's topics:
.xs error values with a .pm method (Scott Grosch)
Re: Algorithm for splitting flat files <rootbeer@teleport.com>
Re: Change /etc/passwd <jcarlosd@ford.com>
Re: Change /etc/passwd (Jason Gloudon)
Re: Change /etc/passwd <seay@absyss.fr>
Dial-Up Networking with Perl ? (batman)
Re: Finding out what they typed <rootbeer@teleport.com>
GNU sort & Perl <j.curzon-price@ic.ac.uk>
Re: GNU sort & Perl <rootbeer@teleport.com>
Re: Hint executing passed script fragments? <rootbeer@teleport.com>
Re: How to use POST method to call a CGI script from Pe <rootbeer@teleport.com>
HTTP::Request - how to get $content in there? x@apocalypse.org
Re: HTTP::Request - how to get $content in there? <aas@bergen.sn.no>
Re: Impossible dbm size <justinb@springer.cray.com>
Re: IP checking <rootbeer@teleport.com>
Re: KornShell to Perl <merlyn@stonehenge.com>
Re: KornShell to Perl <rootbeer@teleport.com>
locking files on unix properly (Richard Smol)
Re: locking files on unix properly (Jeremy D. Zawodny)
Re: locking files on unix properly <rootbeer@teleport.com>
manServer (troff to HTML interpreter) <rolf@parallax.co.uk>
Re: Newbie question about system function <rootbeer@teleport.com>
Re: Perl and WINNT4.0 <dvpgg@landmark.com>
Perl CGI Win-httpd problem (August Brunsman)
Returning hashes of arrays from a subroutine r_a_m_l_i@csc.ti.com
Re: Returning hashes of arrays from a subroutine (Matthew Cravit)
Re: Rounding numbers problem (Michael Fuhr)
Re: Rounding numbers problem <eike.grote@theo.phy.uni-bayreuth.de>
Re: Rounding numbers problem (Tad McClellan)
Re: Something of the day script <rootbeer@teleport.com>
Re: Text::Wrap bombs on lines with no white space! (Andrew M. Langmead)
Re: Text::Wrap bombs on lines with no white space! <rootbeer@teleport.com>
Re: The CSV format stinks! (Andrew M. Langmead)
usage of gethostbyaddr <benday@ultranet.com>
Re: usage of gethostbyaddr <rootbeer@teleport.com>
Re: Win32 Perl FAQ Addition? (WAS Re: Is Perl for Win32 (Andrew M. Langmead)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Sep 1997 17:05:38 GMT
From: grosch@ichips.intel.com (Scott Grosch)
Subject: .xs error values with a .pm method
Message-Id: <5vrn12$3to@news.or.intel.com>
I'm writing a perl module for LDAP, so I've defined an Ldap class, where I
do '$thing = new Ldap' and I might have multiple of these in a program. Most
of the functions don't make it convenient to return both an error code and
data, so I want to create an Ldap::errno type value.
I understand how to do that from the .xs file, but that'll make it a global
variable to that package. How do I attach it to the $thing I created? Most
of the functions in the .xs code are just stubs, like:
int
ldap_func(foo)
int foo
with no CODE blocks or anything. I'd hate to have to define a sub for each
of those in the .pm file that called it, set an error, and returned, like:
sub func {
my $self = shift;
$self->{status} = ldap_func(shift);
}
Is there a way from the .xs file to realize that I've been called from a method
and then it can set the value directly?
------------------------------
Date: Thu, 18 Sep 1997 10:00:34 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "E.R. Daams" <eelco@bicho.eui.upm.es>
Subject: Re: Algorithm for splitting flat files
Message-Id: <Pine.GSO.3.96.970918095925.8611S-100000@julie.teleport.com>
On Thu, 18 Sep 1997, E.R. Daams wrote:
> does somebody have an algorithm to split flat files.
Maybe you want the Unix utility called split. Otherwise, try making N
copies of portions of the file, then delete the original. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 18 Sep 1997 14:33:20 +0200
From: Juan Carlos del Rio <jcarlosd@ford.com>
Subject: Re: Change /etc/passwd
Message-Id: <34211F90.9DF@ford.com>
brian d foy wrote:
>
> In article <3420E375.3F3@ford.com>, jcarlosd@ford.com wrote:
>
> >My question is the following: is it possible to run a perl program so
> >they can change the access password (updating /etc/passwd file)?
>
> sure, but they would have ot be superuser (or somehow get their process
> to be root).
>
> if they want to change their password, use the passwd command. that's
> why it's there :)
What I want to do is create a page where our unix users can change their
systema password.
As far as I know, the passwd command is not suitable for that, mainly
because it does
run in interactive mode.
Is there any perl function or routine that can send the password
parameters (user, old password, new password) to the passwd command?
------------------------------
Date: 18 Sep 1997 13:24:27 GMT
From: jgloudon@bbn.com (Jason Gloudon)
Subject: Re: Change /etc/passwd
Message-Id: <5vra2b$rp2$1@daily.bbnplanet.com>
In article <34211F90.9DF@ford.com>,
Juan Carlos del Rio <jcarlosd@ford.com> wrote:
>brian d foy wrote:
>>
>> In article <3420E375.3F3@ford.com>, jcarlosd@ford.com wrote:
>>
>> >My question is the following: is it possible to run a perl program so
>> >they can change the access password (updating /etc/passwd file)?
>>
>> sure, but they would have ot be superuser (or somehow get their process
>> to be root).
>>
>> if they want to change their password, use the passwd command. that's
>> why it's there :)
>
>What I want to do is create a page where our unix users can change their
>systema password.
>As far as I know, the passwd command is not suitable for that, mainly
>because it does
>run in interactive mode.
>
>Is there any perl function or routine that can send the password
>parameters (user, old password, new password) to the passwd command?
The simplest way to do this from a language perspective is to use expect
see http://expect.nist.gov.
Jason Gloudon
------------------------------
Date: Thu, 18 Sep 1997 19:00:57 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Change /etc/passwd
Message-Id: <34215E49.7DCC4F60@absyss.fr>
Juan Carlos del Rio wrote:
>
> Our web server is running on HP-UX 10.2. Some of our users are able to
> input files on it, because I have created them as unix users.
>
> My question is the following: is it possible to run a perl program so
> they can change the access password (updating /etc/passwd file)?
If you run your server as root, /etc/passwd is as editable as any other
file. You can just use open() and go to town on it. Mind you, I think
you'd be a fool for allowing someone to randomly modify this file.
Using one of the standard tools (ie - passwd) would make much more sense
to me. The only problem there is that passwd reads and writes directly
to the tty device, not to stdin and stdout. You would have to set up
some sort of pseudoterminal (ptty) for handling this. As I've never
done that, I have no idea how hard this would be.
- doug
------------------------------
Date: 18 Sep 1997 17:34:09 GMT
From: as646@freenet.carleton.ca (batman)
Subject: Dial-Up Networking with Perl ?
Message-Id: <5vromh$kft1@piper.ncr.pwgsc.gc.ca>
I would like to use Win95's Dial-Up Networking (DUN) to make a connection
to my ISP. Or if the connection is already up, then tell Perl to use
that connection.
Does anyone have an idea on how to start doing this with Perl for Windows
95/NT and PerlWin32 ? Any suggestions or info are appreciated. Thanks!
------------------------------
Date: Thu, 18 Sep 1997 09:34:50 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ed Vander Bush <temp.ed.vanderbush@bentley.com>
Subject: Re: Finding out what they typed
Message-Id: <Pine.GSO.3.96.970918093205.8611L-100000@julie.teleport.com>
On Wed, 17 Sep 1997, Ed Vander Bush wrote:
> I nned to know what URL a client entered to come to a certain page...
How can you be sure that they typed anything? They may have clicked, or
they may have been redirected. If they're using http 1.0, you can't even
find out what server they asked for.
> If locally they type www o get to a page my script will not work. They
> need to type www.domainname.com. (The full URL) I need to be able to
> redirect them. How can this be done thoguh PERL/CGI?
Use the standard method of redirection, but specify the full URL that you
want. (I think that's what you're asking, but I'm not sure.) There's a
module on CPAN which can help you to send out the redirection information.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 18 Sep 1997 15:16:45 +0100
From: Tony Curzon Price <j.curzon-price@ic.ac.uk>
Subject: GNU sort & Perl
Message-Id: <342137CD.FB7A888@ic.ac.uk>
Hello.
I had some sorting to do, so read the very comprehensive post by Tom
Christiansen. He suggests that it's often a good idea to write to a file
and get GNU sort to do the work.
Here's the problem:
I have a file, tat when sorted (from bash with "sort -o file.txt -b +2
-3n file.txt") returns a beuatifully sorted file.
In my Perl script, I have:
$str = `sort -o $ifiles[$k+1] -b +2 -3n $ifiles[$k+1]`;
hoping to achieve the same thing.
What seems to happen is that I have a sorted file, but sorted without
the -b switch 9which ignores leading blanks in a filed). The alignment
of my data is such that sorting without -b cuases -ve and 0 values not
to be sorted, but positive ones to be perfectly OK.
Any ideas?
Thanks
Tony
--
Tony Curzon Price Imperial College
http://is.eunet.ch/Customers/curzon/index.html
(During GMT office hours, or so):
http://epgphd.et.ic.ac.uk/www/
------------------------------
Date: Thu, 18 Sep 1997 10:07:14 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tony Curzon Price <j.curzon-price@ic.ac.uk>
Subject: Re: GNU sort & Perl
Message-Id: <Pine.GSO.3.96.970918100549.8611U-100000@julie.teleport.com>
On Thu, 18 Sep 1997, Tony Curzon Price wrote:
> I have a file, tat when sorted (from bash with "sort -o file.txt -b +2
> -3n file.txt") returns a beuatifully sorted file.
>
> In my Perl script, I have:
> $str = `sort -o $ifiles[$k+1] -b +2 -3n $ifiles[$k+1]`;
> hoping to achieve the same thing.
>
> What seems to happen is that I have a sorted file, but sorted without
> the -b switch 9which ignores leading blanks in a filed).
Maybe you're calling a different sort binary than you thought; check your
$PATH or use the full path to sort, or both. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 18 Sep 1997 09:31:01 -0700
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Hint executing passed script fragments?
Message-Id: <Pine.GSO.3.96.970918092756.8611K-100000@julie.teleport.com>
On Wed, 17 Sep 1997, dave wrote:
> How should a running perl script execute perl script fragments that
> are received from a shell script?
Do you mean that a shell script is running the Perl script, and giving the
Perl script snippets of Perl to execute? You could do this with eval, if
you trust the snippets.
> What is the best way to return values to the shell script?
However the shell script wants. That could be in the form of the standard
output stream, or in the form of a modified file.
> | For reply by email, use:
> | dlripber@one.net
For a reply by email, use headers. It doesn't help you, me, or anyone else
to put your address here and not in the headers.
Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 18 Sep 1997 09:27:09 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: x@apocalypse.org
Subject: Re: How to use POST method to call a CGI script from Perl?
Message-Id: <Pine.GSO.3.96.970918092608.8611J-100000@julie.teleport.com>
On Wed, 17 Sep 1997 x@apocalypse.org wrote:
> How would I use Perl to send a bunch for form data from a CGI
> script using the POST method, rather than encoding everything in
> a URL...
There's a module on CPAN to do that.
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
> Also, for when I've got small data sets, how would I convert
> all the non-alphanumeric characters in a string to the hex format
> browsers seem to like: (i.e. %xx)
There's a module to do that, too. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 18 Sep 1997 08:23:01 -0600
From: x@apocalypse.org
Subject: HTTP::Request - how to get $content in there?
Message-Id: <874588535.21677@dejanews.com>
What I'm trying to do: use the POST method from a CGI script to
post form data non-interactively.
I got the LWP module, and am looking at the request object syntax;
unfortunately, the documentation hasn't helped much. The syntax is:
$r = new HTTP::Request $method, $url, [$header,
[$content]]
Ok, so here I am:
$r = new HTTP::Request 'POST', 'http://www.somedomain.com',
$content?!? In the script, I've read-in data from a form using
CGI.pm. Now, I want to get that form data POSTed to another CGI script;
the data has a lot of text in it; say, a paragraph here and a paragraph
here from <TEXTAREA> input boxes... so it doesn't seem like URL-encoding
(GET) is the way to go. What syntax should I use in place of "$content"
to get all the data received from CGI.pm into the Request object?
If there is an extensive list of examples somewhere on using LWP, I'd
love to know about it.
Does anyone have code to do what I want to do? I'm just plain stuck at
this point.
Thanks.
- Xochi
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 18 Sep 1997 16:26:06 +0200
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: HTTP::Request - how to get $content in there?
Message-Id: <hk9ger94x.fsf@bergen.sn.no>
x@apocalypse.org writes:
> What I'm trying to do: use the POST method from a CGI script to
> post form data non-interactively.
>
> I got the LWP module, and am looking at the request object syntax;
> unfortunately, the documentation hasn't helped much. The syntax is:
>
> $r = new HTTP::Request $method, $url, [$header,
> [$content]]
>
> Ok, so here I am:
>
> $r = new HTTP::Request 'POST', 'http://www.somedomain.com',
>
> $content?!? In the script, I've read-in data from a form using
> CGI.pm. Now, I want to get that form data POSTed to another CGI script;
For instance like this:
$q = new CGI;
($content = $q->self_url) =~ s/[^?]*\?//;
$r->content_type("application/x-www-form-urlencoded");
$r->content($content);
--
Gisle Aas <aas@sn.no>
------------------------------
Date: 18 Sep 1997 09:32:07 -0500
From: Justin Banks <justinb@springer.cray.com>
Subject: Re: Impossible dbm size
Message-Id: <o8n7mcezo9k.fsf@springer.cray.com>
jgloudon@bbn.com (Jason Gloudon) writes:
> In article <34202F4C.66B2FDBA@ican.net>,
> Charles Jaimet <cjaimet@ican.net> wrote:
> >My server says my dbm database file takes up 4,800 GB!
> >
I think it's also possible that your LOCALE indicates that you're in Europe,
in which case 4,800 would translate to 4.8 American. Still large, but not
unusual. How your machine handles this is probably OS dependent, if this is
indeed the problem.
-justinb
--
Justin Banks \ If you spam me, I promise to go upstream from you until I
Silicon Graphics \ find someone that cares. Then, I'll think about charging
Eagan, Minnesota \ you for my time. Do it at your own risk
------------------------------
Date: Thu, 18 Sep 1997 09:58:57 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Toni Makela <makela@riksu.hamkk.fi>
Subject: Re: IP checking
Message-Id: <Pine.GSO.3.96.970918095720.8611R-100000@julie.teleport.com>
On Thu, 18 Sep 1997, Toni Makela wrote:
> How can i check if the users IP-address is allowed IP!
Use Perl. :-)
> Example, all users form 222.222.222.xxx are allowed to access, no-one
> else!
Compare the first three octets of the user's address with the allowed
values. If you get stuck trying to do that, and you can't find the answer
in the docs and FAQs, post again and tell us where you've gotten stuck.
Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 18 Sep 1997 09:59:21 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: petja@weald.air.saab.se (peter jacobsson)
Subject: Re: KornShell to Perl
Message-Id: <8cg1r2pnh2.fsf@gadget.cscaper.com>
>>>>> "peter" == peter jacobsson <petja@weald.air.saab.se> writes:
peter> Hi all,
peter> Is there a Kornshell to Perl translator??
Yes... I'm working on one... here's an alpha release:
#!/usr/bin/perl
## usage: $0 <ksh-script >perl-script
print <<'MARK', <>, "\nEND\n";
#!/usr/bin/perl
system "/bin/ksh", "-c", <<'END', @ARGV; exit $? >> 8;
MARK
Although it's an alpha release, it seems pretty complete, although I
want to add options for bash and a few other popular shells.
(Unfortunately, csh will require a completely different strategy.
Stoopid csh.) I'm also considering having it automatically recognize
the #! line.
Maybe 5.005 will come with this installed as ksh2perl. I can only
hope!
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 347 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 18 Sep 1997 10:04:14 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: peter jacobsson <petja@weald.air.saab.se>
Subject: Re: KornShell to Perl
Message-Id: <Pine.GSO.3.96.970918100234.8611T-100000@julie.teleport.com>
On 18 Sep 1997, peter jacobsson wrote:
> Is there a Kornshell to Perl translator??
Yes; use this algorithm.
read the ksh script
understand it
re-write it in Perl.
That's really as good as it gets! :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 18 Sep 1997 15:40:55 GMT
From: bl227@cleveland.Freenet.Edu (Richard Smol)
Subject: locking files on unix properly
Message-Id: <5vri27$137@alexander.INS.CWRU.Edu>
How do I implement file-locking properly on a UNIX-system? E.g.
I need several processes to read and write in a certain file,
but I don't want the file to become corrrupted.
Thanks in advance,
Greetz... Richard Smol
------------------------------
Date: Thu, 18 Sep 1997 15:53:57 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: locking files on unix properly
Message-Id: <342a4e1f.181682115@igate.hst.moc.com>
[cc'd automagically to original author]
On 18 Sep 1997 15:40:55 GMT, bl227@cleveland.Freenet.Edu (Richard
Smol) wrote:
>
>How do I implement file-locking properly on a UNIX-system? E.g.
>I need several processes to read and write in a certain file,
>but I don't want the file to become corrrupted.
Check perlfunc for flock() and see the FAQ:
http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html#How_can_I_lock_a_file_
Hope that helps,
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: Thu, 18 Sep 1997 10:46:43 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Richard Smol <bl227@cleveland.Freenet.Edu>
Subject: Re: locking files on unix properly
Message-Id: <Pine.GSO.3.96.970918104627.8611X-100000@julie.teleport.com>
On 18 Sep 1997, Richard Smol wrote:
> How do I implement file-locking properly on a UNIX-system? E.g.
> I need several processes to read and write in a certain file,
> but I don't want the file to become corrrupted.
I think you could use the methods in Randal's fourth Web Techniques
column, which explains how to use flock() to avoid problems when multiple
processes need to modify one file. Hope this helps!
http://www.stonehenge.com/merlyn/WebTechniques/
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 18 Sep 1997 17:10:25 +0100
From: Rolf Howarth <rolf@parallax.co.uk>
Subject: manServer (troff to HTML interpreter)
Message-Id: <34215271.9DA@parallax.co.uk>
manServer is a Perl script that parses Unix manual pages and converts
them to HTML.
Unlike similar programs which use nroff to do the formatting and just
display the plain text output generated by nroff, manServer makes a
reasonable attempt at interpreting troff directives and man macros
itself. In most cases this produces much more readable results.
As one would expect, references to other man pages are converted to HTML
links, as are URLs, links to other sections of the document, and so on.
Tables generated using the tbl preprocessor are supported, as are simple
eqn equations. Note, however, that troff is a layout-oriented markup
language and gives much more control over page layout than HTML does, so
there are many situations where it is not possible to accurately render
a page as it was originally intended.
manServer is designed to work as a CGI script, but also features a
limited built-in HTTP server for standalone use.
It can be downloaded from
http://www.parallax.co.uk/~rolf/download/manServer.pl
A more detailed description and sample output can be viewed at
http://www.parallax.co.uk/~rolf/download/manServer.html
-Rolf
------------------------------
Date: Thu, 18 Sep 1997 09:46:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Kenneth G. Markus" <markus@dismal.com>
Subject: Re: Newbie question about system function
Message-Id: <Pine.GSO.3.96.970918094000.8611O-100000@julie.teleport.com>
On Wed, 17 Sep 1997, Kenneth G. Markus wrote:
> Newsgroups: comp.lang.perl.misc, comp.lang.perl
If your news administrator still carries comp.lang.perl, please let him
or her know that that newsgroup has not existed since 1995. If you
have such an outdated newsgroup listing, you are probably missing out
on many other valid newsgroups as well. You'll be doing yourself and
many others a favor to use only comp.lang.perl.misc (and other valid
Perl newsgroups) instead.
> Subject: Newbie question about system function
Contrary to popular belief, it's not necessary to use the word "newbie" in
the subject line. We can always figure it out. :-)
> I'm working on a script that contains a simple call to the system
> function:
>
> system ("c:/Winzip/winzip32.exe", " -min", " -a", " c:/ross.zip", "
> c:/web/wwwroot/pdf/pit.pdf\n");
>
> which doesn't work.
When you say it doesn't work, what do you mean? Do you mean that it calls
the program, but the program doesn't do what you want? Do you mean that it
doesn't call the program? Do you mean that it calls the wrong program? Do
you mean that it calls the right program with the wrong arguments? Do you
mean that it doesn't do anything? Do you mean that it stops and prints a
diagnostic message that you don't understand? Do you mean that it stops
and prints a diagnostic message that you do understand? Do you mean that
it makes smoke come out of the back of your computer? :-)
All that said, do you know that you have some unusual characters in your
parameters? For example, I see three spaces and two newlines, at least.
That's quite odd...
> Now does system ("c:/Winzip/winzip32.exe -min -a c:/ross.zip
> c:/pit.pdf\n");
That one "doesn't work" either? Maybe it's that trailing newline that it
doesn't like.
> The statement, however, does work at the command line.
Which one? The statement corresponding to that last call?
> Basically, I need help with a system call to zip files. I've been
> struggling and any help would be greatly appreciated.
Maybe there's a module which works with zip files. If there isn't, maybe
there should be. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 18 Sep 1997 10:04:23 -0400
From: Pat Garverick <dvpgg@landmark.com>
Subject: Re: Perl and WINNT4.0
Message-Id: <342134E7.106@landmark.com>
We've been running perl scripts on Windows NT 4.0 for a couple of
months and no problems have been experienced with the systems due to
the Perl scripts.
Regarding your question of starting programming, I'd recommend
getting a good Perl book and starting from the basics.
Two excellent books:
Cross Platform Perl for Unix and Windows NT
Eric F. Johnson
MS&T Books
Learning Perl on Win32 Systems
Randal L. Schwartz, Erik Olson & Tom Christiansen
O'Reilly & Associates, Inc.
Scott Balneaves wrote:
>
> I have been told that Perl programming can cause problems on NT 4.0, any
> truth behind this and second of all where is the best place to start
> programming.
>
> Basically I need to learn how to put a database online using a perl
> script to access it.
>
> thanks
> cheers
> Scott
> chaos@futurenet.co.za
------------------------------
Date: Thu, 18 Sep 1997 11:35:30 -0400
From: brunsman.3@pop.service.ohio-state.edu (August Brunsman)
Subject: Perl CGI Win-httpd problem
Message-Id: <brunsman.3-1809971135300001@ts5-7.homenet.ohio-state.edu>
Hello Perl Gurus, I am having a bit of a confusing problem, and I was
wondering if any of you might be able to offer a helping hand.
About a month ago I installed Win-httpd on a 486DX-33 running Win 3.1, I
also installed (via the instructions at
http://www.winternet.com/~plp/cgi-dos.html) Perl on it. I got it running
pretty quickly and didn't have any problems with it. I went about
devloping my package without any major problems for quite some time.
However, when I tried to move what I had done on that first machine to
another machine (the one that it turns out is going to be the server) my
Perl scripts don't run. I keep getting told that the PerlVM can't startup
due to a problem wiht its PIF file.
All the directory names are the same, I copied all the .cnf files and the
.pif file from the working machine to the new one, yet I cannot get my old
scripts to work. Some of the old pages and scripts did use the IP of the
old machine, but I have changed them all.
I have also stepped through the instructions at
www.winternet.com/~plp/cgi-dos.html many times.
However, I still get told
"Start-up directory not found.
Check the applicaiton's PIF to ensure the directory is correctly specified."
I have--It is.
But I keep getting the message.
Thanks for any help you might be able to offer.
Be well
August Brunsman
brunsman.3@osu.edu
------------------------------
Date: 18 Sep 1997 11:43:15 -0500
From: r_a_m_l_i@csc.ti.com
Subject: Returning hashes of arrays from a subroutine
Message-Id: <fhn2lah8t8.fsf_-_@csc.ti.com>
#-----------------------------------------------------------------------------
# Remove underscores from my name if you want to also mail me a copy of your
# response. Thanks.
#-----------------------------------------------------------------------------
I have a subroutine that creates two hashes of arrays: %common and %non_common.
I want each of them to be returned to the main program. One solution is to
keep the variables as global; if possible, I want to avoid doing this.
The following won't work:
subroutine: return (%common, %non_common);
main prog : (%cmn, %ncmn) = &process_file($hg_file);
because %cmn will hog the returned array in its entirety, leaving %ncmn
empty.
Is the solution then to return references to the associative arrays in the
subroutine ? In that case, can the variables %common and %non_common be
"my" variables in the subroutine ? Any help on the syntax of returning
references from a subroutine would be much appreciated.
Thanks!
------------------------------
Date: 18 Sep 1997 10:39:47 -0700
From: mcravit@best.com (Matthew Cravit)
Subject: Re: Returning hashes of arrays from a subroutine
Message-Id: <5vrp13$gtv$1@shell3.ba.best.com>
In article <fhn2lah8t8.fsf_-_@csc.ti.com>, <r_a_m_l_i@csc.ti.com> wrote:
>subroutine: return (%common, %non_common);
>main prog : (%cmn, %ncmn) = &process_file($hg_file);
>
>Is the solution then to return references to the associative arrays in the
>subroutine ? In that case, can the variables %common and %non_common be
>"my" variables in the subroutine ? Any help on the syntax of returning
Yes, and yes.
If you do
subroutine: return (\%common, \%non-common);
main: ($cmnref, $ncmnref) = &process_file($hg_file);
then $cmnref will be a reference to %common, and $cmnref will be a reference
to %non-common, and you can dereference them and everything will work fine.
Actually, technically $cmnref will be a reference to an anonymous hash
containing all of the data that was in %common, and likewise with $mcmnref,
but the net effect is the same.
Hope this helps.
/MC
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@taos.com (work) | time you make it.
------------------------------
Date: 18 Sep 1997 07:43:22 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Rounding numbers problem
Message-Id: <5vrb5q$29t@flatland.dimensional.com>
"David R. Nurse" <david.nurse@ndcb.ox.ac.uk> writes:
> I need to round some numbers to different numbers of decimal places and
> then to the nearest half, e.g.
Answered in the Perl FAQ:
http://language.perl.com/faq/
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Thu, 18 Sep 1997 15:35:04 +0200
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: Rounding numbers problem
Message-Id: <34212E08.31DF@theo.phy.uni-bayreuth.de>
Hi,
David R. Nurse wrote:
>
> I need to round some numbers to different numbers of decimal places and
> then to the nearest half, e.g.
>
> to 2 decimal places:
> 1.34456 becomes 1.35
> 2.57876 becomes 2.60
>
> to 1 decimal place:
>
> 1.34456 becomes 1.5
> 2.57876 becomes 2.5
>
> any of you Perl experts think of an easy way of doing this ?
For rounding problems 'sprintf' is always your friend ... ;-)
Try this formula (I didn't do much testing - so don't blame me, if
it still contains a bug [ask a mathematician in such a case]):
$rounded = sprintf("%.${places}f",$number/5)*5
Bye, Eike
--
======================================================================
Eike Grote, Theoretical Physics IV, University of Bayreuth, Germany
----------------------------------------------------------------------
e-mail -> eike.grote@theo.phy.uni-bayreuth.de
WWW -> http://www.phy.uni-bayreuth.de/theo/tp4/members/grote.html
http://www.phy.uni-bayreuth.de/~btpa25/
======================================================================
------------------------------
Date: Thu, 18 Sep 1997 09:42:52 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Rounding numbers problem
Message-Id: <clerv5.as8.ln@localhost>
David R. Nurse (david.nurse@ndcb.ox.ac.uk) wrote:
: I need to round some numbers to different numbers of decimal places and
: then to the nearest half, e.g.
: to 2 decimal places:
: 1.34456 becomes 1.35
^^^^ 1.34 would be the normal rounded value...
: 2.57876 becomes 2.60
^^^^ 2.58 for this one
Are you using a variant definition of 'round'? ;-)
: to 1 decimal place:
: 1.34456 becomes 1.5
: 2.57876 becomes 2.5
: any of you Perl experts think of an easy way of doing this ?
To round to the nearest half, double it, round to the nearest whole,
and half it ;-)
---------------------
#!/usr/bin/perl -w
$_ = 2.57876 * 2;
$_ = sprintf("%6.0f\n", $_) / 2;
print "$_\n";
---------------------
Haven't given it much thought, but the above seems to work...
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 Sep 1997 09:55:30 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: John Thomas Mosey <mosey@alpha3.csd.uwm.edu>
Subject: Re: Something of the day script
Message-Id: <Pine.GSO.3.96.970918095316.8611P-100000@julie.teleport.com>
On 18 Sep 1997, John Thomas Mosey wrote:
> Does anyone out there know of a daily rotation script program. For
> example, quote of the day or picture of the day?
Sure; you can find lots of those on Yahoo or another search engine.
> I'm not looking for a random roation, I'd like everyone to see the same
> thing for one 24 hour period. I'd just like to program the quotes and
> pictures for a month period at a time.
>
> Email me with any information you may have, please.
If you can't find a ready-made script to do what you want, I'd recommend
writing it in Perl. Start with the docs and FAQs, and any good books like
the ones recommended in the perlbook(1) manpage. If you have Perl
questions after reading those references, please ask them here. Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 18 Sep 1997 13:37:22 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Text::Wrap bombs on lines with no white space!
Message-Id: <EGpHuB.AzM@world.std.com>
jase@cadence.com writes:
>What I need is something that will insert a newline at the last whitespace
>character on a line before the wrap column, *or* if no such character is
>found the newline should simply be placed at the wrap column position. Is
>there such a function?
You could use the substitution operator with the appropriate regular
expression:
s/(.{1,$wrap_length}\s|.{$wrap_length})/$1\n/og;
Find 1 to $wrap_length characters followed by a space character, or a
full $wrap_length characters. Replace what was found by itself,
followed by a newline.
--
Andrew Langmead
------------------------------
Date: Thu, 18 Sep 1997 09:38:31 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: jase@cadence.com
Subject: Re: Text::Wrap bombs on lines with no white space!
Message-Id: <Pine.GSO.3.96.970918093723.8611N-100000@julie.teleport.com>
On Wed, 17 Sep 1997 jase@cadence.com wrote:
> I have a Perl script that reads in a file of text, and then displays that
> text wrapped to 80 columns. Text::Wrap works most of the time, except when
> there's a line that contains 80 non-white-space characters all in a row.
> In that special case, the call to wrap() causes the script to exit with
> the error:
>
> couldn't wrap 'blablabla...' /usr/local/lib/perl5/Text/Wrap.pm line 87.
>
> What I need is something that will insert a newline at the last whitespace
> character on a line before the wrap column, *or* if no such character is
> found the newline should simply be placed at the wrap column position. Is
> there such a function?
Why don't you patch Text::Wrap to offer such a function? Contact its
author and work with him or her to make the next version do what you want.
Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 18 Sep 1997 16:05:13 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: The CSV format stinks!
Message-Id: <EGpoop.I6K@world.std.com>
daniel@aksi.net (Daniel Freeman) writes:
>We can even have quotes inside our quotes, oddly, like so:
> "MY 3.5" DISK","MY 5" INCH FLOPPY","MY 10" RECORD"
For this particular case, would it help to strip off the first and
last quote and then split on /","/.
Then the only fields that it would mess up on would be something like
""Just Drive","she said"","Stan Ridgway"
which would be hard to find.
--
Andrew Langmead
------------------------------
Date: Thu, 18 Sep 1997 10:58:33 -0400
From: Benjamin Day <benday@ultranet.com>
Subject: usage of gethostbyaddr
Message-Id: <34214199.5760@ultranet.com>
I have the o'reilly "programming perl" book by wall & schwartz and
although the book has helped me 95% of the time it isn't helping right
now.
The documentation for gethostbyaddr doesn't make much sense to me.
It says that the function takes the arguements (ADDR,ADDRTYPE). What
are ADDR and ADDRTYPE? Where do I get the values?
How do I grab the values returned by the function?
Please drop me an email if you know the answer or have a functioning
example!
-Ben Day
benday@ultranet.com
------------------------------
Date: Thu, 18 Sep 1997 10:35:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Benjamin Day <benday@ultranet.com>
Subject: Re: usage of gethostbyaddr
Message-Id: <Pine.GSO.3.96.970918101630.8611W-100000@julie.teleport.com>
On Thu, 18 Sep 1997, Benjamin Day wrote:
> The documentation for gethostbyaddr doesn't make much sense to me.
>
> It says that the function takes the arguements (ADDR,ADDRTYPE). What
> are ADDR and ADDRTYPE? Where do I get the values?
>
> How do I grab the values returned by the function?
Perl offers a way to call many functions which are either library
functions (as this one is) or which are system calls. In each case, your
system's docs should tell how they work.
In this case, though, there's a little more to the story. :-) That is,
you could spend all day tracking through docs and more docs, so I'll save
you a little time.
First, the address. That is a "packed-format" address, which generally
means that it's squeezed down to four bytes. This is normally done with a
function called inet_aton(), which you can get from the Socket module.
Then the ADDRTYPE. This is normally a constant called AF_INET which is
defined in your system's socket.h file. But don't look there; that's just
where C programmers go to get it. Perl people get that from the Socket
module.
As for the return value, that's documented in the perlfunc(1) manpage,
which has this (somewhat cryptic) line:
($name,$aliases,$addrtype,$length,@addrs) = gethost*
That's saying that all of the gethost* family of functions return the same
list of information (when called in a list context). In a scalar context,
gethostbyaddr will return the host's name.
Now, having said that, let's see some code!
use Socket; # Defines AF_INET and inet_aton(), among others
my $address = '18.72.0.3';
my $name = gethostbyaddr(inet_aton($address), AF_INET);
if (not defined $name) {
warn "Couldn't find name for $address - reverse DNS problem?";
} else {
print "$address is $name\n";
}
For more info, check your system's manpages, and the docs for Socket.pm.
You may also be interested in using a module like Net::DNS, which can
provide you with even more DNS-type info. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 18 Sep 1997 15:45:09 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Win32 Perl FAQ Addition? (WAS Re: Is Perl for Win32 really as brain damaged as it seems?)
Message-Id: <EGpnrA.MMq@world.std.com>
Tom Phoenix <rootbeer@teleport.com> writes:
>Well, I was thinking of making it a command-line option whether to ask or
>simply automatically to delete those refs. By default, it should nuke them
>all, IMHO.
But there are some reasons why some programs might intentionally put a
registry entry that contains a path to a removable drive.
HKEY_LOCAL_MACHINE\\Software\\somecompany\\someprogram\\InstallPath
pointing to the place where optional components may be re-installed or
HKEY_LOCAL_MACHINE\\Software\\somecompany\\cryptoprogram\\PrivateKeyLocation
pointing to a file containing the users private key.
--
Andrew Langmead
------------------------------
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 1044
**************************************