[6420] in Perl-Users-Digest
Perl-Users Digest, Issue: 45 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 4 02:07:17 1997
Date: Mon, 3 Mar 97 23:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 3 Mar 1997 Volume: 8 Number: 45
Today's topics:
Advanced cookie question. <bildun@vci.net>
Re: advice needed (Mike Zorn)
Re: ANYONE COMPILE PERL 5.003 FOR LINUX? <rootbeer@teleport.com>
Re: Beginner - simple problem <rootbeer@teleport.com>
Re: Beginner - simple problem (Mike Zorn)
Re: Calling PGP from a Perl CGI script <rootbeer@teleport.com>
Can't run Perl from Win95 DOS command prompt? (Fred Elbel)
Comm.pl client/server woes khawkins@ncsa.uiuc.edu
Re: Creating a new empty file from within Perl.. (Dave Thomas)
Re: Creating a new empty file from within Perl.. <bildun@vci.net>
Re: File reading error <rootbeer@teleport.com>
ftp.pl - Protocol not supported <klg@westweb.com>
How can I use #! w/o knowing where perl lives? <hargrove@sccm.Stanford.EDU>
Re: How to spam - legitimately (Mike Zorn)
Re: Inline subroutines? <rootbeer@teleport.com>
Re: Inline subroutines? (Abigail)
Re: Interview With The Internet's Wise Guys Of Perl - W <dbenhur@egames.com>
Re: IP Address to Host Name code WANTED <rootbeer@teleport.com>
Re: Is it possible to alias a builtin function??? <roderick@argon.org>
Joining next line with previous line <mrdr@usa.net>
Re: Joining next line with previous line (Abigail)
More weird regular expressions. <riekhof@primenet.com>
Re: More weird regular expressions. (Ilya Zakharevich)
need some help here <surber@earthlink.net>
Re: Numeric value expected... <rootbeer@teleport.com>
Re: Perl filehandling <roderick@argon.org>
Re: Perl filehandling (Mike Zorn)
Re: Public domain DES and other crypto code in Perl? (Paul Rubin)
Update: New Perl Module: Fraction (Kevin Atkinson)
Re: Where is Perl-Win32 documentation <billc@tibinc.com>
Re: Which one is the best (pattern matching) (Abigail)
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 4 Mar 1997 05:58:32 GMT
From: "Bill Dunn" <bildun@vci.net>
Subject: Advanced cookie question.
Message-Id: <01bc2858$db1d60e0$8c81cecf@p133.bildun.com>
I know how to do cookies easily from a perl script or C program but I
haven't been able to send a cookie when another document is being loaded.
I've been trying to call a perl script or C program from a server side
include. The SSI runs the CGI but instead of doing a traditional cookie the
whole "Set-cookie: expires=...path=..." header gets put into the document
as regular text.
I'm sure there's a way something like this can be done. It seems that the
LinkExchange does something like this with those banners you see
everywhere.
Can anyone help?
I'd appreciate an email, please. Thanks.
------------------------------
Date: 3 Mar 1997 22:16:59 -0800
From: rigoleto@kaiwan009.kaiwan.com (Mike Zorn)
Subject: Re: advice needed
Message-Id: <5fgeor$9q@kaiwan009.kaiwan.com>
In <5f4dia$466$1@seva.mdx.ac.uk> kc079@mdx.ac.uk (kent) writes:
>1) The O/S environment I am working with is Unix, do I need a server
>to run the Perl script ? Can I run it on my PC ?
Perl is a standalone language, so you can run Perl programs without
a server. For your project, though, they probably need to be run from
a web page, in which case, yes, you need some sort of server. It can
be a personal web server, which is just a server that runs on your PC,
and which talks to Netscape (or that other one). (Netscape makes a
personal web server, 'FastTrack', which you can get from their site.)
There are other good ones.
>2) Which editor in Unix should I use for writing Perl script ?
[smart-aleck answer:] vi (I know, there's teco and pico and Quark
Express (probably a little overkill...))
[more reasonable] Any text editor that saves files as just text.
Since you've got UNIX, vi is just fine. I use it every day at work as
a program source editor. If you're running on a PC and are in Windows
a lot, Notepad or Wordpad will also work.
>3) What else do I need and know in order to do the research ?
[trying here to be helpful] How to use search features on Alta
Vista, InfoSeek and the rest. Read this and the
comp.infosystems.www.authoring.cgi groups for a week or two. If you
have a paper due next Tuesday, I don't think we can help.
If you're near a good bookstore, browse the computer bookshelves
for books on making web pages.
A lot of the really nice interactive web stuff is done in Javascript
and Java, but we don't talk about that here.
Mike Zorn rigoleto@kaiwan.com
http://www.kaiwan.com/~rigoleto/
"As the most participatory form of mass speech yet developed, the
Internet deserves the highest protection from governmental intrusion."
- - U. S. District Judge Stewart Dalzell
------------------------------
Date: Mon, 3 Mar 1997 20:41:06 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Larry <Larry@softech-consulting.com>
Subject: Re: ANYONE COMPILE PERL 5.003 FOR LINUX?
Message-Id: <Pine.GSO.3.95q.970303203215.11970N-100000@kelly.teleport.com>
On Mon, 3 Mar 1997, Larry wrote:
> Subject: ANYONE COMPILE PERL 5.003 FOR LINUX?
No need to shout! :-)
> Has anyone successfully compiled PERL 5.003 for LINUX?
Yes.
> I've tried about 100 different response sets for Configure.sh, and
> no matter what I do, I get the following message toward the end of
> the first make process:
>
> make: *** [makefile] Error 2
Usually you can tell Configure to go with the defaults. This should work
on most Linux systems, so long as you're not running out of memory or disk
space.
./Configure -ders
If you've really tried this 100 different times, I'd say to play it safe
and use that command upon a newly-unpacked source. That will almost always
get you a working Perl, although it may get, some details wrong. For that
sort of thing, you can edit config.sh and use './Configure -S' to
propagate the changes as needed.
When you're done, be sure to 'make test' to see that everything is working
correctly. If you get any Linux-specific error messages, it's likely that
someone on a Linux-specific newsgroup will be able to be of assistance.
Also, the file hints/linux.sh (or something like that) should have good
advice.
Good luck!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Mon, 3 Mar 1997 20:31:24 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark Turner <turnerm@cs.man.ac.uk>
Subject: Re: Beginner - simple problem
Message-Id: <Pine.GSO.3.95q.970303202048.11970M-100000@kelly.teleport.com>
On 3 Mar 1997, Mark Turner wrote:
> In my program I need the directory path.
You may (or may not) find what you seek in 'perldoc Cwd'. I encourage you
to check it out before using the solution below.
> I am trying to use the UNIX pwd command from perl, using the system()
> command, and trying to put the result into a variable $original_dir.
Maybe backticks would make you happier? They redirect the stdout of a
program into a variable. It's common to chomp the output, unless you wish
to keep the trailing newline.
chomp( $original_dir = `pwd` ) ;
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 3 Mar 1997 22:35:51 -0800
From: rigoleto@kaiwan009.kaiwan.com (Mike Zorn)
Subject: Re: Beginner - simple problem
Message-Id: <5fgfs7$1do@kaiwan009.kaiwan.com>
In <5fedfo$vv@m1.cs.man.ac.uk> turnerm@cs.man.ac.uk (Mark Turner) writes:
>I am a newcomer to perl and as much I am enjoying using perl I have a
>In my program I need the directory path.
>system("pwd >$original_dir");
>system("(pwd; >$original_dir &");
(This one should give a syntax error)
What the machine will try to do with your first one is run the
command
pwd > whatever
where whatever is contained in the variable $original_dir: it writes
the name of the present working dir into the file 'whatever'.
You could then read the file 'whatever' into a variable, but I think
this fails the elegance test.
You might try
$original_dir = `pwd`;
The back-tics `xxx` say: run the command xxx, gather up the output (if
any), and return the result (which is then avalible to the = operator).
There's a lot of similarity betwwen system(xxx) and `xxx`, at
least as far as the observer of the program can tell. I suspect that
the internals may be somewhet different.
[Question for someone else: does `xxx` do a fork?]
Mike Zorn rigoleto@kaiwan.com
http://www.kaiwan.com/~rigoleto/
"As the most participatory form of mass speech yet developed, the
Internet deserves the highest protection from governmental intrusion."
- - U. S. District Judge Stewart Dalzell
------------------------------
Date: Mon, 3 Mar 1997 19:33:11 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Martin_Khoo/SIN/Lotus@crd.lotus.com
Subject: Re: Calling PGP from a Perl CGI script
Message-Id: <Pine.GSO.3.95q.970303192924.11970D-100000@kelly.teleport.com>
On Mon, 3 Mar 1997 Martin_Khoo/SIN/Lotus@crd.lotus.com wrote:
> I am trying to write a web frontend for PGP.
Have you seen the modules in CPAN for interfacing with PGP? (Or, for that
matter, for interfacing with the web?)
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
> The problem i am facing now is that when
> pgp is called I get the following error :
>
> Preparing random session key...
> We need to generate 192 random bits. This is done by measuring the
> time intervals between your keystrokes. Please enter some random text
> on your keyboard until you hear the beep:
That sounds like a problem with PGP, rather than with Perl. Have you
looked in the PGP newsgroups (or their FAQs)? Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Tue, 04 Mar 1997 05:04:52 GMT
From: __felbel@csn.net__ (Fred Elbel)
Subject: Can't run Perl from Win95 DOS command prompt?
Message-Id: <331ba72f.24354397@news-2.csn.net>
I have installed Perl under Win95.
The version is ActiveWare Perl 5.03 for Windows95 (Win32)
(Build 302 - Dec. 13, 1996).
When I try to run from a DOS command prompt line (a DOS window), the
response is "This program can not be run in DOS mode.". According to
several posts, and section 1.14 of Evangelo Prodromou's FAQ, Perl
should run OK from the command line.
I *can* run Perl from explorer by clicking on a Perl source file (and
I can compile from within my MultiEdit editor). So I do think Perl is
installed completely and correctly, and I have reinstalled a few
times.
So am I missing a major concept here, or is there perhaps a registry
setting that got hozed? Thanks much for any and all help!
-- Fred Elbel felbel@csn.net
------------------------------
Date: Mon, 03 Mar 1997 23:21:10 -0600
From: khawkins@ncsa.uiuc.edu
Subject: Comm.pl client/server woes
Message-Id: <857452558.8293@dejanews.com>
Well, let me first point out that I'm using Perl 5.003 on a SunOS 4.1.4
sun4c machine.
I'm having trouble getting my client to communicate properly to my server.
However, the problem is minimal, and I'd venture to guess that it's
something sitting right in front of my face, though perlipc, deja news,
the Perl FAQ, etc., have not made it clear to me.
The problem is this: My client is supposed to read lines out of an input
file, and send them to the server, which, at this point, is supposed to
echo them to the screen. Simple, right? Well, it worked just fine when
my input filehandle was STDIN, but when I changed that to an input file
filehandle, the server would not echo the output lines unless I hit
<Return> for each line of input in the client window...and the client is
running as a daemon??? The client procedure is listed below. It
interfaces just
fine with the server. It's pretty much the client example given in the
examples at the end of the Comm.pl package, except that it reads from a
file instead of STDIN. Any help would be greatly appreciated.
TIA,
Kevin Hawkins
require "Comm.pl";
&Comm'init;
sub submit_to_server {
local($Server_handle, $SERVER, $PORT, $handle, @ready_handles,
$buffer);
$SERVER = "my.server.machine.com";
$PORT = 5050;
$| = 1;
open(INPUT, "/tmp/temp_file") || die "Can't open input: $!\n";
$Server_handle = &open_port("$SERVER", $PORT, 5);
die "Couldn't connect to server: $!\n" unless $Server_handle;
$done = 0;
while (!$done) {
@ready_handles = &select_it(5, $Server_handle, INPUT);
foreach $handle (@ready_handles) {
if ($handle eq "INPUT") {
if ($buffer = <INPUT>) {
chop($buffer);
print $Server_handle "$buffer\n" ||
die "Could not print buffer to $SERVER";
} else {
close(INPUT);
$done = 1;
}
} else { # The server handle
unless (sysread($handle, $buffer, 1000)) {
&Comm'close($handle);
die "The connection to $SERVER was broken.";
}
print $buffer;
}
}
}
&Comm'close($Server_handle);
}
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 4 Mar 1997 04:14:39 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Creating a new empty file from within Perl..
Message-Id: <slrn5hn86v.pf.dave@fast.thomases.com>
On 3 Mar 1997 22:54:49 GMT, Aegir <ByeBye@www.dma.be> wrote:
>
> Following problem :
>
> I'm writing a little CGI in perl (works perfectly..). But one of the things I
> need is to create a none existing new file (a new one for each new
> user). I can't do this with the open command, which will die when I
> open a none existing file..
open(F, ">newfile") or die "Error opening newfile: $!";
The '>' at the front of the name will create a new file or empty an existing
one. If it doesn't work for you, then you've probably got a permissions
problem.
Regards
Dave
--
_________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: 4 Mar 1997 05:46:23 GMT
From: "Bill Dunn" <bildun@vci.net>
Subject: Re: Creating a new empty file from within Perl..
Message-Id: <01bc2857$2838ad00$8c81cecf@p133.bildun.com>
Have you tried doing a system command using the unix program "touch". You
could do:
system("touch /home/username/blankfile.name");
> I'm writing a little CGI in perl (works perfectly..). But one of the
things I
> need is to create a none existing new file (a new one for each new
> user). I can't do this with the open command, which will die when I
> open a none existing file..
>
> Ok, how do I create a new file from within perl ? It's running on an
> UNIX server...Would this mean I have to send an UNIX command like
> ? If yes, what command ? I can't find one..
>
> On the other hand..It's probably me, not noticing which powerfull
> command Perl has hidden somewhere for me to create a file ...
>
> Anyone can help me out with this one...Source (small) would be
> appreciated..
>
> --
> Wondering where and how it started...
> Bugs !....
>
> Warning ! Return Email address is changed to fool junk mail: return
> through mail at Aegir@www.dma.be
>
------------------------------
Date: Mon, 3 Mar 1997 21:27:08 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Joe Kline <Joe.Kline@sdrc.com>
Subject: Re: File reading error
Message-Id: <Pine.GSO.3.95q.970303212334.11970R-100000@kelly.teleport.com>
On Mon, 3 Mar 1997, Joe Kline wrote:
> background details: perl4 script being run through a cron job
> opening a file and writing to it
Version four? Eek! :-)
> Read on closed filehandle <MASTERREP> at line 242
Maybe the filehandle is closed? Just maybe? :-)
> 238 open(MASTERREP,"<$file");
Hmmm... Maybe that open is failing. Here's one way to find out.
open(MASTERREP,"<$file") || die "Can't open '$file': $!";
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Mon, 03 Mar 1997 18:35:40 -0800
From: "Kevin L. Gross" <klg@westweb.com>
Subject: ftp.pl - Protocol not supported
Message-Id: <331B8A7C.41C67EA6@westweb.com>
Hi,
I used ftp.pl, chat2.pl and sys/socket.ph to write an automated ftp
script in Perl5. It works flawlessly on BSDI, but when I try to run it
between two Sun machines (solaris->sunos) or (solaris->solaris) I get
this error:
Protocol not supported at ./myprog line 64.
Any idea what is going on here?
-Kevin
------------------------------
Date: Mon, 03 Mar 1997 20:03:31 -0800
From: "Paul H. Hargrove" <hargrove@sccm.Stanford.EDU>
Subject: How can I use #! w/o knowing where perl lives?
Message-Id: <331B9F13.41C67EA6@sccm.Stanford.EDU>
I am currently working on a perl script that needs to run on a few
different UN*X systems (with perl versions 4 and 5) on which I have
accounts. Unfortunately the perl interpreter is located in different
directories on different systems. My home directory is different on
different systems so using a symbolic link to the interpreter won't work
either (since I don't have a consistent place to put it). I am
currently using the following method:
#!/bin/sh
#
# Stupid hack for running a perl script without knowing the path to perl
#
PATH=/bin:/usr/bin:/usr/bin/X11:/usr/local/bin:/usr/subsw/bin
export PATH
exec perl -- - ${1+"$@"} 3<&1 <<'__EOF__'
# -------- The perl script starts here --------
# reacquire stdin, which was dup()ed to descriptor 3
open(STDIN, "<&3");
close(3);
...BODY OF PERL SCRIPT...
__EOF__
There are two problems I notice with this method. The first is that
warn and die think that the script is named '-'. If I modify the exec
line to be
exec perl -- - $0 ${1+"$@"} 3<&1 <<'__EOF__'
and put
$0 = shift;
in the perl script, then ps is fooled, but die and warn are not. How
can I get around this? It would also be nice if I could tell warn and
die to add 7 to their line counts.
The second has to do with the way I dup stdin to file descriptor 3 so
that perl can get to it (so my script can take '-' as a filename
argument.) The problem witht he current method is that if stdin is
closed in the parent, then the shell will fail to dup stdin, and won't
even try to run perl. I know that this is a shell problem, not a perl
problem, but I have better hopes for a perl soultion than a shell
solution.
Any better ideas (I'm sure there are some) on how to handle this problem
would be appreciated. However I don't want to split the script into two
files.
--
Paul H. Hargrove All material not otherwise attributed
hargrove@sccm.stanford.edu is the opinion of the author or a typo.
------------------------------
Date: 3 Mar 1997 21:55:07 -0800
From: rigoleto@kaiwan009.kaiwan.com (Mike Zorn)
Subject: Re: How to spam - legitimately
Message-Id: <5fgdfr$rjj@kaiwan009.kaiwan.com>
In <8cvi7itdjw.fsf@gadget.cscaper.com> Randal Schwartz <merlyn@stonehenge.com> writes:
>>>>>> "Terry" == Terry Carroll <carroll@tjc.com> writes:
>Terry> On 22 Feb 1997 05:09:42 GMT, Tom Christiansen <tchrist@mox.perl.com>
>>> In comp.lang.perl.misc, Valdis Kletnieks <valdis.kletnieks@vt.edu> writes:
>Terry> It's pretty common now to hear "email" as a noun. "eletter" would be an
>again. :-)
>So, there's no such word as "emails".
[newsgroups clipped to c.l.p.m., 'cause this really doesn't have
anything to do with any of them, but Randal touched it last.]
I agree. (Though I have been known to work on several CGIs
simultaneously. In Perl. Of course)
'emails' is equivalent to 'deers'; an unnecessary plural.
Unfortunately, it is an uphill battle (see Sisyphus). This morning
someone said in a newsgroup, "I'm webmastering a site...". Maybe he's
pursuing the art of webmastery.
Mike Zorn rigoleto@kaiwan.com
http://www.kaiwan.com/~rigoleto/
"As the most participatory form of mass speech yet developed, the
Internet deserves the highest protection from governmental intrusion."
- - U. S. District Judge Stewart Dalzell
------------------------------
Date: Mon, 3 Mar 1997 19:44:55 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Markus Laker <mlaker@contax.co.uk>
Subject: Re: Inline subroutines?
Message-Id: <Pine.GSO.3.95q.970303193353.11970E-100000@kelly.teleport.com>
On Mon, 3 Mar 1997, Markus Laker wrote:
> Are you thinking of C++'s ability to inline functions for you? That
> isn't quite what the writers of the Camel had in mind. In Perl you
> have to do the job yourself.
...except that in the upcoming 5.004, some function calls may be inlined
by perl. If a function call has an empty prototype, and if it's called
with the new-style &-less syntax, and if Perl can tell at compile time
that it has a constant return value, then that value will be used in place
of a subroutine call.
sub PI () { 4 * atan2 1, 1 }
sub circumference ($) { 2 * PI * $_[0] }
sub area ($) { PI * $_[0] ** 2 }
The first sub will calculate a value for pi at compile time, and that
value will be inlined into the other subs, when you use 5.004. Cool, huh?
Coming soon in beta form to a server near you!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Tue, 4 Mar 1997 05:35:31 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: Inline subroutines?
Message-Id: <E6I7J7.KxK@nonexistent.com>
On Mon, 3 Mar 1997 19:44:55 -0800, Tom Phoenix wrote in comp.lang.perl.misc:
++ On Mon, 3 Mar 1997, Markus Laker wrote:
++
++ > Are you thinking of C++'s ability to inline functions for you? That
++ > isn't quite what the writers of the Camel had in mind. In Perl you
++ > have to do the job yourself.
++
++ ...except that in the upcoming 5.004, some function calls may be inlined
++ by perl. If a function call has an empty prototype, and if it's called
++ with the new-style &-less syntax, and if Perl can tell at compile time
++ that it has a constant return value, then that value will be used in place
++ of a subroutine call.
Surely the function shouldn't have side effects either?
Abigail
------------------------------
Date: Mon, 03 Mar 1997 19:13:22 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
Subject: Re: Interview With The Internet's Wise Guys Of Perl - Web Week
Message-Id: <331B9352.4B04@egames.com>
Dave Thomas wrote:
> On Sun, 02 Mar 1997 14:09:49 -0800, Devin Ben-Hur <dbenhur@egames.com> wrote:
> > Well, this was the third time I got sucked into trying their
> > web-page in responce to a "spam" posting here and it was the
> > third time I couldn't find any reference to the interesting
> > article title they advertised.
>
> To be fair, it was there, and when you followed the link there was the
> interview, both in text and RealAudio.
To be fair, I'll admit the article was there 2 days *after*
the posting first showed up on my newsserver.
And yes it was an interesting interview and I'm glad
I eventually tracked it down.
It most certainly was not there immediately after I saw
the posting. I went there, I carefully scanned their article
index and didn't see it. I searched with my browser's
Find... command for 'perl' and 'wise' with case-insensitivity.
no match. I used their search engine at the bottom of the page.
no match.
As someone else pointed out, their announcements here
have been well targetted, not *spam*. That's probably why
I've tried to follow three of them. All three times,
I couldn't find the announced article at the time I first
saw the announcement -- apparently they send their news
posts before they update their web site.
I don't mind the announcements. I just wish I could
actually follow them to the interesting article(s) they're
announcing. I also wish they would link directly to
the articles and not to that gawdawful long index page.
--
Devin Ben-Hur <dbenhur@egames.com>
eGames.com, Inc. http://www.egames.com/
eMarketing, Inc. http://www.emarket.com/
"Sometimes you just have to step in it and see if it stinks" O-
-- Sonia Orin Lyris
------------------------------
Date: Mon, 3 Mar 1997 19:54:02 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark Perkins <mark@weymouth.gov.uk>
Subject: Re: IP Address to Host Name code WANTED
Message-Id: <Pine.GSO.3.95q.970303194602.11970F-100000@kelly.teleport.com>
On Mon, 3 Mar 1997, Mark Perkins wrote:
> Should'nt this work?
>
> $host = gethostbyaddr($ENV{'REMOTE_HOST'}, AF_INET);
> print "$host\n";
Only if you've remembered to set AF_INET to the correct value for your
system, and if $ENV{'REMOTE_HOST'} is in the right format for that
function.
Fortunately, these are both easy to do: Put 'use Socket;' near the top of
your script; that will set AF_INET for you. And if $ENV{'REMOTE_HOST'} is
not already in packed form (and it probably isn't), use inet_aton to
convert it. Something like this...
use Socket;
$host = gethostbyaddr( inet_aton("192.108.254.11"), AF_INET );
print "$host\n";
'perldoc Socket' should tell you more. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 3 Mar 1997 22:16:04 -0500
From: Roderick Schertler <roderick@argon.org>
To: "Freeman P. Pascal IV" <pascal@pascal.org>
Subject: Re: Is it possible to alias a builtin function???
Message-Id: <pz209w73mx.fsf@eeyore.ibcinc.com>
On Mon, 03 Mar 1997 00:52:01 -0800, "Freeman P. Pascal IV" <pascal@pascal.org> said:
>
> I'm trying to do something simular to following:
>
> *panic = \¨
[...]
> *panic = \&warn
> if ($opt_warn);
As the error you get shows, \&die refers to main::die(), just like
\&anysub would refer to main::anysub(). You're free to create your own
subroutine which has the same name as a builtin. If the approach you're
trying to use were to work you'd need to use \&CORE::die there, but that
doesn't work either (it just isn't supported yet).
You'll have to bite the bullet and do something like
sub panic_die { die @_ }
sub panic_warn { warn @_ }
*panic = $opt_warn ? \&panic_warn : \&panic_die;
or more simply (in this specific case)
sub panic {
$opt_warn ? warn @_ : die @_;
}
--
Roderick Schertler
roderick@argon.org
------------------------------
Date: 4 Mar 1997 03:37:49 GMT
From: "Mark Richards" <mrdr@usa.net>
Subject: Joining next line with previous line
Message-Id: <01bc26de$e53b5f80$6c4f45c6@portal.gulf.net>
I have the following script:
while (<>) {
chop;
($f1,$f2)=split(/:/,$_);
if /Owner Address/ {
}
print "$f2";
print "\n";
}
The data is split like this:
dataname : data
dataname : data
all the way to Owner Address which takes two lines like this:
dataname : data
dataname : data
Owner Address : firstline
second line
dataname : data
How can I join the other line and get $f2 joined to the
previous $f2?
I know it can be done with the scalar(EXPR) function but it doesn't
seem to be working. I am also using the join(EXPR, LIST) function
but don't seem to know the correct way to do it.
Help would be greatly appreciated.
Mark Richards
mrdr@usa.net
------------------------------
Date: Tue, 4 Mar 1997 05:46:40 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: Joining next line with previous line
Message-Id: <E6I81s.4nv@nonexistent.com>
On 4 Mar 1997 03:37:49 GMT, Mark Richards wrote in comp.lang.perl.misc:
++ I have the following script:
++
++ while (<>) {
++ chop;
++ ($f1,$f2)=split(/:/,$_);
++ if /Owner Address/ {
++
++ }
++ print "$f2";
++ print "\n";
++ }
++
++ The data is split like this:
++
++ dataname : data
++ dataname : data
++
++ all the way to Owner Address which takes two lines like this:
++
++ dataname : data
++ dataname : data
++ Owner Address : firstline
++ second line
++ dataname : data
++
++ How can I join the other line and get $f2 joined to the
++ previous $f2?
++
++ I know it can be done with the scalar(EXPR) function but it doesn't
++ seem to be working. I am also using the join(EXPR, LIST) function
++ but don't seem to know the correct way to do it.
++
I would do it like this:
$/ = "\n(?!\s)"; # Split the file on newlines *not* followed by whitespace.
while (<>) {
chomp; # Safe form of chop;
($f1, $f2) = split /:/;
if ($f1 =~ /^Owner Address/) {
# Something?
}
$f2 =~ s/\n\s+/ /g; # Change newlines (followed by whitespace) to a space.
print "$f2\n";
}
Abigail
------------------------------
Date: 3 Mar 1997 22:01:02 -0700
From: Darrel Riekhof <riekhof@primenet.com>
Subject: More weird regular expressions.
Message-Id: <331BB930.52E3@primenet.com>
I was toying around with more regular expressions and came up
with this one:
(([a-z])+([A-Z])+)+
with input:
abcABCdefgABChijklmnop
To my suprise, Perl put the following in the backrefs:
\1 "defgABC"
\2 ""
\3 ""
I wouldn't have been suprised if I replaced the '+'s with '*'s.
Anyone know why \2 and \3 are empty?
Badly written perl code below:
------------------------------
$_=abcABCdefgABChijklmnop;
if (/(([a-z])+([A-Z])+)+/) {
print "Matched: ";
print "$_";
print "\n";
print "1=", $1;
print "\n";
print "2=", $2;
print "\n";
print "3=", $3;
}
Darrel Riekhof
riekhof@primenet.com
Visit http://www.connectcorp.com
------------------------------
Date: 4 Mar 1997 06:06:11 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: More weird regular expressions.
Message-Id: <5fge4j$l3r$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Darrel Riekhof
<riekhof@primenet.com>],
who wrote in article <331BB930.52E3@primenet.com>:
> I was toying around with more regular expressions and came up
> with this one:
>
> (([a-z])+([A-Z])+)+
>
> with input:
>
> abcABCdefgABChijklmnop
>
> To my suprise, Perl put the following in the backrefs:
>
> \1 "defgABC"
> \2 ""
> \3 ""
>
> I wouldn't have been suprised if I replaced the '+'s with '*'s.
> Anyone know why \2 and \3 are empty?
Looks like a bug to me, but I would never use ()+ in intention to use
$digit. Keep in mind that this regexp may be _very_ pessimized. I would
not wonder if it runs for centuries if you have 10 case changes in
your string.
No, experiments show that backtracking is not so pessimal. I have no
idea why, though...
Ilya
------------------------------
Date: Mon, 03 Mar 1997 21:35:39 -0800
From: "Christopher M. Surber" <surber@earthlink.net>
Subject: need some help here
Message-Id: <331BB4A3.51BD@earthlink.net>
hey all,
im trying to get this script to take a list and from one line at
a time
take each word or whatever and put it into a variable so that i can
insert the information into a different format. what i have don't work
and im gittin crazy. the script i have so far is
***************************
#!/usr/bin/perl
print "what file?";
chop($filename = <STDIN>);
open (THATFILE, "$filename") || die"cannot open $filename";
while (<THATFILE>) {
($lname,$fname,$location,$mailstop,$phone) = split(/ /);
write;
}
format STDOUT =
@<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<@<<<<<<<@<<<<<<<<<<
$lname,$fname,$location,$mailstop,$phone,$real
.
**********************
part of the list im using is below , all the list looks the same, each
item is seperated by a space or tab.
**********************
Abrams, Sandra Lib2123B L2211 6611
Academic Advising Lib1401 L1401 6312
Academic Budgeting Lib3234 L3234 6867
Academic Computing Lib2409 L2408 6235
John Aikin Cushing Lib2213 L2211 6234
Virginia Darney Lib2210 L2211 6436
**********************
when i run the script i get:
**********************
Abrams, Sandra Lib2123B
Academic Advising Lib1401
Academic Budgeting Lib3234
Academic Computing Lib2409 L2408
John Aikin
Virginia Darney Lib2210
********************
does any one have any suggestions?
feel free to e-mail me directly
thanx chrisssss...
--
================================
Just because you're not Paranoid,
don't mean their not after you.
================================
ONLY THE PARANOID SURVIVE!
================================
surber@earthlink.net
surberc@elwha.evergreen.edu
================================
------------------------------
Date: Mon, 3 Mar 1997 20:00:37 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Daniel Drennan <xixax@echonyc.com>
Subject: Re: Numeric value expected...
Message-Id: <Pine.GSO.3.95q.970303195501.11970G-100000@kelly.teleport.com>
On 3 Mar 1997, Daniel Drennan wrote:
> I'm currently using a DBM file that is a simple log that keeps one key
> and one value that increments.
Kind of a small DBM file, but okay... :-)
> I'm trying to sort the associative array by value, and keep getting an
> error message that the spaceship operator expects a numeric value.
That it does. What value are you giving it? (Try printing the values, to
see what they are. Put each one in quotes or something so that you can
spot the empty ones.)
> I found a tiny footnote in the new Perl book that says that everything
> in a DBM file is treated as a string...why won't Perl do a numeric
> conversion here?
It ought to be doing that conversion, but maybe there is some other junk
that has crept into a string, or maybe one of the strings is empty.
> On a side note, while trying to figure stuff out I was printing out the
> values to make sure things were running okay, and most of the time it is
> a number, but sometimes it came up as HASH(#######) ... is Perl taking
> some of the values for references?
That sounds like somehow you might have tried to store a reference into
the file. That would cause the problem you describe, since
"HASH(0x123456)" is certainly not numeric.
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 3 Mar 1997 23:56:00 -0500
From: Roderick Schertler <roderick@argon.org>
To: nrao@achilles.net
Subject: Re: Perl filehandling
Message-Id: <pz4tesi7is.fsf@eeyore.ibcinc.com>
On Mon, 03 Mar 1997 13:33:22 -0600, nrao@achilles.net said:
>
> #!/bin/perl
> open(F,">>testfile");
> print F "This line goes to the file.\n";
> close(F);
>
> The file executes and doesn't display any errors, however, it does not
> append to testfile.
It doesn't display any errors because you haven't told it to.
> It doesn't even open the file.
How do you know? You aren't checking. Do it like this:
$file = 'testfile';
open F, ">>$file" or die "Can't append to $file: $!";
print F "This line goes to the file.\n"
or die "Error writing to $file: $!";
close F or die "Error closing $file: $!";
--
Roderick Schertler
roderick@argon.org
------------------------------
Date: 3 Mar 1997 22:46:05 -0800
From: rigoleto@kaiwan009.kaiwan.com (Mike Zorn)
Subject: Re: Perl filehandling
Message-Id: <5fggfd$252@kaiwan009.kaiwan.com>
In <857416804.16179@dejanews.com> nrao@achilles.net writes:
>#!/bin/perl
>open(F,">>testfile");
>print F "This line goes to the file.\n";
>close(F);
>This doesn't work. I assume I am making some small sytax error. The file
>executes and doesn't display any errors, however, it does not append to
It looks OK to me. (I would have put parens in the print, but that
shouldn't matter.
When all else fails...
Try the all-seeing flag -w on the #! line; also test the open
statement:
open(F,">>testfile") || die("can't open testfile");
Mike Zorn rigoleto@kaiwan.com
http://www.kaiwan.com/~rigoleto/
"As the most participatory form of mass speech yet developed, the
Internet deserves the highest protection from governmental intrusion."
- - U. S. District Judge Stewart Dalzell
------------------------------
Date: Tue, 4 Mar 1997 04:47:59 GMT
From: phr@netcom.com (Paul Rubin)
Subject: Re: Public domain DES and other crypto code in Perl?
Message-Id: <phrE6I5Bz.9tt@netcom.com>
In article <5ff7r3$cmi$1@news.eecs.umich.edu>,
Aviel Rubin <rubin@quip.eecs.umich.edu> wrote:
>Is there a public domain implementation of DES, MD5 and other crypto
>algorithms? I have seen ones that are C modules that people can link
>into their programs. One problem with such schemes is that usually they
>are installed in a central place by a system administrator, so the entire
>security of the system relies on trusting that you are linking to the
>right functions.
>
>We would like to be able to have a self-contained program where each
>user has all of the code, including the crypto, locally. So, are
>there any packages WRITTEN IN PERL for DES, etc.?
Huh? What's wrong with the user compiling the C functions in with
their programs? DES and other bit twiddling algorithms sound painful
in Perl.
------------------------------
Date: Mon, 03 Mar 1997 23:01:40 -0600
From: kevina@clark.net (Kevin Atkinson)
Subject: Update: New Perl Module: Fraction
Message-Id: <857450796.7324@dejanews.com>
> I have written a Perl module for manipulating Fractions.
>
> This is my first real attempt at writing a Perl Module and at
> Object-Oriented Programming. I mainly write it to teach my self how to
> program Object-Oriently in Perl and for the challenge.
>
> I would appreciate some people taking a look at it and letting me know
> what you think. I would especially appreciate some advise on improving
> my code if anyone cares to give it.
>
> You can find it at http://sunsite.unc.edu/kevina/perl/.
Ver .22a is out. The Biggest improvment is that the reduce method no
longer needs a large list of primes to work. Many Internal changes were
made.
Here is a small demonstration of what the fraction module can do.
It is run for the most part with this function:
sub pevel {print ">$_[0]\n"; $ans = eval $_[0]; print " $ans\n"; }
>frac(1, 3)
1/3
>frac(4, 3, MIXED)
1 1/3
>frac(1, 1, 3)
4/3
>frac(1, 1, 3, MIXED)
1 1/3
>frac(10)
10/1
>frac(10, MIXED)
10
>frac(.66667)
2/3
>frac(1.33333, MIXED)
1 1/3
>frac("5/6")
5/6
>frac("1 2/3")
5/3
>frac(10, 20, NO_REDUCE)
10/20
>$f1=frac(2,3); $f2=frac(4,5);
>$f1 + $f2
22/15
>$f1 * $f2
8/15
>$f1 + 1.6667
7/3
>$f2->modify_tag(MIXED)
>$f2 + 10
10 4/5
>frac($ans, NORMAL) # trick to create a new fraction with different tags
54/5
>$f1 + $f2 # Add two unlikes it goes to default mode
22/15
>$f1**1.2
229739670999407/373719281884655
>num($f1)**1.2
0.614738607654485
>frac(1,2)+frac(2,5)
9/10
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Mon, 03 Mar 1997 21:34:20 -0500
From: Bill Cowan <billc@tibinc.com>
To: Kathleen Ramsey <kramsey@worldnet.att.net>
Subject: Re: Where is Perl-Win32 documentation
Message-Id: <331B8A2C.4979@tibinc.com>
Kathleen Ramsey wrote:
>
> Where can I find it.
>
> Kathy
> kramsey@worldnet.att.net
You should find it (at least html) in "doc" subdirectory of your Win32
Perl installation. Also suggest:
Useful URLs for Win32 Perl (NT Perl)
------------------------------------
Win32 Perl for Windows NT:
http://www.activeware.com/ [also online web pages]
http://www.perl.com/CPAN/ports/win32/Perl5/
Searchable Archive for Perl-Win32-users Mailing List:
http://www.divinf.it/perl-win32/index.sht
Evangelo's Frequently Asked Questions (FAQ):
http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html
-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com> Voice:919-490-0034 Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707
------------------------------
Date: Tue, 4 Mar 1997 05:32:13 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: Which one is the best (pattern matching)
Message-Id: <E6I7Dp.Iy6@nonexistent.com>
On 03 Mar 1997 18:04:38 GMT, Jeffrey wrote in comp.lang.perl.misc:
++
++ Comments on this point from perl.gods would be appreciated here,
Are you trying to start a religion?
Abigail -- The church of Perl?
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 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.
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 45
************************************