[12454] in Perl-Users-Digest
Perl-Users Digest, Issue: 6055 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 19 11:33:29 1999
Date: Sat, 19 Jun 99 02:00:19 -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 Sat, 19 Jun 1999 Volume: 8 Number: 6055
Today's topics:
Re: Afraid to ask about Y2K! (Abigail)
Re: Afraid to ask about Y2K! (n.o. s.p.a.m, m.a.a.m.)@ix.netcom.com (Clifford Orlofsky)
Re: Afraid to ask about Y2K! (Bart Lateur)
Re: ANN: Grabbing daily cartoons <sb@sdm.de>
Re: Beginner program (Tad McClellan)
Re: FREE Mp3 Site... here you can even upload your song (Dave Cross)
Re: HOWTO compare two arrays, an get the difference (Bart Lateur)
Re: importing comma-delimited data into perl? <monty@primenet.com>
Re: Is Perl4 Y2K compliant? (Dave Cross)
Re: Match diff with '\s*' vs ' ' (Tad McClellan)
Re: Match diff with '\s*' vs ' ' (Abigail)
Re: odd autoincrement behavior ? (Bart Lateur)
Parsing bug in Perl? (Sean McAfee)
Re: Parsing bug in Perl? (Sean McAfee)
Re: Parsing bug in Perl? <rootbeer@redcat.com>
Re: Parsing bug in Perl? (Bart Lateur)
Re: pattern match by column (Bart Lateur)
Re: Perl "constructors" armchair@my-deja.com
Re: Perl "constructors" armchair@my-deja.com
Re: Perl "constructors" zenin@bawdycaste.org
Re: Perl and artificial intelligence. (Abigail)
Re: Printing compound variables (explanation) (Lee)
Win32::NetAdmin::UserChangePassword <mstone@mountaincreek.com>
Re: Writing RTF with Perl (Bart Lateur)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Jun 1999 22:20:14 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <slrn7mm33a.gnv.abigail@alexandra.delanet.com>
Lee (rlb@intrinsix.ca) wrote on MMCXVIII September MCMXCIII in
<URL:news:B39058EA96686CD2B@0.0.0.0>:
{} In article <7keldd$7e7$1@fcnews.fc.hp.com>,
{} ada@fc.hp.com (Andrew Allen) wrote:
{}
{} >Lee (rlb@intrinsix.ca) wrote:
{} >: In Perl, I *expect* to find the imaginary humantime() function. This is one
{} >: of the few times it has left me disappointed.
{} >
{} >Something other than POSIX::strftime?
{}
{} I know (or suspect, I've never actually used any of them) that there are at
{} least three modules that give this functionality. But it seems such a
{} common need/desire that it shouldn't require a module. Or am I being a
{} silly git again?
What's the fear for a module?
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sat, 19 Jun 1999 08:18:15 GMT
From: Orlofsky(n.o. s.p.a.m, m.a.a.m.)@ix.netcom.com (Clifford Orlofsky)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <376b4803.11350654@nntp.ix.netcom.com>
On Tue, 15 Jun 1999 14:22:49 GMT, finsol@ts.co.nz wrote:
[ huge snip]
>For some examples, check out the following URL:
>http://www.idg.co.nz/WWWfeat/Y2000/ja190499.htm
>
[snip]
>
>Jocelyn Amon
>
>--
>Financial Solutions Limited
>http://www.ts.co.nz/~finsol/
[snip]
Quoting from the above (your) website:
>Leap year: An application may have a requirement to determine whether or not the year is a
> leap year. Incorrect determination of a leap year can occur where a programmer does not
> know the leap year rules. A leap year is determined, in most cases, by checking if the year is
> evenly divisible by four. If it is, then the year is assumed to be a leap year. This will give the
> correct result for the year 2000. However, for the year 1900 this does not work and
> therefore some calculations have had additional accuracy added by determining whether the
> year is the first year of a century by determining if it is evenly divisible by 100. If so, then it is
> assumed that the year is not a leap year. However, the first year in a century is a leap year if it
> is evenly divisible by 400 and some programmers have failed to make this additional check.
> Where the division by 100 test is performed but the division by 400 check is not made, the
> year 2000 will not be determined as being a leap year.
What bothers me is the last sentence. Am I missing something here? If
only the divide by 4 test and the divide by 100 test are performed,
then the year 2000 WILL be "determined as being a leap year."
The divide by 400 test would succeed for the year 2000 anyway. It's
important for determining leap-ness for 1800, 1900, 2100, 2200, etc.
Based on the way you've clumsily worded this example, you fooled
yourself into writing that last line in error. Your own syntax has
tripped you up. Does anyone proofread your web pages before they're
posted? Wait. That would be a peer review. Nevermind.
It's no wonder you're having a problem convincing people in this N.G.
(BTW, years ending in "00" are not the first year of a century. They
are the last year of a century. There was no year 0. We started
counting years with year 1. (But we understand what you meant.)
[Standard rant about year 2000 is NOT the millenium.] )
------------------------------
Date: Sat, 19 Jun 1999 08:23:51 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <376b52d8.230300@news.skynet.be>
Abigail wrote:
>What's the fear for a module?
Separate searching for the file. Separate reading of the file. Separate
compilation. All waste *some* time.
I find the "fear of a module" even slightly more sensible, than the fear
of eval (once). Of course, it's difficult to becnhmark, as you can't
"use" a module over and over again, in order to get a reliable
benchmark. At the least, disk caching would kick in.
Bart.
------------------------------
Date: 19 Jun 1999 08:17:01 GMT
From: Steffen Beyer <sb@sdm.de>
Subject: Re: ANN: Grabbing daily cartoons
Message-Id: <7kfjlt$go9$1@solti3.sdm.de>
In comp.lang.perl.misc Steffen Beyer <sb@sdm.de> wrote:
> I made a nice little set of scripts for downloading daily cartoons
> (e.g. Dilbert, UserFriendly and Calvin&Hobbes), maintaining an archive
> (sorted by date) of them and viewing the images via a CGI script.
I have applied some considerable improvements to these scripts in the
meantime, so you people out there I saw in my server's log file who
have downloaded this scripts suite already might want to download
this newer version as well. The new file now has 3533 bytes.
URL: http://www.engelschall.com/u/sb/scripts/cartoons.tools.tar.gz
Enjoy!
Best regards,
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/
http://www.engelschall.com/u/sb/download/
http://www.perl.com/CPAN/authors/id/STBEY/
http://www.oreilly.de/catalog/perlmodger/bnp/
------------------------------
Date: Fri, 18 Jun 1999 19:55:27 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Beginner program
Message-Id: <f9mek7.o3n.ln@magna.metronet.com>
Amir Schricker (amirs@uclink4.berkeley.edu) wrote:
: Maximum at x
: mean = y
: where x and y are some numbers.
^^^^^^^
What is a number for your application?
I am going to assume positive integer.
: I want to write a Perl script to go and extract those numbers (x and y)
: from only those lines.
while (<>) {
print "max is $1\n" if /^Maximum at\s*(\d+)$/;
print "mean is $1\n" if /^mean =\s*(\d+)$/;
}
: I need to
: extract just the numbers out. Any ideas how?
Capturing parenthesis, aka "backreference".
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 19 Jun 1999 08:30:35 GMT
From: dave@dave.org.uk (Dave Cross)
Subject: Re: FREE Mp3 Site... here you can even upload your songs
Message-Id: <376c551d.2347755@news.demon.co.uk>
On Saturday, 19 Jun 1999 05:21:14 -0600, nobody@nowhere33.yet wrote:
>www.mediterranei.it/mp3
Did you have a Perl question?
--
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>
------------------------------
Date: Sat, 19 Jun 1999 07:25:37 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: HOWTO compare two arrays, an get the difference
Message-Id: <376c3ed7.1657087@news.skynet.be>
Torfinn Keringen wrote:
>I have @array1 @array2, both of them contains a few lines of text,
>what I want is an @array3 containing the lines from @array1
>that is missing in @array2
I've posted a snippet a few monts ago, that allows you to determine the
use of any keyword in a series of arrays. Abigail didn't like it. Here
it is again, anyway. It is easily extended to more (3, 4, ...) arrays.
The only difficulty I see is how to know the mask you need for a
particular array.
my $bitmask = 1;
my %presence;
foreach $ary (\@array1,\@array2) {
foreach (@$ary) {
$presence{$_} |= $bitmask;
}
} continue {
$bitmask *= 2;
}
@only_in_1 = grep { $presence{$_}==1 } keys %presence;
@only_in_2 = grep { $presence{$_}==2 } keys %presence;
@in_both = grep { $presence{$_}==3 } keys %presence;
Bart.
------------------------------
Date: 19 Jun 1999 07:37:49 GMT
From: Jim Monty <monty@primenet.com>
Subject: Re: importing comma-delimited data into perl?
Message-Id: <7kfhcd$147$1@nnrp03.primenet.com>
Kate Roberts <kate.roberts@lib.monash.edu.au> wrote:
> I have a file containing comma-delimited data (exported from EXCEL),
> egmyfile... "field1-wanted later","field2","field3-wanted"
> "field1-wanted later","field2","field3-wanted"
> "field1-wanted later","field2","field3-wanted"
> which I want to bring into perl, filter out most of the fields, and
> then output the fields of interest.
>
> I had thought that since you can assign separate fields to a list-array
> as follows:
> @listarray = ("field1-wanted later","field2","field3-wanted");
>
> that it might also be possible to first put each line from the file into
> a scalar, and then replicate the pattern above using that scalar
> eg
> open (FILEHANDLE, "myfile");
> while ($scalar1 = <FILEHANDLE>) {
> chomp $scalar1;
> @listarray1 = ($scalar1); #This line should be equivalent to above
> print "$listarray1[0]\n";
> print "$listarray1[2]\n";
> }
> close(FILEHANDLE);
>
> It doesn't work, though.
> Can anyone advise me on how to achieve importing this data?
Kate,
Others have posted more correct answers to the question of how,
generally, to parse CSV text with Perl. But since you seem to be
struggling to learn Perl, and since you posted a specific case that
does not itself require one of the more sophisticated solutions,
I offer this simple script that, at least for your example data,
works:
#!/usr/bin/perl -w
while (<DATA>) {
chomp;
s/^"//;
s/"$//;
@fields = split /","/; # presumes all values are enclosed in quotes
for ($i = 0; $i <= $#fields; $i++) {
$fields[$i] =~ s/[\\"]"/"/g;
printf "record %d, field %d: %s\n", $., $i + 1, $fields[$i];
}
}
__END__
"field1-wanted later","field2","field3-wanted"
"field1-wanted later","field2","field3-wanted"
"field1-wanted later","field2","field3-wanted"
"one, ""uno""","two, ""dos""","three, ""tres"""
"one, \"un\"","two, \"deux\"","three, \"trois\""
The program produces this output:
record 1, field 1: field1-wanted later
record 1, field 2: field2
record 1, field 3: field3-wanted
record 2, field 1: field1-wanted later
record 2, field 2: field2
record 2, field 3: field3-wanted
record 3, field 1: field1-wanted later
record 3, field 2: field2
record 3, field 3: field3-wanted
record 4, field 1: one, "uno"
record 4, field 2: two, "dos"
record 4, field 3: three, "tres"
record 5, field 1: one, "un"
record 5, field 2: two, "deux"
record 5, field 3: three, "trois"
It should be obvious to you that this only works for the trivial
case where every field value is a doublequoted string (as opposed
to, say, an unquoted number). The line
$fields[$i] =~ s/[\\"]"/"/g;
replaces all quoted doublequotes (i.e., doublequotes preceded by
either another doublequote or a backslash) with a single doublequote.
I recommend this program for pedagogical purposes only, and even
then with some reservation. (I'm new at this, too.)
Wanna make your life easier? Save the data in Excel as ASCII text
using tabs to separate columns and {none} to enclose values. Then
either use
split /\t/;
or the Unix command cut.
By the way, Perl is a programming language, not an application.
You don't "bring into" or "import into" Perl. Perl "reads" its
input. Learning the lingo helps learning the language. ;-)
--
Jim Monty
monty@primenet.com
Tempe, Arizona USA
------------------------------
Date: Sat, 19 Jun 1999 08:25:35 GMT
From: dave@dave.org.uk (Dave Cross)
Subject: Re: Is Perl4 Y2K compliant?
Message-Id: <376b5391.1952089@news.demon.co.uk>
On 18 Jun 1999 09:40:08 -0500, abigail@delanet.com (Abigail) wrote:
>Dave Cross (dave@dave.org.uk) wrote on MMCXVII September MCMXCIII in
><URL:news:376A00E6.92B526FF@dave.org.uk>:
>||
>||
>|| "Daniel W. Burke" wrote:
>|| >
>|| > Hopefully I can wade through all these messages to see the response...
>|| > but, can perl4 be considered "Y2K Compliant"? I imagine so, but we have
>|| > an aweful lot of scripts at work that run off perl4/oraperl...
>|| > I don't think anyone else has thought to ask at work wether or not we should
>|| > take the time to make sure all the scripts work with perl 5, and just update
>|| > the darn things, but I figured better I better ask :)
>||
>|| "There are no plans to make Perl 4 Y2K compliant."
>
>
>There are no plans to make Perl 5 Y2K compliant either.
Oh, I know that, but as the point is to gently nudge the people still
using Perl 4 over to Perl 5, I think it's probably best that we don't
mention it too often :-)
Dave...
>
>Abigail
--
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>
------------------------------
Date: Fri, 18 Jun 1999 19:46:06 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Match diff with '\s*' vs ' '
Message-Id: <unlek7.o3n.ln@magna.metronet.com>
David Pautler (pautler@hawaii.edu) wrote:
: I'm new to Perl and using egrep to try to understand problems in my
: regexprs.
Why not just use perl itself in an "egreppish way"?
: Below, I'm getting a successful match with a regexpr that ends in ' <',
: but a regexpr that's the same except for ending in '\s*<' is failing. I
: can only guess that this has something to do with the greediness of
: '\s*'.
: /disk1/users/pautler% egrep "Availability\s*</B>\s*:? <"
: bc-Perl5Peschko1.htm
perl -ne 'print if m#Availability\s*</B>\s*:? <#' bc-Perl5Peschko1.htm
: /disk1/users/pautler% egrep "Availability\s*</B>\s*:?\s*<"
: bc-Perl5Peschko1.htm
perl -ne 'print if m#Availability\s*</B>\s*:?\s*<#' bc-Perl5Peschko1.htm
: Would someone explain why one match works and the other doesn't?
It works for both with perl.
Maybe you should ask about egrep in one of the Unix newsgroups.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 18 Jun 1999 22:18:46 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Match diff with '\s*' vs ' '
Message-Id: <slrn7mm30j.gnv.abigail@alexandra.delanet.com>
David Pautler (pautler@hawaii.edu) wrote on MMCXVII September MCMXCIII in
<URL:news:376ACF69.518198BA@hawaii.edu>:
~~ I'm new to Perl and using egrep to try to understand problems in my
~~ regexprs.
~~
~~ Below, I'm getting a successful match with a regexpr that ends in ' <',
~~ but a regexpr that's the same except for ending in '\s*<' is failing. I
~~ can only guess that this has something to do with the greediness of
~~ '\s*'.
No. Why are you using '\s*<' if all you want to match is ' <'?
You want to match a space, a less then sign, and the end of the string.
Nothing special going on. Just write down what you want to match:
/ <$/
A space, a less then sign and the end of the string.
Don't make things more difficult then they are.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sat, 19 Jun 1999 07:25:35 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: odd autoincrement behavior ?
Message-Id: <376b3cf9.1179734@news.skynet.be>
Abigail wrote:
>,, >That's because you have a syntax error.
>Duh! I was assuming you couldn't omit the parens.
In Perl, it's never safe to assume anything. One of it's shortcomings:
it's easy to oversee existing syntax errors, or to imagine a syntax
error where there isn't one.
Bart.
------------------------------
Date: Sat, 19 Jun 1999 07:52:24 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Parsing bug in Perl?
Message-Id: <Y_Ha3.1452$FK.31245@news.itd.umich.edu>
I thought I had achieved a pretty solid foundation in Perl, but this
problem has me mystified. Consider the following simple program:
sub foo { 4 } sub bar { foo <=> 5 }
Compilation fails with the following error:
Number found where operator expected at -e line 1, near "<=> 5"
(Missing operator before 5?)
syntax error at -e line 1, near "<=> 5"
Execution of -e aborted due to compilation errors.
Just as strangely, if I replace "<=>" with either "<" or "<=", I get this
error message:
Unterminated <> operator at -e line 1.
The program works (well, compiles, anyway) if the operator is ">", ">=", or
any of the string comparison operators. Compilation also succeeds if I
replace "foo" with "foo()", but this doesn't really help me because the
program I'm writing builds a subroutine on the fly from user input, and I
don't want the user to have to put parentheses after the function name.
I must sorrowfully conclude that these problems are due to a bug in Perl's
parser. Can someone more familiar with the source than I am confirm this?
Oh, I'm using version 5.005_02 on Solaris 2.6. The problem also occurs on
Linux (specifically, i686-linux, according to "perl -v").
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: Sat, 19 Jun 1999 08:05:47 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Parsing bug in Perl?
Message-Id: <vbIa3.1453$FK.31331@news.itd.umich.edu>
In article <Y_Ha3.1452$FK.31245@news.itd.umich.edu>, I wrote:
>sub foo { 4 } sub bar { foo <=> 5 }
>Compilation fails with the following error:
>Number found where operator expected at -e line 1, near "<=> 5"
> (Missing operator before 5?)
>syntax error at -e line 1, near "<=> 5"
>Execution of -e aborted due to compilation errors.
>Just as strangely, if I replace "<=>" with either "<" or "<=", I get this
>error message:
>Unterminated <> operator at -e line 1.
...and just as I was in the middle of submitting a bug report with perlbug,
I found that the program compiles successfully if I define foo like so:
sub foo () { 4 }
This solves my immediate problem, so I'm holding off on the bug report for
the time being. It would still be nice to know if the behavior *is*
actually a bug, as I supposed. Anyone?
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: Sat, 19 Jun 1999 01:32:20 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Parsing bug in Perl?
Message-Id: <Pine.GSO.4.02A.9906190124390.15039-100000@user2.teleport.com>
On Sat, 19 Jun 1999, Sean McAfee wrote:
> I thought I had achieved a pretty solid foundation in Perl, but this
> problem has me mystified. Consider the following simple program:
>
> sub foo { 4 } sub bar { foo <=> 5 }
>
> Compilation fails with the following error:
>
> Number found where operator expected at -e line 1, near "<=> 5"
> (Missing operator before 5?)
Yup. foo, as an unprototyped sub, expects a list of arguments following.
So, when the parser sees (the second) 'foo', the next item after that must
be an argument list. And so it is: a funny-looking glob (I guess). Of
course, you can't have a number after that, so the parser gives up.
> Just as strangely, if I replace "<=>" with either "<" or "<=", I get this
> error message:
>
> Unterminated <> operator at -e line 1.
Yes, the parser was looking for a term there.
> The program works (well, compiles, anyway) if the operator is ">",
> ">=", or any of the string comparison operators.
Yes, since those don't look like terms, the parser backs up and tries
assuming that by 'foo' you meant '&foo()' - which you did.
As you said in your later post, explicitly using an empty prototype will
fix the confusion - on your part, that is; perl was never confused. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 19 Jun 1999 08:45:42 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Parsing bug in Perl?
Message-Id: <376c54c3.721110@news.skynet.be>
Sean McAfee wrote:
>>sub foo { 4 } sub bar { foo <=> 5 }
>>Compilation fails
>I found that the program compiles successfully if I define foo like so:
>
>sub foo () { 4 }
>
>This solves my immediate problem, so I'm holding off on the bug report for
>the time being. It would still be nice to know if the behavior *is*
>actually a bug, as I supposed. Anyone?
I'd say it is. This works:
sub foo { 4 };
print foo;
so a bareword function call IS legal (and it prints "4").
This works too:
sub foo { 4 }
sub bar { foo() <=> 5 }
print bar;
which prints "-1".
Only, this doesn't compile:
sub foo { 4 }
sub bar { foo <=> 5 }
print bar;
altough the other tests show this indeed this ought to be considered
legal Perl. I'm not sure if it really matters that much, anyway.
Barewords as function calls are a bit of a dubious practise, in my book.
Nevertheless, it is being used by modules, such as constant.pm.
use constant foo => 4;
sub bar { foo <=> 5 }
print bar;
That does NOT fail, probably because of the function prototype for the
closure, the same as in your fix.
Bart.
------------------------------
Date: Sat, 19 Jun 1999 07:26:17 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: pattern match by column
Message-Id: <377045d4.3446378@news.skynet.be>
Abigail wrote:
>s/^(.{79})0101/${1}9999/;
Doesn't work if one of the first 79 characters is a newline. Er... I
*think* that's the only exception.
And I like the substr() solution (as per the Cookbook; see other
replies) much better. Terribly neat hack.
Bart.
------------------------------
Date: Sat, 19 Jun 1999 06:03:19 GMT
From: armchair@my-deja.com
Subject: Re: Perl "constructors"
Message-Id: <7kfbr4$kd5$1@nnrp1.deja.com>
In article <929485198.150138@thrush.omix.com>,
zenin@bawdycaste.org wrote:
> armchair@my-deja.com wrote:
> : In article <7k3d72$u1n$1@nnrp1.deja.com>,
> : John Porter <jdporter@min.net> wrote:
> >snip<
> :> Hmm, maybe Foo needs to modify its inheritance tree at runtime:
> :>
> :> unshift @Foo::ISA, 'Quux';
> :
> : I'll bet that practice has a lot of proponents in Object Oriented
> : Symposiums.
>
> If you want SmallTalk, you know where to find it.
If Smalltalk doesn't allow classes in a heirarchy to be discarded at
runtime, it is not alone.
> : It certainly does show how much more complex the Perl class
implementation
> : is.
>
> Or more astutely, how much more flexible the Perl object model
> is.
I don't see how Perl's object model is more flexible than C++. Can you
describe it in terms of object oriented concepts like "member data,
methods, inheritance, instantiation"?
> :> Not unable, just unwilling.
> :> Stories, like newsgroup threads, don't end just because someone
> :> declares them ended.
> :
> : Didn't say the story ended, just that you were unable to
> : write assembler
> : code that was anywhere equivalent to:
> : int i = 0,j =0;
> : for ( ; i < 10; i++)
> : for ( ; j < 10; j++)
> : print ("i/j %d/%d\n",i,j);
>
> Of course the equivalent asm can be written for the above,
> but what
> would the exercise prove? Even if the asm was 100k LOC,
> it would
> still not prove that C is "higher level" then asm. -It is, but your
> exercise would not prove it.
Why would it not prove it?
>
> The definition of a "high(er) level" language is one that more
> closely resembles human thought, logic, and process then a machine's
> logic and process. Total LOC are irrelevant to that end.
Then it wouldn't prove it because it is many many lines of code less,
but by demonstrating how C code "more closely resembles human though,
logic, and process then a machine's logic and process" than Assembler
code.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Sat, 19 Jun 1999 05:52:59 GMT
From: armchair@my-deja.com
Subject: Re: Perl "constructors"
Message-Id: <7kfb7r$k8k$1@nnrp1.deja.com>
In article <7k5smg$pib$1@nnrp1.deja.com>,
John Porter <jdporter@min.net> wrote:
> In article <7k5chd$jb9$1@nnrp1.deja.com>,
> armchair@my-deja.com wrote:
> > In article <7k30op$p12$1@nnrp1.deja.com>,
> > John Porter <jdporter@min.net> wrote:
> > >
> > > Perl is little more than a programming language,
> > > although it is a great one.
> >
> > my concern is that you consider Perl more than just
> > a programming language. And above, you admit to that fact.
>
> And your opinion of C and C++ is different, how?
> You have claimed, repeatedly, that C is not comparable to asm on
> the basis of the quality/quantity of its available support tools.
> If these things can be considered part of "the C language",
> then I can confidently say that Perl is truly nothing more than a
> programming language.
Actually, the truth is slightly different. I have never made any claims
about C being better than assember based on the quantity/quality of it's
support tools. What I have done is repeatedly ask you to supply
Assembler code that is equivalent to a C nested for loop, since you
contend the two are equivalent languages. I am very glad to see you say
above "Perl is truly nothing more than a programming language". If I may
quote Dilbert - "The healing has begun."
>
> > Can't we talk about how C++ "models the real
> > machine" while Perl "models a virtual machine"??
>
> Actually C++ does a half-way decent job of trying to model something
> a little more abstract than the real machine.
What would C++ need to make it all the way to modeling an abstract
machine?
>
> > Why does your "C is
> > portable assember" "argument" not apply to C++.
>
> I am simply recognizing the design motivations for those languages,
> and also that they have achieved their design goals with some
> considerable degree of success.
How does that answer the question above? C++ is a superset of C. It
compiles C code. C is portable assember per you, thus C++ must be object
oriented portable assember.
>
> > > Anything in C++ that is not in Perl is not necessary in a
> > > high-level language.
> >
> > I hope you tell that to the programmers writing fields.pm and other
> > modules for function overloading and operator overloading.
>
> Some people, especially recovering C++ programmers, find these things
> desirable. Necessary: not.
So those modules were written by recovering C++ programmers, and now
that they have recovered they no longer use them. Would you agree then
that those modules should be removed from CPan and the Perl
distribution?
>
> > I am glad to see that they agree with me, and not you.
>
> Rather than assume that they do, perhaps you should ask them.
It doesn't surprise me that you would think that you would need to ask
people adding features to Perl that I champion, whether we agree on if
they are good things. After all, you are the "C is Portable Assembler"
fellow.
>
> > I have never programmed in assembler.
>
> Well that explains a lot.
Ah, then assembler is what did it to you.
>
> > I give credit to Perl
>
> Heh, Perl doesn't need your credit. Thanks anyway.
But Perl graciously accepts my credit, rather than sullenly tossing them
aside while simultaenously claiming that C is not portable assembler,
and that it is. So it is Perl that I will be buying a drink at the next
LinuxWorld.
>
> > ... for giving me new ideas
>
> I suppose that's the best outcome we can hope for here.
Don't give up. There is still much more time to demonstrate that C is
"merely portable assembler".
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 19 Jun 1999 07:56:51 GMT
From: zenin@bawdycaste.org
Subject: Re: Perl "constructors"
Message-Id: <929779213.912580@thrush.omix.com>
armchair@my-deja.com wrote:
>snip<
:> It's true that objects have primacy over classes in Perl, which is
:> the opposite of C++.
:
: I don't know what this means. Can you give an example to illustrate the
: point you are trying to make?
>snip<
:> And it shows that Perl is more powerful than C++ in this one
:> specific respect at least.
:
: I have forgotten what the respect was. Above I see
: $foo = bless {}, 'Foo';
: You are going to put this "class" up as an example of Perl's power?
That's just it (to reply to both your comments above), the above
code isn't a class, it's an object. The class doesn't have to exist
at all in Perl (of course, neither does the object). The semantics
of what makes up objects is explicit, while the semantics of what
makes up a class is more vague.
:> > > Make undefined method calls do something useful:
:> > >
:> > > sub Foo::AUTOLOAD {
:> > > my $self = shift;
:> > > my $name = $Foo::AUTOLOAD;
:> > > $name =~ s/.*:://; # strip the qualification
:> > > $self->{'contained_object'}->$name( @_ );
:> > > }
:> >
:> > Don't know what this is doing, but it again appears that Perl objects
:> > have a lot of complexity to them versus the much simpler C++.
:>
:> It only appears complex to you *because* you don't know what's going on.
:> It's really not bad at all. And it is a powerful, useful feature which
:> C++ programmers could only dream of.
:
: So what does it do that you couldn't do in C++. Explain your benefit.
Automatic delegation for one. Similar to inheritance, but when
$foo *contains* a Bar object but doesn't subclass it:
package Foo;
use Bar;
sub new {
bless { bar => Bar->new() }, shift;
}
sub someFooMethod {}
sub AUTOLOAD {
my $self = shift;
my $method = $AUTOLOAD;
$method =~ s/.*:://;
$self->{bar}->$method (@_);
}
....time passes....
my $foo = Foo->new();
$foo->someFooMethod(); ## calls Foo::someFooMethod because it exists
$foo->anyNonFooMethod(); ## calls the method on the Bar object that
## $foo *contains*.
Another example is handling member set/get methods automatically
without actually having to code any of them beyond AUTOLOAD():
sub AUTOLOAD {
my $self = shift;
my $field = $AUTOLOAD; ## Strip package info
$field =~ s/.*:://;
if (exists $self->{$field}) { ## Sanity check
if (@_) { ## Setting or fetching a value?
return $self->{$field} = $_[0];
}
else {
return $self->{$field};
}
}
else {
croak ("Method '$field' is not implemented by " . ref ($self)");
}
}
....time passes....
$foo->someField("some value");
my $val = $foo->someOtherField();
If you want to make them explicitly getSomeField() and
setSomeField(), that as well is quite trivial.
:> > > > End of story.
:> > >
:> > > Stories, like newsgroup threads, don't end just because someone
:> > > declares them ended.
:> >
:> > Didn't say the story ended,
:>
:> You are a liar.
:
: "End of story" means "let's put an end to your story about why you can't
: write the assembler equivalent to a C nested for loop, even though you
: repeatedly contend that C is merely portable assember".
There is nothing that <insert language> can do that asm can not.
The resulting asm may likely be many magnitudes larger, but it can
be done.
: By your own inability to match a tiny snippet of C code in assembler you
: tell a sad story of a man unable to justify his outrageous claims. And
: that's no lie, I'm afraid.
All C maps 1:1 to assembly, albeit at times very large amounts of
assembly.
Once again, the terms "high level" and "low level" do not in any way
refer to total lines of code but only to how well the language maps
the logic process of the human mind or the physical machine. As
such, the only thing lower level then asm is machine code. C *is*
higher level then asm, but not by leaps and bounds as all its
constructs do map so closely to asm routines (again, albeit large
ones).
Your example of a for loop was invalid, simply because it included a
printf() call. It's been years since I've done asm but the for loop
is pretty trivial:
set reg 10; ; initial count value (some general register)
push code; ; set top of loop
push "some %s format" ; printf format
push reg ; printf value
call printf ; call printf
dec reg ; decrement register value
jmpz reg ; repeat loop until reg == 0
Of course, you have to define the printf call someplace but then so
does C (and on some systems printf *is* coded at least in part in
asm).
C did not invent loops, nore did it invent calling subroutines.
You've stated that you have absolutely no asm experience. I suggest
you go out and get some because until then your arguments are
totally baseless.
>snip<
: No doubt because you intend to trail along and chime in that "Perl classes
: are much less complex than Java classes" and to prove it you will show
: Perl code and no Java code, and then say that Perl is a higher level
: language, while C/C++ and Java are low level languages.
It is not that black and white. In order from high to low as a gray
scale:
Perl
Lisp
Java
C++
C
asm
machine code
The differences between each vary of course, and this also in no way
specifics the "power" scale of the languages, which is impossible
because it changes with the problem domain.
--
-Zenin (zenin@archive.rhps.org) "Hey, are you one of those Linux coders?"
"Nyet. Linux coder in next office."
"Good man. Ignore the screams."
--www.userfriendly.org
------------------------------
Date: 18 Jun 1999 23:28:23 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Perl and artificial intelligence.
Message-Id: <slrn7mm734.gnv.abigail@alexandra.delanet.com>
ktb (xyf@inetnebr.com) wrote on MMCXVIII September MCMXCIII in
<URL:news:376AFCA9.A4EE3ECD@inetnebr.com>:
@@ Hi, I've been searching for something on the net about artificial
@@ intelligence using the Perl language. Most of the programs seem to be
@@ in 'C' and other languages I haven't heard of. I'm new to programming
@@ but I thought it would be fun to mess around with this. If anyone knows
@@ of any A.I. programs written in Perl or links on the topic I'd love to
@@ know about it.
Didn't AI die in the mid-80's, even before Perl 1 was born?
Anyway, if you are new to programming, I wouldn't try AI. That's like
driving a formula 1 bolide while new to driving.
Abigail
--
perl -wlne '}for($.){print' file # Count the number of lines.
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sat, 19 Jun 1999 02:52:38 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: Printing compound variables (explanation)
Message-Id: <B390B67696681CC78E@204.112.166.88>
In article <7ke9f4$rap$1@nnrp1.deja.com>,
greg@dns.kode.net wrote:
>In article <376a6387@cs.colorado.edu>,
> tchrist@mox.perl.com (Tom Christiansen) wrote:
>> [courtesy cc of this posting mailed to cited author]
>>
>> Six times. SIX FRICKING TIMES. Have you no sense of
>> proportion decency? Who is this really?
Teehee!
Tom's so cute when he's angry.
Eric already gave you a good answer, Greg. I have nothing to add. I'm just
here to waste my time, yours, and everybody else's.
Really.
Lee
------------------------------
Date: Fri, 18 Jun 1999 13:35:23 -0400
From: "Mike Stone" <mstone@mountaincreek.com>
Subject: Win32::NetAdmin::UserChangePassword
Message-Id: <7kdvi3$8vv$1@news.eclipse.net>
Hi,
I am having problems getting an error message out of the following copule
lines of code:
use Win32::NetAdmin;
Win32::NetAdmin::UserChangePassword("domain","user","oldpwd","newpwd");
print Win32::FormatMessage Win32::GetLastError;
My problem is that it always returns "The command Completed Successfully".
It doesn't matter if I enter an invalid username, invalid domain, a wrong
old password.
Perl Verison 5.005_02, my NetAdmin module is version 0.06.
Is there a more recent version of the NetAdmin?
Thank you in advance,
Mike W. Stone
mstone@mountaincreek.com
------------------------------
Date: Sat, 19 Jun 1999 07:25:07 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Writing RTF with Perl
Message-Id: <376f437a.2843796@news.skynet.be>
NewtronBoy@aol.com wrote:
>Does anyone know of a specification
>of Rich Text Format so I can create RTF files
>with perl?
There's a specification file on Wotsit.
http://www.wotsit.org/
But let me warn you: in my experience, RTF isn't very stable, as
different versions of Word (RTF is a MS invention) write -- and
recognize -- (slightly) different file formats. Files that MUST be valid
according to the specification, may fail. Good luck.
What I would do, if I were in your shoes, is to write a basic RTF file
using a normal word processor, and try to wurm your specific data in to
specific places in that template file, after massaging your data into
the right format according to the spec.
Bart.
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 6055
**************************************