[7332] in Perl-Users-Digest
Perl-Users Digest, Issue: 957 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 1 14:07:13 1997
Date: Mon, 1 Sep 97 11:00:22 -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 Mon, 1 Sep 1997 Volume: 8 Number: 957
Today's topics:
Re: Associative Sort? <rootbeer@teleport.com>
bug in perl5.004_01 ? (Periat Henri)
Re: Bug in perl? Bug in my code? (M.J.T. Guy)
Re: bug? redirecting standard output for system() <rootbeer@teleport.com>
Re: cardinality of an array given a reference (Martin Cohen)
Re: changing dir of parent shell <rootbeer@teleport.com>
Re: Creation Date of a File (Michael Fuhr)
Re: Creation Date of a File <rootbeer@teleport.com>
Re: Crypt::IDEA and blocksize <doug@ono.tc.net>
editing perl <hammond@u.arizona.edu>
filehandle - select problem denis@mathi.uni-heidelberg.de
Help please <weaver@peterboro.net>
Re: Help: Creating a datastructure. (Martin Cohen)
Re: Include external subroutines <rootbeer@teleport.com>
Re: ODBC not working (Jeremy D. Zawodny)
Re: Password verification with a shadow file ?? (Aaron Sherman)
Re: Pattern matching problem with \n (Simon Hyde)
Re: Perl & Shadow Passwords authentitacion. (Michael W Peterson)
Perl goofs up search/replace - *sometimes* (Filip M. Gieszczykiewicz)
Re: perl/win95/Long File Names (Andrew M. Langmead)
Re: perldoc (M.J.T. Guy)
Problems with socket buffering (Mark Denby)
Re: Provider removed <!--EXEC > (Michael Fuhr)
Reserved words <lehors@w3.org>
Re: Reserved words (M.J.T. Guy)
Re: Shortest Path Algorithm (Andy)
Re: Trouble with DBM files <rootbeer@teleport.com>
Re: Uploading WORD doc (PERL CODE ERROR) <rootbeer@teleport.com>
Re: Use with if statements (M.J.T. Guy)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 1 Sep 1997 08:09:30 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: MacProgFreak <macprogfreak@hotmail.com>
Subject: Re: Associative Sort?
Message-Id: <Pine.GSO.3.96.970901080720.1910G-100000@julie.teleport.com>
On Sun, 31 Aug 1997, MacProgFreak wrote:
> Newsgroups: comp.lang.perl, comp.programming
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: Associative Sort?
You seem to want to know how to sort a hash (associative array).
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq4/
How_do_I_sort_a_hash_optionaly.html
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/
------------------------------
Date: 1 Sep 1997 08:52:34 GMT
From: periat@ens.ascom.ch (Periat Henri)
Subject: bug in perl5.004_01 ?
Message-Id: <5udvoi$6v4@ascomax.hasler.ascom.ch>
Hi everybody
With Perl versions before 5.004_01 i got with:
perl -en 'print "@ARGV\n";' blue red
blue red
But with this new version i get nothing. Is this a bug ?
Cheers
Henri
--
-----------------------------------------------------------------------
Henri Periat Phone: 0041 32 624 35 78
Ascom Business Systems AG E-Mail: periat@ens.ascom.ch
Dep. 3578 Fax: 0041 32 624 31 56
Ziegelmattstr. 1
CH-4503 Solothurn
Switzerland
-----------------------------------------------------------------------
------------------------------
Date: 1 Sep 1997 15:25:58 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Bug in perl? Bug in my code?
Message-Id: <5uemq6$3nh$1@lyra.csx.cam.ac.uk>
Eli the Bearded <usenet-tag@qz.little-neck.ny.us> wrote:
>
>ObPerl:
>Are there any limitations on what you can put in a s///e evaluation
>context? I mean can I import packages, etc, etc.
You can put anything you like, provided it's a valid Perl program (and
provided the bugs don't bite).
Mike Guy
------------------------------
Date: Mon, 1 Sep 1997 08:06:32 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "David J. Fiander" <davidf@mks.com>
Subject: Re: bug? redirecting standard output for system()
Message-Id: <Pine.GSO.3.96.970901080303.1910F-100000@julie.teleport.com>
On 29 Aug 1997, David J. Fiander wrote:
> I've tried this:
>
> open(SAVOUT, ">&STDOUT");
> open(STDOUT, ">output");
>
> print "perl is redirected\n";
> system("echo echo should be redirected");
>
> open(STDOUT, ">&SAVOUT");
> close(SAVOUT);
>
> but the string "echo should be redirected is still appearing on
> my terminal.
Doesn't appear on mine, using versions 4.016, 5.003_20, or 5.004_01 of
Perl. Maybe it's your OS. Have you tried checking the return values from
open? 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/
------------------------------
Date: 1 Sep 1997 16:32:45 GMT
From: mcohen@netaxs.com (Martin Cohen)
Subject: Re: cardinality of an array given a reference
Message-Id: <5ueqnd$bqe@netaxs.com>
I tried this, which worked by printing 2:
$arref=["one","two"];
print scalar(@$arref),"\n";
--
Marty Cohen
Aaron Newman (newman@ttd.teradyne.com) wrote:
: Hello, friends. I am wondering about finding the cardinality of an
: array given a reference to the array. I am trying to do this in one
: statement, dereferencing it and getting the cardinality at the same
: time. For example,
:
: $arref=["one","two"];
: @ar=@$arref;
: print "cardinality is ",$#ar,"\n";
:
: Is there a way to do this without first creating @ar? I can't seem to
: work it out syntactically. Perl chokes on $#@$arref, and $#(@$arref)
: doesn't work either.
:
: Thanks,
: Aaron
:
: --
: ---------------------------------------------------------------------
: | newman@ttd.teradyne.com | "A forest is a finite |
: | | (possibly empty) set of |
: |http://www.cirrusnet.com/~newman | trees." - Baase |
: ---------------------------------------------------------------------
--
Martin Cohen - mcohen@acm.org - Melrose Park, PA 19027
------------------------------
Date: Mon, 1 Sep 1997 08:32:25 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Les Schaffer <godzilla@futuris.net>
Subject: Re: changing dir of parent shell
Message-Id: <Pine.GSO.3.96.970901081749.1910K-100000@julie.teleport.com>
On 31 Aug 1997, Les Schaffer wrote:
> can i get my perl script to change the directory of the parent (bash)
> shell, THAT DOES NOT INCLUDE SOURCING A BASH SHELL SCRIPT (WRAPPER)?
> -- u.c. added for improved clarity.
Let's turn that question on its head: How can anyone possibly write a
shell script which can be at all reliable if any of its child processes
can change its directory or environment at any time?
I think that, when you've pondered that question deeply enough, you'll see
why you can't do what you might wish to do. (But it may spark other ideas
on how you could do this. For example, this _could_ be done if you had a
root-privileged process which tinkers with the parent process in
interesting ways.... But that would be like having children do brain
surgery on their parents. :-)
The short answer (in case you don't have time to ponder :-) is that each
process is in charge of its own environment and working directory. If you
want a process to change something, you may request the change, but it's
still always the process itself which is in charge.
Now, since I know that several people pointed you to the FAQ entries about
this, and since you've read them before posting, I have a question that I
hope you can answer: Is there some way in which the FAQ could have given
this answer which would have made it any clearer to you?
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/
------------------------------
Date: 1 Sep 1997 08:39:48 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Creation Date of a File
Message-Id: <5uek3k$7vd@flatland.dimensional.com>
"Paul Denman" <pdenman@ims.ltd.uk> writes:
> I have worked with the '-M' operator to find the last modification time
> (and work out the age)
> of a file - no problem. I was under the impression that you could also find
> out the original
> creation date of a file, or am I mistaken?
You are mistaken. You can get the following:
mtime - the last time the file was modified
ctime - the last time the file's inode was changed
(e.g., ownership change, permissions change)
atime - the last time the file was accessed
Take a look at the stat() function in the perlfunc manual page, or
the stat() function in the manual pages for your system libraries
(i.e., "man stat").
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Mon, 1 Sep 1997 08:56:34 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Paul Denman <pdenman@ims.ltd.uk>
Subject: Re: Creation Date of a File
Message-Id: <Pine.GSO.3.96.970901085444.1910O-100000@julie.teleport.com>
On Mon, 1 Sep 1997, Paul Denman wrote:
> I have worked with the '-M' operator to find the last modification time
> (and work out the age) of a file - no problem. I was under the
> impression that you could also find out the original creation date of a
> file, or am I mistaken?
You're mistaken. :-) Unix-type filesystems don't record any creation date
for files, and Perl doesn't (AFAIK) provide any interface to such
timestamps if any are available on other systems - but if you have a
non-Unix port, you might find something in that port's release notes. 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/
------------------------------
Date: 01 Sep 1997 13:41:20 -0400
From: Douglas McNaught <doug@ono.tc.net>
To: chris@ixlabs.com
Subject: Re: Crypt::IDEA and blocksize
Message-Id: <m2afhxc4ov.fsf@ono.tc.net>
[mailed and posted]
Chris Schoenfeld <chris@ixlabs.com> writes:
> Am I nuts, or can Crypt::IDEA only encrypt 8 bytes of data.
> There seems no way in the interface to override this.
> Why is it like this?
Because IDEA (like DES) is a block cipher with an 8-byte blocksize.
That's just the way it works. To encrypt data greater than 8 bytes in
size, you'll need to split it into blocks and encrypt each
individually. It's a good idea to use some kind of feedback mechanism
like CBC (cipher block chaining) to give more security.
For more information, see _Applied Cryptography_, 2nd Edition, by
Bruce Schneier.
-Doug
--
sub g{my$i=index$t,$_[0];($i%5,int$i/5)}sub h{substr$t,5*$_[1]+$_[0],1}sub n{(
$_[0]+4)%5}$t='encryptabdfghjklmoqsuvwxz';$c='fxmdwbcmagnyubnyquohyhny';while(
$c=~s/(.)(.)//){($w,$x)=g$1;($y,$z)=g$2;$w==$y&&($p.=h($w,n$x).h($y,n$z))or$x==
$z&&($p.=h(n$w,$x).h(n$y,$z))or($p.=h($y,$x).h($w,$z))}$p=~y/x/ /;print$p,"\n";
------------------------------
Date: 1 Sep 1997 16:02:55 GMT
From: Michael T Hammond <hammond@u.arizona.edu>
Subject: editing perl
Message-Id: <5ueovf$mb2$1@news.ccit.arizona.edu>
This may be a terribly naive question.
I'd like to be able to edit Perl bits with emacs and then try them out
from within emacs. How do I do this?
Mike H.
hammond@u.arizona.edu
------------------------------
Date: Mon, 01 Sep 1997 13:28:47 +0200
From: denis@mathi.uni-heidelberg.de
Subject: filehandle - select problem
Message-Id: <340AA6EF.167E@mathi.uni-heidelberg.de>
hi,
i have a problem with select and filehandels. i tried to change a
filehandle with select. this worked in the main program. now i tried
to do this in a subroutine , but this doesnot work.
perl thinks this is a format, but it isnot.
this is the errormessage:
Undefined format "main::ERROR" called at /home/denis/scripts/prog.pl
line 164, <FILE> line 1
i open the filehandle in the same subroutine:
open(ERROR, ">$ERR_OUT") or die "kann $ERR_OUT nicht erstellen";
if i try select STDOUT i get a simmilar message.
any suggestions?
denis
------------------------------
Date: Mon, 01 Sep 1997 11:23:03 -0400
From: "G.McKenzie" <weaver@peterboro.net>
Subject: Help please
Message-Id: <340ADDD7.787ECDB9@peterboro.net>
Hi
Being a newbie, I have a question that I am looking for some guidance
on. Well here it is.
I have a game that I wish to register high scores in and have a button
to enter the high score into a db for eg. and have it register and list
scores highest to lowest. Now is there a easy way to accomplish this in
perl as in a simple interface to say msql??
Any information of suggestions of how to tackle this would be greatly
appreciated.
Thanx
G. Mckenzie
weaver@peterboro.net
------------------------------
Date: 1 Sep 1997 16:16:06 GMT
From: mcohen@netaxs.com (Martin Cohen)
Subject: Re: Help: Creating a datastructure.
Message-Id: <5uepo6$bqe@netaxs.com>
Eric Bohlman (ebohlman@netcom.com) wrote:
: the Thief of Always (omard@blue.seas.upenn.edu) wrote:
:
: : I want to create an array of lists.
: : as in I have X amount of the following
: : fields:
:
: : ($ind, $name,$date,$horse, $cat)
: : and I want to store them in an associative
: : called REF with $ind as they key; I dont
: : particularly wanna concat'em into a string and resplit
This is actually not a bad way to do it.
: : every single time, nor do I wish to reread them.
: : the dilemma in essence is that I know the $ind, and I want
: : to access $name or $date or $horse or whatever.
:
: : So how do I go about doing this?
:
: man perllol(1).
Or, of course, see the Blue Camel book's Chapter 4 for many examples.
You may not use one of them for your purpose, but it's still worth
reading and experimenting with.
The way I handles this problem is that I made a hash on the name I
was indexing (a symbol table for a simple compiler) whose value was
an integer. I used the integer as the index to regular (parallel)
arrays -- not hashes -- for the other attributes (your $ind, $name, $date,
$horse,$cat). When I defined a new name I executed this:
$name{"$name"}=;++$nnames
[The quotes are just to show you that I am using a character string.]
I had initialized $nnames to zero. And I looked in the hash for $name
before I created a new entry: if (!defined($name{$name})) # { above }
--
Martin Cohen - mcohen@acm.org - Melrose Park, PA 19027
------------------------------
Date: Mon, 1 Sep 1997 08:49:52 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ake Johansson <ets96aja@student.hk-r.se>
Subject: Re: Include external subroutines
Message-Id: <Pine.GSO.3.96.970901083743.1910N-100000@julie.teleport.com>
On Mon, 1 Sep 1997, Ake Johansson wrote:
> I have made several Perl programs that are very similar to each other,
> my question is if it's possibly to put a subroutine in an external file
> and use something like "include" to call it from several other Perl
> programs?
Yes, this is usually done with modules.
> I would not like to make a module, since I'm not very familar with OO
> programing, I just want to put a subroutine in an external file...
Modules don't have to be OO. And they're easier to create than you
probably think. I recommend that you make a module.
But if you can't bear to make a module (and if you want to make your code
less convenient :-) then you should probably check out the require
function in the perlfunc(1) manpage. 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/
------------------------------
Date: Mon, 01 Sep 1997 14:19:41 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: ODBC not working
Message-Id: <340bcecc.36521014@news.bgsu.edu>
[original author automagically cc'd via e-mail]
On Fri, 29 Aug 1997 10:54:01 -0400, Mike Drons <Michael_Drons@ins.com>
wrote:
>I have perl for win32 build 307 with the ODBC.pm module. My perl script
>works fine if I run it from the command line. It does not work when IIS
>version 3.0 runs it. It dies when it creates the new ODBC object. I
>think it is a permission problem but don't know where to look. Any
>suggestions?
Mike,
Have a look at the ODBC.pm FAQ at Dave Roth's web site.
http://www.roth.net/odbc. I think you'll find the answer there.
Jeremy
---
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>
"That's an example of how Perl can bring school yard cruelty to new heights."
-- Jon Orwant at the 1st Annual Perl Conference
------------------------------
Date: 1 Sep 1997 10:58:58 -0400
From: ajs@lorien.ajs.com (Aaron Sherman)
Subject: Re: Password verification with a shadow file ??
Message-Id: <5uel7i$i3f@lorien.ajs.com>
Tom Phoenix <rootbeer@teleport.com> wrote:
>On Fri, 29 Aug 1997 mgrabenstein@isinet.com wrote:
>
>> I need to validate a user's password entered from a Web form.
>> Problem is the system has a shadow password file and I do _not_ want the
>> CGI to have, or call a program with special privledges (ie. root).
>
>Why not? Here's one idea: Set up a root-privileged script (or daemon)
>which, when given a username and a password attempt, reports whether or
>not the attempt works. It wouldn't be too hard to make it secure, and it
It would be impossible to make it secure. The whole point to having
a shadow password file is to avoid the average user being able to
test random guesses (e.g. brute-force cracking) against the encrypted
password. Providing a program that does exactly this is a mistake.
Of course, you could have a special group which would be allowed
to execute the program, and have the program check for multiple failed
password checks on the same account (using a DBM file, say). But,
it's still never going to be "secure" just "acceptable risk".
-AJS
------------------------------
Date: Mon, 01 Sep 1997 15:42:31 GMT
From: shyde@poboxes.com (Simon Hyde)
Subject: Re: Pattern matching problem with \n
Message-Id: <3409ee14.11050861@news.uni-stuttgart.de>
The following should do:
s/\\t/\t/g;
s/\\n/\n/g;
s/\\\\/\\/g;
or if you want to be clever try:
s/(\\t|\\n|\\\\)/eval('"'.$1.'"')/eg;
------------------------------
Date: 1 Sep 1997 17:07:17 GMT
From: michael@flash.net (Michael W Peterson)
Subject: Re: Perl & Shadow Passwords authentitacion.
Message-Id: <5ueso5$7uf$1@excalibur.flash.net>
On 01 Sep 1997 12:37:21 +0200, Tom Grydeland <tom@mitra.phys.uit.no> wrote:
>
>> On 30 Aug 1997, Michael W Peterson wrote:
>> > I've yet to have script running on Solaris
>> > 2.5.1 return shadow passwords unless it's running privileged.
>
>Tom Phoenix <rootbeer@teleport.com> writes:
>> That's a relief. :-)
>
>> It may be that this feature confused someone into thinking that their
>> system was giving out crypted passwords. But until we see some code and
>> output, it's just a guess. Cheers!
>
>I'm not going to post the usernames or entire passwords returned, but...
>
>On Solaris 2.5 running NIS+:
>
[snip usernames returned with crypted passwords]
>
>And on another machine with YP/NIS (I'm not really sure, actually)
>
[snip usernames returned with crypted passwords on an alpha]
>
>
>So unprivileged code gets the crypted passwords in these systems, and
>in one of them it even gets the root password! None of these have
>crypted passwords in the /etc/passwd file.
>
(throwing in my US$0.02)
I think it's an "issue" with NIS. I don't see that on a non-NIS Solaris box,
even as root. I've got to do the getspnam call to get crypted passwords
back.
Solaris 2.5.1 with _no_ NIS of any type
$ uname -a
SunOS 5.5.1 Generic i86pc i386 i86pc
$ perl -le 'while(($n,$p)=getpwent){print "$n:$p"}'
root:x
daemon:x
bin:x
sys:x
adm:x
lp:x
smtp:x
uucp:x
nuucp:x
listen:x
nobody:x
noaccess:x
nobody4:x
XXel:x
XXin:x
etc...
And another box with 2.5.1 and no NIS, but running as root
# uname -a
SunOS 5.5.1 ISS_1.0 sun4u sparc SUNW,Ultra-Enterprise
# perl -le 'while(($n,$p)=getpwent){print "$n:$p"}'
root:x
sysdiag:x
sundiag:x
daemon:x
sync:x
bin:x
sys:x
adm:x
lp:x
smtp:x
uucp:x
audit:*
listen:x
nobody:x
noaccess:x
XXmy:x
XXix:x
XXws:x
XXer:x
etc...
--
Michael W Peterson <http://www.flash.net/~michael/>
Senior System Administrator
FlashNet Communications <http://www.flash.net/>
"Unix: more than enough rope..."
------------------------------
Date: 1 Sep 1997 17:46:06 GMT
From: fmgst+@pitt.edu (Filip M. Gieszczykiewicz)
Subject: Perl goofs up search/replace - *sometimes*
Message-Id: <5uev0u$t1i@usenet.srv.cis.pitt.edu>
Greetings. I have a small perl script that reads in a 'dictionary' file
(generated by a shell script in step 1 of 2) of the form:
"search for this" --> #tag_number
(internally converts is to:
"search for this" --> <a HreF="#tag_number">search for this</a>)
The input files are ~300-900KB in size and they are searched with $/ cleared.
Here's the problem, for a reason that I am completely unable to find, it
will now and then _skip_ a search and replace! No reason for it, goes great
everywhere else, the skipped pattern is perfect!
This is for a "cross-referencer" that substitutes dynamic links for
references. Example:
'[..] see section: "Testing B&W monitors"'
becomes
'[..] see section: "<a HreF="#MON_197">Testing B&W monitors</a>"'
Again, it can make 300 substitutions just fine and right on the dime
and skip 10-15 perfectly ok matches. It is very annoying to correct said
links by hand since I deal with many MB of data... and it needs to be
processed often.
Please point me in the right direction.
Sys stats:
Linux 2.0.30 (months of uptime)
486/66 w/64MB ram + 64MB vm
Happens on both Perl 5.003 w/ EMBED AND
Perl 5.004_01 (just built it to check)
ALSO (just tested) happens on:
SunOS [..] 5.5.1 Generic_103640-08 sun4u sparc SUNW,Ultra-2
under 5.004_01
Curious: happens on SAME dictionary lines, repeatably
(cross-platform, too!! :-)
Input file:
Just plain HTML V2, nothing fancy. Has new-lines before
each <P> to make the "paragraph mode" in perl happy ($/="")...
Dictionary file looks like this:
[..]
"DISCLAIMER" --> #LASERFAQ_005
"Acknowledgements" --> #LASERFAQ_006
"Related information" --> #LASERFAQ_007
"Common lasers of interest to the hobbyist and experimenter" --> #LASERFAQ_008
"Diode lasers" --> #LASERFAQ_009
"Helium neon (HeNe) lasers" --> #LASERFAQ_010
"Argon (Ar) and krypton (Kr) ion lasers" --> #LASERFAQ_011
"Laser Safety" --> #LASERFAQ_012
[..]
Dictionary files are usually ~150-250 lines
And the actual perl script is:
-----------------chop-with-axe----------------chop-with-axe---------------------
#!/usr/bin/perl
#
$default_dict=$ARGV[0];
if ($default_dict eq "") { die("ERROR: I need the dictionary name!\n");}
#
$DEBUG=0;
#$DEBUG=1;
#
&Load_Dictionary;
#
# We can turn on paragraph mode on... now.
$/="";
#
while (<STDIN>) {
@tmp = @pattern;
&Search_n_Replace(@tmp);
print $_;
}
#----------------------------------------------------------------------
sub Search_n_Replace {
local (@tmp) = @_;
while (@tmp) {
# FILO
$replace = pop (@tmp);
$search = pop (@tmp);
if (m|$search|is) {
# leave the section names/titles themselves ALONE!
if (!m|<a name=| && !m|<a href=\"\#|) {
s|$search|$replace|sxg;
s@/@\/@gx;
}
}
}
}
#----------------------------------------------------------------------
sub Load_Dictionary {
if (! -f "$default_dict") { die ("ERROR: Can not find '$default_dict'!\n"); }
open (DICT, "$default_dict") || die ("ERROR: can't open '$default_dict'");
while (<DICT>) {
chomp; # chop off the \n
#
# Is it a comment line? ('#' in position #1 or just empty?)
if (!m/^#/ && $_ ne "") { # Nope...
# for now ignore "-->" (change to '@' and split on it)
$_ =~ s/(\ *)-->(\ *)/@/;
#
# Stuff values on line into array
($search,$replace) = split (/@/);
#
if (length($replace) < 1) {
if ($DEBUG) {
print "[dict error]: $_\n";
}
} else {
# Don't know how to do this 'nicer' but it
# DOES work and everything is as desired...
$orig_search = $search;
$orig_search =~ s/"//g;
$search =~ s|\?|\\?|g;
$search =~ s/"//g;
# TODO: add search for unmatched ()
$search =~ s|\.|\\.|g;
$search =~ s|\"\ |\"|g;
$search =~ s|\"|\\"|g;
$search =~ s|\ |\.|g;
#
# The "HreF" is **CRITICAL** so the ToC doesn't get hosed
# on next PRocess... (when it rebuilds the ToC)!!!!!!!!
#
$repl = "<a HreF=\"" . $replace . "\">" . $orig_search . "</a>";
$replace =~ s/$replace/$repl/;
#
push (@pattern,$search,$replace);
}
}
}
close (DICT);
if ($DEBUG) {
@tmp = @pattern;
print "<ol>\n";
while (@tmp) {
# FILO
$replace = pop (@tmp);
$search = pop (@tmp);
print "<li>search=$search\nreplace=$replace\n";
}
}
}
-----------------chop-with-axe----------------chop-with-axe---------------------
Take care.
--
Filip "I'll buy a vowel" Gieszczykiewicz | http://www.paranoia.com/~filipg/
Now exploring whatever, life, and the meaning of it all... and 'not' :-)
------------------------------
Date: Mon, 1 Sep 1997 17:33:52 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: perl/win95/Long File Names
Message-Id: <EFuBGG.Jtx@world.std.com>
Mike Turk <mturk@globalserve.net> writes:
> You might want to try opendir( DIRHANDLE, 'c:\\program
>files\\netscape\\navigator\\program')
>^ ^ ^ ^
>instead.......remember those silly DOS boxes are backwards.
That is not the problem, the MS-DOS (snicker) kernel, allows both
forward and backward slashes as pathname delimiters. Its just that
many programs botch the filename before it gets to the kernel. For
example, COMMAND.COM uses the forward slashes for optional arguments,
so tries to process the characters after the forward slashes are
arguments.
--
Andrew Langmead
------------------------------
Date: 1 Sep 1997 15:48:21 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: perldoc
Message-Id: <5ueo45$4fh$1@lyra.csx.cam.ac.uk>
Kevin <klander@primenet> wrote:
>I just installed perl5.00401, and I'm having trouble with perldoc. I
>type 'perldoc IO::Socket', and after a few seconds it tells me it
>can't find documentation for IO::Socket. Also, if I use the -v flag
>to get information about where it's searching, I get a segmentation
>fault. Is there any documentation on IO::Socket? If so, where would
>perldoc be looking for it? The man page doesn't say where besides the
>PATH and PERL5LIB paths it searches. Also, why would I be getting a
>segmentation fault when I use -v? Thanks for any help...
You seem to have a very bent Perl installation. Did you check all
the output from Configure / make / make test / make install for errors?
(Did you run "make test" at all?) Did you use unusual options to
Configure?
perldoc gets its pod information for a module from the module itself,
which will be in IO/Socket.pm in one of the directories in the @INC list.
So if it fails to find it, the module isn't installed as it should be.
Mike Guy
------------------------------
Date: Mon, 01 Sep 1997 16:30:57 GMT
From: mark@entranet.co.uk (Mark Denby)
Subject: Problems with socket buffering
Message-Id: <340aebb9.429380218@news.theplanet.co.uk>
Hi!
I have a Netscape IMAP mail server running under Solaris 2.5.1
which I am attempting to communicate with using Perl.
The following is a chunk of one of my scripts:
#!/usr/local/bin/perl
$sockaddr ='S n a4 x8';
$AF_INET =2;
$PROTOCOL =0;
$SOCK_STREAM =1;
$FileHandle=0;
$Host='eng_sparc1';
$Port=143;
$Username='mark';
my($SOCKET)="$Host".$FileHandle++;
# Lookup the hostname
my($addr)=((gethostbyname($Host))[4]);
# Now create a socket to the named server
if(socket($SOCKET,$AF_INET,$SOCK_STREAM,$PROTOCOL))
{
$sin=pack($sockaddr,$AF_INET,$Port,$addr);
# And make the connection
if(connect($SOCKET,$sin))
{
select((select($SOCKET),$|=1)[0]);
# Now send the login string
$_=<$SOCKET>;
print $_;
}
}
When running from the Solaris box, the above script will
hang at the $_=<$SOCKET>; line.
If, however I run the same script from a Linux (2.0.28) box,
the script returns the signon message from the IMAP server
(still running under Solaris).
I am using Perl 5.003 (patch level unknown - RedHat 4.2 RPM)
under Linux and have tried both Perl 5.003 and Perl 5.004.03
under Solaris.
Is anyone able to explain this to me?
Many thanks,
Mark.
------------------------------
Date: 1 Sep 1997 08:43:26 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Provider removed <!--EXEC >
Message-Id: <5uekae$819@flatland.dimensional.com>
of@lms.be (Orlando Frooninckx) writes:
> My ISP removed the <!--EXEC > command, is there a way to do the same
> thing by using other commands? Maybe by using javascript?
This has nothing to do with Perl -- it would be better to ask in
one of the comp.infosystems.www.* newsgroups.
I suspect your ISP removed it for a reason, so you'd probably be
violating their policy by trying to work around it.
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Mon, 01 Sep 1997 16:57:01 +0200
From: Arnaud Le Hors <lehors@w3.org>
Subject: Reserved words
Message-Id: <340AD7BD.B60D5880@w3.org>
Hi everybody,
I'm looking for the list of perl reserved words. I spent some time
looking in the man pages, the FAQs, as well as various resources on the
web, but can't find it anywhere. Any body knows if this is available
anywhere? It would be a good thing to have this in the distribution
package.
Thanks.
--
Arnaud Le Hors - W3C, User Interface Domain - www.w3.org/People/Arnaud
------------------------------
Date: 1 Sep 1997 15:33:55 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Reserved words
Message-Id: <5uen93$43b$1@lyra.csx.cam.ac.uk>
In article <340AD7BD.B60D5880@w3.org>, Arnaud Le Hors <lehors@w3.org> wrote:
>Hi everybody,
>I'm looking for the list of perl reserved words. I spent some time
>looking in the man pages, the FAQs, as well as various resources on the
>web, but can't find it anywhere. Any body knows if this is available
>anywhere? It would be a good thing to have this in the distribution
>package.
That's why it *is* in the standard distribution. See the file keywords.pl
(or keywords.h).
Mike Guy
------------------------------
Date: Mon, 01 Sep 1997 15:02:04 +0100
From: andyc@dircon.co.uk (Andy)
Subject: Re: Shortest Path Algorithm
Message-Id: <andyc-0109971502040001@aj139.du.pipex.com>
In article <5u2qkq$g5v$1@newbabylon.rs.itd.umich.edu>, Matthew Scott Britt
<msbritt@ren.us.itd.umich.edu> wrote:
> Does anyone know of a shortest path algorithm written in perl? I search
> CPAN with no luck...
The algoithm would depend on whether you want depth-first or breadth-first
searching done, I would have thought..
------------------------------
Date: Mon, 1 Sep 1997 08:36:30 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "webmaster@vmirror.com" <webmaster@vmirror.com>
Subject: Re: Trouble with DBM files
Message-Id: <Pine.GSO.3.96.970901083416.1910M-100000@julie.teleport.com>
On Sun, 31 Aug 1997, webmaster@vmirror.com wrote:
> All of a sudden I am getting this error message when perl tries to
> open the dbm files:
> No dbm on this machine at try.pl line 2.
> We're using Perl 5.003 and it hasn't been changed in months.
>
> It is possible, though unlikely, that someone changed something else
> on this machine.
That's what it sounds like: Somebody moved, deleted, or changed
permissions on the module needed to open those DBM files. I'd see about
having 5.004 installed. If it somehow doesn't come with the needed modules
for your files, there are others available on CPAN. 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/
------------------------------
Date: Mon, 1 Sep 1997 08:16:31 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Danny Rosenthal <drosenth@com1.med.usf.edu>
Subject: Re: Uploading WORD doc (PERL CODE ERROR)
Message-Id: <Pine.GSO.3.96.970901081314.1910J-100000@julie.teleport.com>
On Sun, 31 Aug 1997, Danny Rosenthal wrote:
> I am writing a program to post MS Word documents on the web. I know how
> to use the multi-part file upload in Perl, but my posted files are
> screwed up when I post Word files.
> I assume the error lies in the fact that Word docs are not just Text.
> What am I missing? Do I need to do some type of file translation for the
> word file? With binmode? How should I be processing the word file
> differently?
Treat Word files like any other binary files, and everything should work:
Perl doesn't have any prejudice against certain file formats. :-)
You should probably use binmode, and you probably want to work with the
data block-by-block rather than line-by-line. If something is still going
wrong, try making a test data file with (for example) 256 different bytes,
and see how it gets transferred. If you see how it's munged, that may help
you to understand what's doing the munging. 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/
------------------------------
Date: 1 Sep 1997 13:57:08 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Use with if statements
Message-Id: <5uehjk$k3$1@lyra.csx.cam.ac.uk>
Tom Phoenix <rootbeer@teleport.com> wrote:
>
> BEGIN {
> if ($var) {
> require "lib.pl";
> } else {
> require Module;
> import Module;
> }
> }
And be warned that you'll probably then get "Use of undefined variable"
if you've got -w set (and more obscure confusion if you haven't).
Make sure thar $var is set _at compile time_. Set it inside the BEGIN
block or in an earlier BEGIN block.
Mike Guy
------------------------------
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 957
*************************************