[10067] in Perl-Users-Digest
Perl-Users Digest, Issue: 3660 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 8 14:07:51 1998
Date: Tue, 8 Sep 98 11:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 8 Sep 1998 Volume: 8 Number: 3660
Today's topics:
<> Question <steve.debenport@us.coopers.com>
Re: Beginner's question (I.J. Garlick)
Re: changing the default shell for system and exec comm (Andrew M. Langmead)
crypt() on a NT system <ruetten@vivai.de>
Re: Denver/Boulder Perl Mongers <jnoble@mediaone.com>
how to retrieve contents of embedded OLE with win32::OD <jamespo@N0SPAMyahoo.com>
Re: IO::File Permissions - Revisited (M.J.T. Guy)
Re: localtime and Y2K (Michael J Gebis)
mkdir and umask <liznet@cookwood.com>
Re: mkdir and umask <rick.delaney@shaw.wave.ca>
Re: Perl Programmer Needed (Chris Russo)
Re: Perl Programmer Needed <jimbo@soundimages.co.uk>
Re: Perl Programmer Needed (Roberto)
Re: Perl Programmer Needed <eashton@bbnplanet.com>
Re: Perl Programmer Needed <rick.delaney@shaw.wave.ca>
Q: Converting C to Perl (Fred Gurzeler)
read a file through HTTP <sharwood@cs.uiowa.edu>
skipping lines <steve.debenport@us.coopers.com>
Re: skipping lines (Matthew Bafford)
Re: Splitting code across several files. <saunder@kben.co.uk>
Re: Splitting code across several files. <tchrist@mox.perl.com>
Re: Stripping out 'bad' HTML (Abigail)
uname -r <twong@exchange.ml.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 Sep 1998 16:54:02 GMT
From: "Steve Debenport" <steve.debenport@us.coopers.com>
Subject: <> Question
Message-Id: <6t3nfa$pfq$1@news-2.news.gte.net>
SG93IGRvIEkgd2l0aGluIGEgJ1doaWxlICg8PiknIGFuZCAnaWYnIHN0YXRlbWVudCwgc2tpcCBh
IGNvdXBsZSBvZiBsaW5lcyBhdCBhIGNlcnRhaW4gcG9pbnQgd2hpbGUgc3RlcHBpbmcgdGhyb3Vn
aCBhIHRleHQgZmlsZS4gIEkgdGhvdWdodCB0d28gc2ltcGxlICc8Picgd291bGQgd29yaywgYnV0
IGl0IGRvZXNuJ3Qgc2VlbSB0by4gIEFueSBpZGVhcz8gIFRoYW5rcy4NClN0ZXZlIERlYmVucG9y
dCANClN0ZXZlLkRlYmVucG9ydEB1cy5wd2NnbG9iYWwuY29tDQo=
------------------------------
Date: Tue, 8 Sep 1998 16:36:44 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: Beginner's question
Message-Id: <Eyz4t8.MJM@csc.liv.ac.uk>
In article <35f596ee.292629796@news.oz.net>,
tgy@chocobo.org (Tim Gim Yee) writes:
> On Mon, 7 Sep 1998 08:46:21 GMT, ijg@csc.liv.ac.uk (I.J. Garlick)
> wrote:
>
>>Also I have never been able to make '$/' strip the
>>character/phrase/word/pattern from what was then read in without doing
>>something like:-
>>
>> s/$pattern//;
Thanks, missed taht in the camel.
Having said that you still need to do the chomp, which addmitedly is faster,
to get what Kevin was after.
--
--
Ian J. Garlick
ijg@csc.liv.ac.uk
postmaster@merseymail.com
strategy, n.:
A comprehensive plan of inaction.
------------------------------
Date: Tue, 8 Sep 1998 15:53:45 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: changing the default shell for system and exec commands
Message-Id: <Eyz2tM.Kzq@world.std.com>
aori <aori@iil.intel.com> writes:
>Subject: Re: changing the default shell for system and exec commands
Besides the the reason for only using /bin/sh mentioned elsewhere,
that different systems may not have the same shells, there is also the
consideration that it would be awkward if a program behaved
differently depending on which user on the system ran it. (and imagine
if the persons shell was some sort of menu system or something that
didn't behave at all like the bourne shell.)
If you want a different shell, you can always call it explicitly.
system 'csh', '-c', $variable_containing_a_csh_construct;
--
Andrew Langmead
------------------------------
Date: Tue, 8 Sep 1998 17:11:46 +0200
From: "news.ipf.net" <ruetten@vivai.de>
Subject: crypt() on a NT system
Message-Id: <6t3hjg$2mi$1@trader.ipf.de>
Hello,
please help me. I can use the cryp function in UNIX, but when i try to use
it in Windows NT a strange error message appears : "crypt not implemented
due to exessive paranoia".
Is there a module or somthing else which allows to use the crypt function on
NT.
Thanks
Frank
------------------------------
Date: Tue, 8 Sep 1998 10:03:06 -0600
From: "news.uswmedia.com" <jnoble@mediaone.com>
Subject: Re: Denver/Boulder Perl Mongers
Message-Id: <6t3kf7$h9l$1@kane.uswmedia.com>
Elaine -HappyFunBall- Ashton wrote in message
<35F190C6.194D585@bbnplanet.com>...
>
>david, new york is not the center of the universe :) hey, boston has a
>'T' and cabs..hotel rooms even! who knew? though i would admit a cab
>ride from denver to boulder would be pretty $$$. but cheaper than a dwi.
In all of Colorado, the Denver <-> Boulder bus service is the best
long-distance haul around. It runs damn near all the time (with a slight
break from say 2a - 4a), comforable seats, etc.
Boulder voters (commuters and those they love) really have made sure that
the RTD bus service works right for them. Anyone looking to come to the
Perl Mongers meeting next Monday from Boulder could do much worse than to
check out http://www.RTD-Denver.com and see the route schedules and maps for
the "B", "D", and other letter'd regional routes.
The meeting will be held about 2 short blocks from the RTD station.
I hope to meet lots of you there!
Joel Noble
------------------------------
Date: Tue, 08 Sep 1998 17:09:43 +0100
From: James Powell <jamespo@N0SPAMyahoo.com>
Subject: how to retrieve contents of embedded OLE with win32::ODBC
Message-Id: <35F556C7.CD921512@N0SPAMyahoo.com>
Basically if I have a bitmap embedded in an access database
field, how can I use Perl to extract the pathname?
thanks for any help.
James
--
-------------------------------------------------------
remove N0SPAM from my email address to reply
-------------------------------------------------------
------------------------------
Date: 8 Sep 1998 17:24:29 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: IO::File Permissions - Revisited
Message-Id: <6t3p8d$rfd$1@pegasus.csx.cam.ac.uk>
Bill 'Sneex' Jones <bill@fccj.org> wrote:
>my $fh = new IO::File $file, "a", "0600";
>From perldoc IO::File:
open( FILENAME [,MODE [,PERMS]] )
[snip]
If IO::File::open receives a Perl mode string (">",
"+<", etc.) or a POSIX fopen() mode string ("w", "r+",
etc.), it uses the basic Perl open operator.
If IO::File::open is given a numeric mode, it passes
that mode and the optional permissions value to the Perl
sysopen operator. For convenience, IO::File::import
tries to import the O_XXX constants from the Fcntl
module. ...
Now it doesn't define what it means by "numeric mode", but that reference
to O_XXX constants gives a hint. But sure as hell, "a" isn't
numeric. So it doesn't look at the permissions in that case.
Not that those permissions look too clever - an octal constant might
be more suitable.
But I agree with your implied comment that the documentation could be
made a great deal clearer ...
Mike Guy
------------------------------
Date: 8 Sep 1998 17:48:38 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: localtime and Y2K
Message-Id: <6t3qlm$b7v@mozo.cc.purdue.edu>
abigail@fnx.com (Abigail) writes:
}james_della_porta@ansett.com.au (james_della_porta@ansett.com.au) wrote
}on MDCCCXXXIV September MCMXCIII in <URL: news:6t2gln$95a$1@nnrp1.dejanews.com>:
}++ Hi,
}++ I'm just going through some scripts of mine, and others written
}++ by collegues. I understand that localtime does not give a proper
}++ representation of the year, and that you need to add 1900 to it.
}++ My question is, will this always be the case, or will things change
}++ at some later stage? eg. at the year 2001, will the year from
}++ localtime() return 101, or could it possibly come back with 01?
}Are you really too stupid to read the manual?
}Maybe you should forget about Perl. You will never be able to program
}in Perl if you refuse to read the manual. Pick a hobby more up to your
}skills, like turning stones or so.
Diligence, patience, and humility.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Tue, 08 Sep 1998 11:42:48 -0500
From: Liz Castro <liznet@cookwood.com>
Subject: mkdir and umask
Message-Id: <35F55E6D.E80618F3@cookwood.com>
Here's a question about permissions. According to the Camel book, the mkdir
function is affected by umask. But in my tests, it only seems to be
_partially_ affected by the umask.
For example, if my umask is 22 (which I would assume is pretty normal), and I
use mkdir (directory, 0777), the directory has 755 permissions. So far so
good. But if I say mkdir (directory, 0744), then the permissions are set at
744 (and not 722, which I expected). And if I say mkdir (directory, 0752),
then the permissions are set at 0750, which is bizarre.
How does mkdir really work?
Thanks!
Liz
------------------------------
Date: Tue, 08 Sep 1998 16:30:19 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: mkdir and umask
Message-Id: <35F55D16.76F31C85@shaw.wave.ca>
[posted & mailed]
Liz Castro wrote:
>
> Here's a question about permissions. According to the Camel book, the
> mkdir function is affected by umask. But in my tests, it only seems to
> be _partially_ affected by the umask.
>
> For example, if my umask is 22 (which I would assume is pretty
> normal), and I use mkdir (directory, 0777), the directory has 755
> permissions. So far so good. But if I say mkdir (directory, 0744),
> then the permissions are set at 744 (and not 722, which I expected).
> And if I say mkdir (directory, 0752), then the permissions are set at
> 0750, which is bizarre.
The umask is not subtracted from the permissions, but rather the bits
that are on in the umask are turned off in the permissions.
printf "%o\n", 0777 & ~0022;
printf "%o\n", 0744 & ~0022;
printf "%o\n", 0752 & ~0022;
For more details,
man chmod
man umask
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Tue, 08 Sep 1998 08:51:04 -0700
From: news@russo.org (Chris Russo)
Subject: Re: Perl Programmer Needed
Message-Id: <news-0809980851040001@buzz.hq.alink.net>
In article <S8%I1.2689$JW5.8001506@news.rdc1.md.home.com>, "Richard"
<Richard@WowMe.com> wrote:
[...]
> So far you are the only one who has
>flamed me for this.
I don't want to flame you. Actually, small numbers of perl job postings
to this group don't bother me personally. However, don't get indignant
because a member of this group politely invoked "the rules".
You'll need better justification for being upset with Randal's response
than that.
> Had you done it via email, I would not be upset, I
>would simply stop asking in this group.
Are you familiar with email spammers who use the "opt-out" system? That's
where the spammer grabs your address from some forum (like USENET) and
magnanimously allows you to remove yourself from the mailing list by
replying to the spam with "Remove" in the subject (or somesuch). This is
referred to as an opt-out mailing list. An "opt-in" mailing list is one
which you join by choice.
Do you see the parallel between what you're advocating and an opt-out
mailing list? Rather than taking the burden upon yourself of knowing and
following some rules, you've transferred that burden to the rest of us.
My sympathy lies with those who have unexpected, unwanted, and undeserved
burdens thrust upon them.
I hope you'll reconsider your methods.
Regards,
Chris Russo
--
Chris Russo
news@russo.org
http://www.russo.org
------------------------------
Date: 08 Sep 1998 17:29:31 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: Perl Programmer Needed
Message-Id: <upvd6y3dg.fsf@jimbosntserver.soundimages.co.uk>
roberto@toutatis.net (Roberto) writes:
>
> In article <8c90jvpeig.fsf@gadget.cscaper.com>, Randal Schwartz
> <merlyn@stonehenge.com> wrote:
>
> > As I said, it was for Dejanews. I'm tired of having dozens of
> > inappropriate job postings here, instead of in the groups they belong.
> > I've not seen enough public compaints, so I expect the problem
> > is that no-one sees anyone else taken to task for it.
>
> It might also be people apppreciate it. I recall following a long thread
> about exactly this topic about a year ago, joined by several frequent
> posters. The general opinion ranged between ok, welcomed and *encouraged*,
> as long as they were specifically targeted at perl programmers. After all,
> this is perl _misc_, and I too think perl job postings are a lot more
> appropriate than a lot of other stuff I see here. Allow yourself a break,
> Randall. :-)
>
Where's the problem? The same rules apply for all groups. If other
groups fail to abide by those rules that's their problem. That does
not remove the rules from existence. If this group does adhere to
those rules that is normal behaviour. Why do you feel normal behaviour
is a problem?
--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.
------------------------------
Date: 8 Sep 1998 16:50:50 GMT
From: roberto@toutatis.net (Roberto)
Subject: Re: Perl Programmer Needed
Message-Id: <roberto-ya02408000R0809981851460001@news.euronet.nl>
In article <8cyarun0nr.fsf@gadget.cscaper.com>, Randal Schwartz
<merlyn@stonehenge.com> wrote:
> >>>>> "Roberto" == Roberto <roberto@toutatis.net> writes:
>
> Roberto> It might also be people apppreciate it. I recall following a
> Roberto> long thread about exactly this topic about a year ago, joined
> Roberto> by several frequent posters. The general opinion ranged
> Roberto> between ok, welcomed and *encouraged*, as long as they were
> Roberto> specifically targeted at perl programmers. After all, this is
> Roberto> perl _misc_, and I too think perl job postings are a lot more
> Roberto> appropriate than a lot of other stuff I see here. Allow
> Roberto> yourself a break, Randall. :-)
>
> But you forget, apparently, that the rules for the group are *not* set
> by the group participants.
I seriously question that statement, but don't want to get trapped in an
"off-topic" discussion.
> They're set by the people that actually
> BRING you the news. The news admins around the world. The ones that
> publish the stuff in news.admin.newusers. And *they* are the ones
> that have decreed that job postings go in job groups, regardless of
> the category.
None of the documents I have consulted at
http://www.netannounce.org/news.announce.newusers/ mentions anything about
job postings. Could you be more precise in pointing out the exact location
of this "decrete"?
--
Roberto Bourgonjen,
roberto@toutatis.net
------------------------------
Date: Tue, 08 Sep 1998 17:17:01 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Perl Programmer Needed
Message-Id: <35F56432.FFEF107A@bbnplanet.com>
Goodness. Have a beer, get out your OED and look yourself up under
'insecure'. It really wasn't a big deal. Also, I think if anyone were
seriously interested in the position they certainly aren't anymore. Hey,
at least you punctuated correctly. :)
e.
------------------------------
Date: Tue, 08 Sep 1998 17:24:02 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Perl Programmer Needed
Message-Id: <35F569B9.87CDD7A8@shaw.wave.ca>
Roberto wrote:
>
> In article <8cyarun0nr.fsf@gadget.cscaper.com>, Randal Schwartz
> <merlyn@stonehenge.com> wrote:
> > And *they* are the ones
> > that have decreed that job postings go in job groups, regardless of
> > the category.
>
> None of the documents I have consulted at
> http://www.netannounce.org/news.announce.newusers/ mentions anything
> about job postings. Could you be more precise in pointing out the
> exact location of this "decrete"?
I guess you didn't look very hard. From _How to find the right place to
post (FAQ)_:
2) Commercial Advertisements
The general rule of thumb is that you need to take the time to
learn where your advertisement is appropriate before you post it.
If you are not sure where your advertisement is appropriate, don't
post it. Another good rule of thumb is that unless the group's
charter or FAQ specifically mentions that some limited types of
advertising are welcome, you should assume that no commercial
postings are allowed.
Most Usenet users strongly disapprove of business advertising in
non-business-related groups. In particular, anything that looks
like a pyramid scheme or chain letter will draw floods of critical
e-mail to both you and your machine administrators. Posting about
a few items for sale, or a job opening, in an appropriate newsgroup
(such as misc.forsale.* or misc.jobs.*) is OK; posting an ad for
your business to a hundred groups is not.
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Tue, 08 Sep 1998 07:47:22 -0800
From: Fred_Gurzeler@rand.org (Fred Gurzeler)
Subject: Q: Converting C to Perl
Message-Id: <Fred_Gurzeler-0809980747210001@gurzeler.rand.org>
All,
I am trying to convert a C program into Perl. Why? To see if I can do
it, mostly; I haven't been programming in Perl for very long and my C
skills are beyond rusty. I've amended the C and Perl code to the end of
this post (it's the game Othello). The conversion to Perl should be
relatively straightforward, but aside from adding a $ in front of every
variable, I am having problems passing variables (including an array) from
one function to another. No big whoop, normally, but one of the functions
is recursive and there's quite a bit of array manipulation. I've tried
making variables "local" or "my" and even renaming them, and while I can
get a working program, "working" is relative because the Perl version
doesn't run the same as the C version. Either I'm doing something wrong
or it can't be done. If it can be done, I'm hoping someone will show me
how. If it can't be done (or it can be done but not without rewriting the
entire program), I'd like to know that, too.
Thanks,
Fred
Here's the C code:
/* Othello */
int V[1600],
r[] = {-1,-11,-10,-9,1,11,10,9},
h[] = {11,18,81,88},
ih[]= {22,27,72,77},
bz, lv = 60, m, level, t, y;
/* minimax function with alpha-beta pruning */
Minimax(depth, V, f, _r, alpha, beta)
int V[];
{
int c, j, w, z, i, g, q, k;
int D = depth * 100;
if (depth < (level - 1))
{
j = alpha;
}
else
{
j = -9000;
}
q = 3 - f;
if (depth > level)
{
for (w = i = 0; i < 4; i++)
{
m = V[h[i] + D];
if (m == f)
{
w = w + 300;
}
else if (m == q)
{
w = w - 300;
}
else
{
t = V[ih[i] + D];
if (t == f)
{
w = w - 50;
}
else if (t == q)
{
w = w + 50;
}
}
}
return w;
}
c = 0;
for (z = 11; z < 89; z++)
{
/* find a valid move position */
if (Check_Move(depth, V, z, f, 100))
{
c++;
w = -Minimax(depth+1, V, q, 0, -beta, -j);
if (w > j)
{
g = bz = z;
j = w;
if (w >= beta || w >= 8003)
{
return w;
}
}
}
}
if (c == 0)
{
g=0;
if (_r)
{
/* count number of Xs and Os */
for (k = 11; k < 89; k++)
{
if (V[k + D] == f)
{
c = c + 1;
}
else if (V[k + D] == (3 - f))
{
c = c - 1;
}
}
if (c > 0)
{
return 8000 + c;
}
else
{
return c - 8000;
}
}
y = 111;
for (k = 11; k < 89; k++)
{
V[y++ + D] = V[k + D];
}
j = -Minimax(depth + 1, V, q, 1, -beta, -j);
}
bz = g;
if (depth >= (level - 1))
{
return (j + (c << 3));
}
else
{
return j;
}
}
/* check for valid move */
Check_Move(k, V, z, f, o)
int V[];
{
int j, q, g, i, w, d;
int D = k * 100;
q = 3 - f;
g = 0;
if (V[z + D] == 0)
{
for (i = 7; i >= 0; i--)
{
w = r[i];
j = z + w;
while (V[j + D] == q)
{
j = j + w;
}
if (V[j + D] == f && (V[j - w + D] != V[z + D]))
{
if (g == 0)
{
g = 1;
y = 111;
for (d = 11; d <= 89; d++)
{
V[y++ + D] = V[d + D];
}
}
while (V[j + D] != V[z + D])
{
V[j + o + D] = f;
j = j - w;
}
}
}
}
if (g == 1)
{
V[z + o + D] = f;
}
return g;
}
print_board()
{
int d;
printf("\n1 2 3 4 5 6 7 8\n");
for (d = 11; d < 89; d++)
{
if (V[d] == 0) printf("%s", ". ");
else if (V[d] == 1) printf("%s", "X ");
else if (V[d] == 2) printf("%s", "O ");
if (d%10 == 8)
{
d += 2;
printf(" %d\n", d/10-1);
}
}
}
main() {
for (t = 0; t < 1600; t += 100)
{
for (m = 0; m < 100; m++)
{
if (m < 11 || m > 88 || (m+1)%10 < 2)
{
V[t+m] = 3;
}
else
{
V[t+m] = 0;
}
}
}
printf("Level: ");
t = scanf("%d",&level);
/* Initialize board */
V[44] = V[55] = 1;
V[45] = V[54] = 2;
while ( lv > 0 )
{
print_board();
do
{
printf("\nYou (O): ");
t = scanf("%d",&m);
} while(!Check_Move(0, V, m, 2, 0) && m != 99);
if (m != 99)
{
lv--;
}
if (lv < 15 && level < 10)
{
level += 2;
}
print_board();
printf("\nThinking...\n");
printf("Move value: %d\n", Minimax(0, V, 1, 0, -9000, 9000));
lv = lv - Check_Move(0, V, bz, 1, 0);
printf("Computer moves to: %d\n", bz);
}
/* print the final board */
if (lv == 0)
{
print_board();
}
}
Here's the almost working Perl version:
#!/usr/bin/perl
@r = (-1,-11,-10,-9,1,11,10,9);
@h = (11,18,81,88);
@ih= (22,27,72,77);
$lv = 60;
$bz = 0;
$m = 0;
$level = 0;
$t = 0;
$y = 0;
# minimax function with alpha-beta pruning
sub Minimax
{
my($depth, $f, $_r, $alpha, $beta, @V ) = @_;
local($c, $j, $w, $z, $i, $g, $q, $k) = 0;
$D = $depth * 100;
if ($depth < ($level - 1))
{
$j = $alpha;
}
else
{
$j = -9000;
}
$q = 3 - $f;
if ($depth > $level)
{
for ($w = $i = 0; $i < 4; $i++)
{
$m = $V[$h[$i] + $D];
if ($m == $f)
{
$w = $w + 300;
}
elsif ($m == $q)
{
$w = $w - 300;
}
else
{
$t = $V[$ih[$i] + $D];
if ($t == $f)
{
$w = $w - 50;
}
elsif ($t == $q)
{
$w = $w + 50;
}
}
}
return $w;
}
$c = 0;
for ($z = 11; $z < 89; $z++)
{
# find a valid move
if (&Check_Move($depth, $z, $f, 100, @V ))
{
$c++;
$w = -&Minimax($depth+1, $q, 0, -$beta, -$j, @V );
if ($w > $j)
{
$g = $bz = $z;
$j = $w;
if ($w >= $beta || $w >= 8003)
{
return $w;
}
}
}
}
if ($c == 0)
{
$g=0;
if ($_r)
{
# count number of Xs and Os
for ($k = 11; $k < 89; $k++)
{
if ($V[$k + $D] == $f)
{
$c = $c + 1;
}
elsif ($V[$k + $D] == (3 - $f))
{
$c = $c - 1;
}
}
if ($c > 0)
{
return (8000 + $c);
}
else
{
return ($c - 8000);
}
}
$y = 111;
for ($k = 11; $k < 89; $k++)
{
$y++;
$V[$y + $D] = $V[$k + $D];
}
$j = -&Minimax($depth + 1, $q, 1, -$beta, -$j, @V );
}
$bz = $g;
if ($depth >= ($level - 1))
{
return ($j + ($c << 3));
}
else
{
return ($j);
}
}
# check for valid move
sub Check_Move
{
($k1, $z1, $f1, $o1, @V) = @_;
local($j, $q, $g, $i, $w, $d, $D) = 0;
$D = $k1 * 100;
$q = 3 - $f1;
$g = 0;
if ($V[$z1 + $D] == 0)
{
for ($i = 7; $i >= 0; $i--)
{
$w = $r[$i];
$j = $z1 + $w;
while ($V[$j + $D] == $q)
{
$j = $j + $w;
}
if ($V[$j + $D] == $f1 && ($V[$j - $w + $D] != $V[$z1 + $D]))
{
if ($g == 0)
{
$g = 1;
$y = 111;
for ($d = 11; $d <= 89; $d++)
{
$y++;
$V[$y + $D] = $V[$d + $D];
}
}
while ($V[$j + $D] != $V[$z1 + $D])
{
$V[$j + $o1 + $D] = $f1;
$j = $j - $w;
}
}
}
}
if ($g == 1)
{
$V[$z1 + $o1 + $D] = $f1;
}
return ($g);
}
sub print_board
{
local($d);
printf("\n1 2 3 4 5 6 7 8\n");
for ($d = 11; $d < 89; $d++)
{
if ($V[$d] == 0) { printf("%s", ". "); }
elsif ($V[$d] == 1) { printf("%s", "X "); }
elsif ($V[$d] == 2) { printf("%s", "O "); }
if ($d%10 == 8)
{
$d += 2;
printf(" %d\n", $d/10-1);
}
}
}
sub main
{
for ($t = 0; $t < 1600; $t += 100)
{
for ($m = 0; $m < 100; $m++)
{
if ($m < 11 || $m > 88 || ($m+1)%10 < 2)
{
$V[$t+$m] = 3;
}
else
{
$V[$t+$m] = 0;
}
}
}
printf("Level: ");
$level = <STDIN>;
chop($level);
# Initialize board
$V[44] = $V[55] = 1;
$V[45] = $V[54] = 2;
while ( $lv > 0 )
{
&print_board;
do
{
printf("\nYou (O): ");
$m = <STDIN>;
chop($m);
} while(!&Check_Move(0, $m, 2, 0, @V) && $m != 99);
if ($m != 99)
{
$lv--;
}
if ($lv < 15 && $level < 10)
{
$level += 2;
}
&print_board;
printf("\nThinking...\n");
printf("Move value: %d\n", &Minimax(0, 1, 0, -9000, 9000, @V));
$lv = $lv - &Check_Move(0, $bz, 1, 0, @V);
printf("Computer moves to: %d\n", $bz);
}
# print the final board
if ($lv == 0)
{
&print_board;
}
}
&main;
exit(0);
------------------------------
Date: Tue, 08 Sep 1998 11:00:37 -0500
From: shane michael harwood <sharwood@cs.uiowa.edu>
Subject: read a file through HTTP
Message-Id: <35F554A5.41C6@cs.uiowa.edu>
is there a way for a CGI script to get the contents
of a file that isn't on the same server as the cgi script
i want to do something like this.
$file= $FORM{'filename'};
open(PIRFILE, $file);
$contents = <PIRFILE>;
close (PIRFILE);
with $file equal to something like http://cs.uiowa.edu/sample.pir
------------------------------
Date: 8 Sep 1998 16:41:26 GMT
From: "Steve Debenport" <steve.debenport@us.coopers.com>
Subject: skipping lines
Message-Id: <6t3mnm$24q$1@news-2.news.gte.net>
SG93IGRvIEkgd2l0aGluIGEgJ1doaWxlICg8PiknIGFuZCAnaWYnIHN0YXRlbWVudCwgc2tpcCBh
IGNvdXBsZSBvZiBsaW5lcyBhdCBhIGNlcnRhaW4gcG9pbnQgd2hpbGUgc3RlcHBpbmcgdGhyb3Vn
aCBhIHRleHQgZmlsZS4gIEkgdGhvdWdodCB0d28gc2ltcGxlICc8Picgd291bGQgd29yaywgYnV0
IGl0IGRvZXNuJ3Qgc2VlbSB0by4gIEFueSBpZGVhcz8gIFRoYW5rcy4NClN0ZXZlIERlYmVucG9y
dCANClN0ZXZlLkRlYmVucG9ydEB1cy5wd2NnbG9iYWwuY29tDQo=
------------------------------
Date: Tue, 8 Sep 1998 13:51:49 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: skipping lines
Message-Id: <MPG.105f388add2d384998968f@news.south-carolina.net>
[This followup was posted to comp.lang.perl.misc and a copy was
sent to the cited author.]
In article <6t3mnm$24q$1@news-2.news.gte.net> on 8 Sep 1998
16:41:26 GMT, Steve Debenport (steve.debenport@us.coopers.com)
pounded in the following text:
=> SG93IGRvIEkgd2l0aGluIGEgJ1doaWxlICg8PiknIGFuZCAnaWYnIHN0YXRlbWVudCwgc2tpcCBh
=> IGNvdXBsZSBvZiBsaW5lcyBhdCBhIGNlcnRhaW4gcG9pbnQgd2hpbGUgc3RlcHBpbmcgdGhyb3Vn
=> aCBhIHRleHQgZmlsZS4gIEkgdGhvdWdodCB0d28gc2ltcGxlICc8Picgd291bGQgd29yaywgYnV0
=> IGl0IGRvZXNuJ3Qgc2VlbSB0by4gIEFueSBpZGVhcz8gIFRoYW5rcy4NClN0ZXZlIERlYmVucG9y
=> dCANClN0ZXZlLkRlYmVucG9ydEB1cy5wd2NnbG9iYWwuY29tDQo=
=>
=>
# This is what we see ^.
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: base64
X-Newsreader: Microsoft Internet News 4.70.1161
Please don't do this.
If you can't configure MS stuff to post plain text, please don't
use it!
--Matthew
Just trying to help...
------------------------------
Date: Tue, 08 Sep 1998 16:57:04 +0100
From: Robert Saunders <saunder@kben.co.uk>
Subject: Re: Splitting code across several files.
Message-Id: <35F553D0.C5F26034@kben.co.uk>
<<my stuff cut>>
>You mean like this?
>
> mainfile:
>
> require "fred.pl";
> &Fred::break_in();
> &Fred::apologize();
>
> file fred.pl:
>
> package Fred;
> require "barney.pl";
> sub break_in {
> for my $host (@hosts) {
> for my $password (@passwords) {
> &try($host, $password);
> }
> }
> }
> sub apologize {
> ...
> }
> ...
> 1;
>
> file barney.pl;
>
> package Fred;
> @hosts = qw(host1 host2 host3);
> @passwords = qw(guessme changeme none);
> ...
> 1;
>
>Of course, if you want it to work with "use", change that fred.pl to
>Fred.pm and set up the export list. But barney.pl can stay the same.
Thanks for the above. I am one of those people who likes 'use strict;' to check my
typing of variable names etc. It seems to me though that I can't have this with the
files split like this because, although the barney file and the fred file are the
same package, a 'my @hosts' in barney.pl makes @hosts private to the file barney.pl
not the package Fred. Am a right in thinking this?
Robert
------------------------------
Date: 8 Sep 1998 17:33:18 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Splitting code across several files.
Message-Id: <6t3pou$t6m$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Robert Saunders <saunder@kben.co.uk> writes:
:Thanks for the above. I am one of those people who likes 'use strict;' to check my
:typing of variable names etc. It seems to me though that I can't have this with the
:files split like this because, although the barney file and the fred file are the
:same package, a 'my @hosts' in barney.pl makes @hosts private to the file barney.pl
:not the package Fred. Am a right in thinking this?
You are. Only package variables (a.k.a globals) can be shared between
files by name. Lexicals can't.
--tom, who doesn't like to admit that you actually can manually export
lexicals; you just can't import them.
--
Besides, REAL computers have a rename() system call. :-)
--Larry Wall in <7937@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 8 Sep 1998 17:01:26 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Stripping out 'bad' HTML
Message-Id: <6t3nt6$p40$1@client3.news.psi.net>
Jeremy Goldberg (jgoldberg@dial.pipex.com) wrote on MDCCCXXXIII September
MCMXCIII in <URL: news:6t06kf$q3p$1@plug.news.pipex.net>:
++ Does anyone have a decent algorithm (or a module, hint, hint) to take text
++ and strip out 'bad' HTML e.g. "3 < 5" (which should be written as "3 <
What is bad about "3 < 5"?
++ 5") without stripping 'good' HTML e.g. "<b>3 is less than 5</b>"? It would
++ be good to allow users to put in HTML (in news articles, say, or message
++ board articles) without letting them wreck their HTML utterly.
I can't parse this. If they put in HTML, then what's wrong with that?
++
++ Any ideas gratefully appreciated.
++
++ - Jeremy (fix the email address to reply)
Spam bait: jgoldberg@dial.pipex.com
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: Tue, 8 Sep 1998 12:35:18 -0400
From: "Thomas Wong" <twong@exchange.ml.com>
Subject: uname -r
Message-Id: <6t3mej$bui$1@news.ml.com>
All,
Is there a built-in perl function to get the OS release version instead of
using something like system ("uname -r"). thx
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3660
**************************************