[23262] in Perl-Users-Digest
Perl-Users Digest, Issue: 5482 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 10 18:20:47 2003
Date: Wed, 10 Sep 2003 15:20:21 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 10 Sep 2003 Volume: 10 Number: 5482
Today's topics:
Splitting and keeping the delimiter <mr@sandman.net>
Re: Splitting and keeping the delimiter <usenet@expires12.2003.tinita.de>
Re: Splitting and keeping the delimiter <xx087@freenet.carleton.ca>
Re: Splitting and keeping the delimiter <krahnj@acm.org>
Re: Splitting and keeping the delimiter <print split /!/"d!a!v!i!d!o!@!p!a!c!i!f!i!e!r!.!c!o!m!\n">
Re: Standards in Artificial Intelligence <trammell+usenet@hypersloth.invalid>
Re: Standards in Artificial Intelligence <dheld@codelogicconsulting.com>
system command question (Himal)
Re: system command question <glex_nospam@qwest.net>
URL detection follow-up <ducott@hotmail.com>
Re: URL detection follow-up <asu1@c-o-r-n-e-l-l.edu>
Re: URL detection follow-up <no@email.com>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 10 Sep 2003 22:29:57 +0200
From: Sandman <mr@sandman.net>
Subject: Splitting and keeping the delimiter
Message-Id: <mr-66A60F.22295710092003@news.fu-berlin.de>
Hello! I have a string like this:
12.00 Simpsons 12.30 Seinfeld 13.00 Movie: Dante's Peak
And I want to split that in seperate "programs" that I'd like to deal with
individually. So, I want this in an array like this:
"12.00 Simpsons",
"12.30 Seindfeld"
"13.00 Movie: Dante's Peak"
And the one thing that I can split on is '\d\d\.\d\d', which is the only common
thing, but using
split /\d\d\.\d\d/
produces
"Simpsons",
"Seindfeld"
"Movie: Dante's Peak"
Is there a way? How would you do it?
--
Sandman[.net]
------------------------------
Date: 10 Sep 2003 20:49:06 GMT
From: Tina Mueller <usenet@expires12.2003.tinita.de>
Subject: Re: Splitting and keeping the delimiter
Message-Id: <bjo2o1$lavn6$1@ID-24002.news.uni-berlin.de>
Sandman wrote:
> Hello! I have a string like this:
> 12.00 Simpsons 12.30 Seinfeld 13.00 Movie: Dante's Peak
> And I want to split that in seperate "programs" that I'd like to deal with
> individually. So, I want this in an array like this:
> "12.00 Simpsons",
> "12.30 Seindfeld"
> "13.00 Movie: Dante's Peak"
just a note: what if you have:
20:00 24 - 06:00 - 07:00
?
the '06:00 - 07:00' belongs to the title of the program
> And the one thing that I can split on is '\d\d\.\d\d', which is the only common
> thing, but using
> split /\d\d\.\d\d/
> produces
> "Simpsons",
> "Seindfeld"
> "Movie: Dante's Peak"
try
split / ?(?=\d\d\.\d\d)/
hth, tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/ \ \ _,_\ __/\ __/_| /__/ perception
- the above mail address expires end of december 2003 -
------------------------------
Date: 10 Sep 2003 21:08:55 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Splitting and keeping the delimiter
Message-Id: <slrnblv4n5.65s.xx087@freenet10.carleton.ca>
Sandman <mr@sandman.net> wrote:
> Hello! I have a string like this:
>
> 12.00 Simpsons 12.30 Seinfeld 13.00 Movie: Dante's Peak
>
> And I want to split that in seperate "programs" that I'd like to deal with
> individually. So, I want this in an array like this:
>
> "12.00 Simpsons",
> "12.30 Seindfeld"
> "13.00 Movie: Dante's Peak"
my $str = "12.00 Simpsons 12.30 Seinfeld 13.00 Movie: Dante's Peak";
my $delim = qr/\d\d\.\d\d/;
my @programs = $str =~ m{
$delim # the delimiter
.+? # followed by some characters, until ...
(?= $delim | $) # we can look ahead to see delim or the end of string
}xg;
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Wed, 10 Sep 2003 21:13:55 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Splitting and keeping the delimiter
Message-Id: <3F5F940E.7BE72A6C@acm.org>
Sandman wrote:
>
> Hello! I have a string like this:
>
> 12.00 Simpsons 12.30 Seinfeld 13.00 Movie: Dante's Peak
>
> And I want to split that in seperate "programs" that I'd like to deal with
> individually. So, I want this in an array like this:
>
> "12.00 Simpsons",
> "12.30 Seindfeld"
> "13.00 Movie: Dante's Peak"
>
> And the one thing that I can split on is '\d\d\.\d\d', which is the only common
> thing, but using
>
> split /\d\d\.\d\d/
>
> produces
>
> "Simpsons",
> "Seindfeld"
> "Movie: Dante's Peak"
>
> Is there a way? How would you do it?
$ perl -le'
$string = " 12.00 Simpsons 12.30 Seinfeld 13.00 Movie: Dantes Peak ";
@array = $string =~ /\d\d\.\d\d.+?(?=\d|$)/g;
print for @array;
'
12.00 Simpsons
12.30 Seinfeld
13.00 Movie: Dantes Peak
John
--
use Perl;
program
fulfillment
------------------------------
Date: Wed, 10 Sep 2003 14:58:07 -0700
From: "David Oswald" <print split /!/"d!a!v!i!d!o!@!p!a!c!i!f!i!e!r!.!c!o!m!\n">
Subject: Re: Splitting and keeping the delimiter
Message-Id: <vlv7jr9p4flg32@corp.supernews.com>
"Sandman" <mr@sandman.net> wrote in message
news:mr-66A60F.22295710092003@news.fu-berlin.de...
> Hello! I have a string like this:
>
> 12.00 Simpsons 12.30 Seinfeld 13.00 Movie: Dante's Peak
>
> And I want to split that in seperate "programs" that I'd like to deal with
> individually. So, I want this in an array like this:
>
> "12.00 Simpsons",
> "12.30 Seindfeld"
> "13.00 Movie: Dante's Peak"
>
<snip>
> Is there a way? How would you do it?
Yes, there is a way. Actually as with most things in Perl there is more
than one way.
The easiest involves using an assertion that doesn't consume anything.
my $string = "12.00 Simpsons 12.30 Seinfeld 13.00 Movie: Dante's Peak";
@array = split /(?=\d+\.\d+\s)/, $string;
Another possibility would be to come up with pairs, and then join them like
this (untested):
while ($string) {
my ($time,$name,$string) = split /(\d+\.\d+)\s/,$string,3;
push @array, join " ",($time, $name);
}
This relies on paranthesis to capture the delimiter, and counts on the limit
parameter of split to limit its output to three strings; in this case the
delimiter, the name of the show, and a string containing everything else,
ready for the next split call.
Eventually $string is empty, and the while loop runs out.
I like the first method better though.
Dave
------------------------------
Date: Wed, 10 Sep 2003 18:11:24 +0000 (UTC)
From: "John J. Trammell" <trammell+usenet@hypersloth.invalid>
Subject: Re: Standards in Artificial Intelligence
Message-Id: <slrnbluqac.2f7.trammell+usenet@hypersloth.el-swifto.com.invalid>
On 10 Sep 2003 10:22:11 -0800, Arthur T. Murray mega-crossposted:
> A webpage of proposed Standards in Artificial Intelligence is at
> http://mentifex.virtualentity.com/standard.html -- updated today.
>
A killfile for excessive crossposters and other undesirables is
at /home/trammell/.slrn/score -- updated about 15 seconds ago.
------------------------------
Date: Wed, 10 Sep 2003 13:23:19 -0500
From: "David B. Held" <dheld@codelogicconsulting.com>
Subject: Re: Standards in Artificial Intelligence
Message-Id: <bjnqsa$snd$1@news.astound.net>
"Arthur T. Murray" <uj797@victoria.tc.ca> wrote in message
news:3f5f5dc3@news.victoria.tc.ca...
> A webpage of proposed Standards in Artificial Intelligence
> is at http://mentifex.virtualentity.com/standard.html --
> updated today.
Besides not having anything to do with C++, you should
stop posting your notices here because you are a crank.
You claim to have a "theory of mind", but fail to recognize
two important criteria for a successful theory: explanation
and prediction. That is, a good theory should *explain
observed phenomena*, and *predict non-trivial
phenomena*. From what I have skimmed of your "theory",
it does neither (though I suppose you think that it does
well by way of explanation).
In one section, you define a core set of concepts (like
'true', 'false', etc.), and give them numerical indexes.
Then you invite programmers to add to this core by using
indexes above a suitable threshold, as if we were defining
ports on a server. When I saw this, and many other things
on your site, I laughed. This is such a naive and simplistic
view of intelligence that you surely cannot be expected
to be taken seriously.
I dare say one of the most advanced AI projects in
existence is Cog. The philosophy behind Cog is that
an AI needs a body. You say more or less the same
thing. However, the second part of the philosophy behind
Cog is that a simple working robot is infinitely better
than an imaginary non-working robot. That's the part
you've missed. Cog is designed by some of the field's
brightest engineers, and funded by one of the last
strongholds of AI research. And as far as success
goes, Cog is a child among children. You expect to
create a fully developed adult intelligence from scratch,
entirely in software, using nothing more than the
volunteer labor of gullible programmers and your own
musings. This is pure comedy.
At one point, you address programmers who might
have access to a 64-bit architecture. Pardon me, but
given things like the "Hard Problem of Consciousness",
the size of some programmer's hardware is completely
irrelevant. These kinds of musings are forgivable when
coming from an idealistic young high school student
who is just learning about AI for the first time. But the
prolific nature of the work implies that you have been
at this for quite some time.
Until such time as you can A) show that your theory
predicts an intelligence phenomenon that is both novel
and later confirmed by experiment or observation of
neurological patients, or B) produce an artifact that is
at least as intelligent as current projects, I must conclude
that your "fibre theory" is just so much wishful rambling.
The level of detail you provide clearly shows that you
have no real understanding of what it takes to build a
successful AI, let alone something that can even
compete with the state of the art. The parts that you
think are detailed, such as your cute ASCII diagrams,
gloss over circuits that researchers have spent their
entire lives studying, which you leave as "an exercise
for the programmer". This is not only ludicrous, but
insulting to the work being done by legitimate
researchers, not to mention it insults the intelligence
of anyone expected to buy your "theory".
Like many cranks and crackpots, you recognize that
you need to insert a few scholarly references here and
there to add an air of legitimacy to your flights of fancy.
However, a close inspection of your links shows that
you almost certainly have not read and understood
most of them, or A) you would provide links *into* the
sites, rather than *to* the sites (proper bibliographies
don't say: "Joe mentioned this in the book he published
in '92" and leave it at that), or B) you wouldn't focus
on the irrelevant details you do.
A simple comparison of your model with something
a little more respectable, such as the ACT-R program
at Carnegie-Mellon, shows stark contrasts. Whereas
your "model" is a big set of ASCII diagrams and some
aimless wanderings on whatever pops into your head
when you're at the keyboard, the "models" link (note
the plural) on the ACT-R page takes you to what...?
To a bibliography of papers, each of which addresses
some REAL PROBLEM and proposes a DETAILED
MODEL to explain the brain's solution for it. Your
model doesn't address any real problems, because
it's too vague to actually be realized.
And that brings us to the final point. Your model has
components, but the components are at the wrong
level of detail. You recognize the obvious fact that
the sensory modalities must be handled by
specialized hardware, but then you seem to think that
the rest of the brain is a "tabula rasa". To see why
that is utterly wrong, you should take a look at Pinker's
latest text by the same name (The Blank Slate).
The reason the ACT-R model is a *collection* of
models, rather than a single model, is very simple.
All of the best research indicates that the brain is
not a general-purpose computer, but rather a
collection of special-purpose devices, each of which
by itself probably cannot be called "intelligent".
Thus, to understand human cognition, it is necessary
to understand the processes whereby the brain
solves a *PARTICULAR* problem, and not how it
might operate on a global scale. The point being
that the byzantine nature of the brain might not make
analysis on a global scale a useful or fruitful avenue
of research. And indeed, trying to read someone's
mind by looking at an MRI or EEG is like trying to
predict the stock market by looking at the
arrangement of rocks on the beach.
Until you can provide a single model of the precision
and quality of current cognitive science models, for
a concrete problem which can be tested and
measured, I must conclude that you are a crackpot
of the highest order. Don't waste further bandwidth
in this newsgroup or others with your announcements
until you revise your model to something that can be
taken seriously (read: explains observed phenomena
and makes novel predictions).
Dave
------------------------------
Date: 10 Sep 2003 12:33:30 -0700
From: himal5@hotmail.com (Himal)
Subject: system command question
Message-Id: <365e1935.0309101133.529f020e@posting.google.com>
I there a reason why a command will not work if i do system "$cmd &>
xyz.log" even though it works if I do system "$cmd"
------------------------------
Date: Wed, 10 Sep 2003 15:51:42 -0500
From: "J. Gleixner" <glex_nospam@qwest.net>
Subject: Re: system command question
Message-Id: <w7M7b.237$aT.29346@news.uswest.net>
Himal wrote:
> I there a reason why a command will not work if i do system "$cmd &>
> xyz.log" even though it works if I do system "$cmd"
This is an OS/Shell issue.
From your command line try:
whateverCommandYouAreTryingToRun & > xyz.log
and you should see the error.
------------------------------
Date: Wed, 10 Sep 2003 21:33:12 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: URL detection follow-up
Message-Id: <sMM7b.935815$3C2.21317890@news3.calgary.shaw.ca>
Hi,
As per my previous posts, I am searching for a way to open a text file that
contains a few paragraphs of text, locate web URL's and replace them with
the needed html tags such as <a href & </a> etc. Most of the responses
suggested using a perl module ... URI::Find and similair methods.
Unfortunately, the hosting company I run my scripts from does not have this
module installed, and they are not prepared to install it just for my needs.
I also cannot change hosting companies.
So ... is there ANY other way my goal can be accomplished giving I cannot
use URI::Find? Here is an example of theoretical code:
#!/usr/bin/perl
# get text file data
open (TEXT, "<data/data.txt") or die "Can't open file: $!";
@data=<TEXT>;
close(TEXT);
# find web URL's and replace occurances with needed HTML tags
scan @list > replace;
# write the changed data back to the text file
open (TEXT, ">data/data.txt") or die "Can't open file: $!";
print DATA @text;
close(TEXT);
Please, it is very important to me to find this solution, if you have any
ideas, post back. Working code examples are very welcomed. Thanx everyone!
Randy
------------------------------
Date: 10 Sep 2003 21:47:50 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: URL detection follow-up
Message-Id: <Xns93F2B50B8D1EBasu1cornelledu@132.236.56.8>
"\"Dandy\" Randy" <ducott@hotmail.com> wrote in
news:sMM7b.935815$3C2.21317890@news3.calgary.shaw.ca:
> methods. Unfortunately, the hosting company I run my scripts from does
> not have this module installed, and they are not prepared to install
> it just for my needs. I also cannot change hosting companies.
perldoc -q lib
Found in C:\Perl\lib\pod\perlfaq8.pod
How do I keep my own module/library directory?
When you build modules, use the PREFIX option when generating
Makefiles:
perl Makefile.PL PREFIX=/u/mydir/perl
then either set the PERL5LIB environment variable before you run
scripts that use the modules/libraries (see perlrun) or say
use lib '/u/mydir/perl';
This is almost the same as
BEGIN {
unshift(@INC, '/u/mydir/perl');
}
except that the lib module checks for machine-dependent
subdirectories. See Perl's lib for more information.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Wed, 10 Sep 2003 22:51:09 +0100
From: "Brian Wakem" <no@email.com>
Subject: Re: URL detection follow-up
Message-Id: <bjo6ce$lfb7n$1@ID-112158.news.uni-berlin.de>
""Dandy" Randy" <ducott@hotmail.com> wrote in message
news:sMM7b.935815$3C2.21317890@news3.calgary.shaw.ca...
> Hi,
>
> As per my previous posts, I am searching for a way to open a text file
that
> contains a few paragraphs of text, locate web URL's and replace them with
> the needed html tags such as <a href & </a> etc. Most of the responses
> suggested using a perl module ... URI::Find and similair methods.
> Unfortunately, the hosting company I run my scripts from does not have
this
> module installed, and they are not prepared to install it just for my
needs.
> I also cannot change hosting companies.
>
> So ... is there ANY other way my goal can be accomplished giving I cannot
> use URI::Find? Here is an example of theoretical code:
>
> #!/usr/bin/perl
>
> # get text file data
> open (TEXT, "<data/data.txt") or die "Can't open file: $!";
> @data=<TEXT>;
> close(TEXT);
>
> # find web URL's and replace occurances with needed HTML tags
> scan @list > replace;
>
> # write the changed data back to the text file
> open (TEXT, ">data/data.txt") or die "Can't open file: $!";
> print DATA @text;
> close(TEXT);
>
> Please, it is very important to me to find this solution, if you have any
> ideas, post back. Working code examples are very welcomed. Thanx everyone!
If they are all like http://www.domain.com/dir/file.html then you could do
something like -
foreach(@data) {
s!(http://.*?)(?:\s|$)!<a href="$1">$1</a>!gi;
}
Not perfect, but it'll get you started.
--
Brian Wakem
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.
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 V10 Issue 5482
***************************************