[19447] in Perl-Users-Digest
Perl-Users Digest, Issue: 1642 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 28 18:10:31 2001
Date: Tue, 28 Aug 2001 15:10:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <999036613-v10-i1642@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 28 Aug 2001 Volume: 10 Number: 1642
Today's topics:
Re: Java mucks up split (Abigail)
Re: Java mucks up split <cberry@cinenet.net>
Re: Java mucks up split (Trewth Seeker)
Re: Java mucks up split (Trewth Seeker)
mistake with form (bettina)
MLDBM <gghostie@hotmail.com>
Re: MySQL grants question... <ilya@martynov.org>
Re: Performance : Shell X Perl <bcc@eswssol001.elsegundoca.ncr.com>
Re: Performance : Shell X Perl <bcc@eswssol001.elsegundoca.ncr.com>
Re: perl "study" function in java? (Abigail)
Re: Perl in Non-IT Work Environments <iltzu@sci.invalid>
Re: Preliminary task description (v2) <tsee@gmx.net>
Re: Preliminary task description <tsee@gmx.net>
problem using a regex to format SGML (Shang-Lin Chen)
Re: problem using a regex to format SGML <krahnj@acm.org>
Re: REGEX <cberry@cinenet.net>
Re: RegEx? <baker@Akira.cyborgworkshop.com>
sharing sockets between processes <bla@bla.bla>
Re: sharing sockets between processes (Logan Shaw)
stringTTF problem with AS Perl 629 (Daniel Harik)
Unix perl directory conventions?? <ekulis@apple.com>
Re: Unix perl directory conventions?? <cberry@cinenet.net>
Re: Unix perl directory conventions?? (Logan Shaw)
Re: Will Perl report on variables no longer used?? (Abigail)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Aug 2001 19:17:19 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Java mucks up split
Message-Id: <slrn9onri3.rpa.abigail@alexandra.xs4all.nl>
Trewth Seeker (trewth_seeker@yahoo.com) wrote on MMCMXIX September
MCMXCIII in <URL:news:d690a633.0108280002.6054b2b5@posting.google.com>:
$$ Those Java folks at Sun seem to have trouble getting it right, even
$$ when it's already been done for them. They've added regexps and
$$ "split" to Java 1.4, but the split doc
$$ http://java.sun.com/j2se/1.4/docs/api/java/util/regex/Pattern.html
$$ says
$$
$$ The input "boo:and:foo", for example, yields the following results
$$ with these parameters:
$$
$$ Regex Limit Result
$$ : 2 { "boo", "and" }
$$
$$ That's just dumb, and misses the whole point of the limit. This is
$$ going to lead to confusion and cause some people to think that Perl is
$$ just as broken, since Java's split is taken from Perl. What can be
$$ done to get Sun to do it right?
Why on earth should this group be bothered?
I don't think there's any point in bickering "oh, language X has feature
foo, that should be in language Y too, and exactly as X has".
I quickly gave up on the entire perl6 development process as there were
just too many people trying to turn Perl into Java/C/Python/Frobel/whatever.
Let Perl be remain Perl. Let Java take whatever course it takes. From a
Perl perspective, it doesn't matter. Nor does it matter how Python 2500
is going to look like, or the next version of Eiffel or SQL.
This groups is about Perl. Perl. Perl. Perl.
The Java groups are over there. Complain there if you think Sun is doing
you injustice. Perhaps someone there will take pitty.
Use Perl. Not Java.
Abigail
--
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'
------------------------------
Date: Tue, 28 Aug 2001 20:51:40 -0000
From: Craig Berry <cberry@cinenet.net>
Subject: Re: Java mucks up split
Message-Id: <Xns910B8D00CBAFEcberrycinenetnet1@207.126.101.92>
abigail@foad.org (Abigail) wrote in
news:slrn9onri3.rpa.abigail@alexandra.xs4all.nl:
> Use Perl. Not Java.
Or use both, applying the correct tool to each job. And I believe the
heads-up regarding split compatibility here in clpm was justified, as Sun
has explicitly stated their intention of basing regex-related tools on Perl.
I agree that further discussion of potential remedies would belong in the
java groups.
--
Craig Berry <http://www.cinenet.net/~cberry/>
"That which is now known, was once only imagined." - William Blake
------------------------------
Date: 28 Aug 2001 14:20:19 -0700
From: trewth_seeker@yahoo.com (Trewth Seeker)
Subject: Re: Java mucks up split
Message-Id: <d690a633.0108281320.5bcb45f8@posting.google.com>
194.203.212.8 [demerphq@hotmail.com] wrote in message news:<XjNi7.1385$3x.4984@news.bc.tac.net>...
> > Those Java folks at Sun seem to have trouble getting it right, even
> > when it's already been done for them. They've added regexps and
> > "split" to Java 1.4, but the split doc
> > http://java.sun.com/j2se/1.4/docs/api/java/util/regex/Pattern.html
> > says
> >
> > The input "boo:and:foo", for example, yields the following results
> > with these parameters:
> >
> > Regex Limit Result
> > : 2 { "boo", "and" }
> >
> > That's just dumb, and misses the whole point of the limit. This is
> > going to lead to confusion and cause some people to think that Perl is
> > just as broken, since Java's split is taken from Perl. What can be
> > done to get Sun to do it right?
>
> Why do you want Sun to get it right?
I already explained that immediately above.
> Aren't you a perler?
Religion makes people stupid.
------------------------------
Date: 28 Aug 2001 14:25:22 -0700
From: trewth_seeker@yahoo.com (Trewth Seeker)
Subject: Re: Java mucks up split
Message-Id: <d690a633.0108281325.2cac72ca@posting.google.com>
merlyn@stonehenge.com (Randal L. Schwartz) wrote in message news:<m1pu9gl139.fsf@halfdome.holdit.com>...
> >>>>> "Trewth" == Trewth Seeker <trewth_seeker@yahoo.com> writes:
>
> Trewth> Those Java folks at Sun seem to have trouble getting it right, even
> Trewth> when it's already been done for them. They've added regexps and
> Trewth> "split" to Java 1.4, but the split doc
> Trewth> http://java.sun.com/j2se/1.4/docs/api/java/util/regex/Pattern.html
> Trewth> says
>
> Trewth> The input "boo:and:foo", for example, yields the following results
> Trewth> with these parameters:
>
> Trewth> Regex Limit Result
> Trewth> : 2 { "boo", "and" }
>
> Trewth> That's just dumb, and misses the whole point of the limit. This is
> Trewth> going to lead to confusion and cause some people to think that Perl is
> Trewth> just as broken, since Java's split is taken from Perl. What can be
> Trewth> done to get Sun to do it right?
>
> It's worse than that. The java regex library I saw (there's more than
> one, apparently)
There's only one in Java 1.4's java.util.regex, which is what I'm talking about.
> returns a separate memory value for *each* *capture*,
> not *each* definition.
The Java 1.4 java.util.regex doesn't do that.
> And since non-capturing parens are not available,
That isn't true of the Java 1.4 java.util.regex.
------------------------------
Date: 28 Aug 2001 11:18:46 -0700
From: bettina.pfluegl@gmx.de (bettina)
Subject: mistake with form
Message-Id: <7457c367.0108281018.3b94777f@posting.google.com>
I have a big problem with the form (HTML::Request::Form) because I
don't know how it works right. I want to check the login of a internet
page and want to check if the pattern of the link (wich will be
reached after the login) is right. But I don't know how to use the
form-command in a right way. The script doesn't recognize my pattern
near the form-command in the following line:
if ($forms[0][0] =~ /home/) {
Can anyone help me? I would be very glad!
I give you the code of my perl-script:
...my $ua = LWP::UserAgent->new;
$ua->timeout($timeout);
$request = HTTP::Request->new('POST', "$urlbase"."$urlpath");
my $res = $ua->request($request);
#my $res = $ua->request(POST "$urlbase"."$urlpath");
#site not reachable
if (! $res->is_success)
{
print "Login page not reachable!\n";
return 0;
}
my $tb = HTML::TreeBuilder->new;
$tb->parse($res->content);
my @forms = @{$tb->extract_links(qw(form))};
my $f = HTTP::Request::Form->new($forms[0][1],
"$urlbase"."$urlpath");
$f->field("name", $login);
$f->field("tpshortname", $org);
$f->field("password", $password);
my $response = $ua->request($f->press("Enter"));
#Login failed/Site reachable
if ($response->is_success) {
$tb->delete;
print "Login failed!1\n";
return (2);
}
$tb->delete;
$tb = HTML::TreeBuilder->new;
$tb->parse($response->content);
@forms = @{$tb->extract_links()};
#Login success
if ($forms[0][0] = ~/bsubba/) { #fehler!!! nimmt muster nicht
an!!! wenn ein leerschritt falsch-> failed!!!
$tb->delete;
print $forms[0][0]; print "\n"; #how does it works to get the
url into the form??????
#only for tests
print $forms[0][1]; print "\n";
print $forms[0][2]; print "\n";
print $forms[1][0]; print "\n";
print $forms[1][1]; print "\n";
print "Login success!2\n";
return (1);
}
#Login failed/Site reachable
else {
$tb->delete;
print "Login failed!3\n";
return (2);
}
}
------------------------------
Date: Thu, 23 Aug 2001 15:53:22 -0400
From: "G Harper" <gghostie@hotmail.com>
Subject: MLDBM
Message-Id: <OvEd40ALBHA.261@cpmsnbbsa07>
I am searching desperately for good documentation on the usage of MLDBM. I
need to store/retreive a DBM hash with 7 keys, each key storing an array
with up to 40 entries. MLDBM is the only reasonable method I've found so
far but the documentation has been thin for the quasi-newbie.
Thanks all...
------------------------------
Date: 28 Aug 2001 23:07:21 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: MySQL grants question...
Message-Id: <874rqsdmvq.fsf@abra.ru>
>>>>> On Tue, 28 Aug 2001 17:39:36 GMT, gil@nospam-keskydee.com (Gil G.) said:
GG> Hello,
GG> Sorry, this is a bit off subject, I could not find a MySQL newsgroup
GG> in my groups file... The MySQL manual and book by Dubois did not
GG> provide me with an answer.
GG> [..skip..]
GG> PS: What is the best group for such MySQL questions?
Subscribe on MySQL maillist:
http://www.mysql.com/documentation/lists.html
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: 28 Aug 2001 13:19:24 -0700
From: Brian Cantin <bcc@eswssol001.elsegundoca.ncr.com>
Subject: Re: Performance : Shell X Perl
Message-Id: <7nn14k0wfn.fsf@eswssol001.elsegundoca.ncr.com>
abigail@foad.org (Abigail) writes:
> Brian Cantin (bcc@eswssol001.elsegundoca.ncr.com) wrote on MMCMXV
> September MCMXCIII in
> <URL:news:7nlmk9tmzb.fsf@eswssol001.elsegundoca.ncr.com>:
> == mjd@plover.com (Mark Jason Dominus) writes:
> == > In my experience it's a lot easier to write a portable Perl program
> == > than a portable shell script. In 1995 you might have had to worry
> == > that the target system didn't have Perl, but these days Perl is almost
> == > everywhere.
> ==
> == True, Perl is available nearly everywhere, but it may not be the same
> == version. I run into problems all the time with machines running 5.001
> == on scripts that were coded and tested against later versions. The
> == Bourne shell and the UNIX toolkit definition is pretty much static, so
> == it is easier to test on a bunch of different platforms and assure
> == things will run.
>
> *Which* Unix toolkit definition are you talking about? That's the problem
> - there are many "standards" for the Unix toolkit definitions. Big vendors
> like HP and SUN have to problem committing themselves to standards, too
> bad they don't always agree to take the same one. And on top of that,
> tools for Linux at best follow a POSIX standard, but not always.
True enough. Even though the vendors vary, you can determine what
platform you are running on and often do the appropriate thing. Ugly,
but it works. Having the Perl version change from machine to machine
is a different sort of a problem.
>
> And for Windows, you have to depend on some Unix toolkit to be installed
> - that doesn't come with the OS.
Hence my remark about NT below.
>
> == So, pick your poison: the ever changing virtual machine that Perl
> == provides versus the relatively static but platform dependent UNIX
> == toolkit. However, if you have to support something as impoverished as
> == NT, you are definitely better off with Perl.
>
> So, which tool from the "Unix toolkit" are you going to use to open a
> socket, or to lock a file?
Pick any from the null set.
------------------------------
Date: 28 Aug 2001 13:23:48 -0700
From: Brian Cantin <bcc@eswssol001.elsegundoca.ncr.com>
Subject: Re: Performance : Shell X Perl
Message-Id: <7nk7zo0w8b.fsf@eswssol001.elsegundoca.ncr.com>
mjd@plover.com (Mark Jason Dominus) writes:
> In article <7nlmk9tmzb.fsf@eswssol001.elsegundoca.ncr.com>,
> Brian Cantin <bcc@eswssol001.elsegundoca.ncr.com> wrote:
> >So, pick your poison: the ever changing virtual machine that Perl
> >provides versus the relatively static but platform dependent UNIX
> >toolkit.
>
> I did pick my poison:
>
> >mjd@plover.com (Mark Jason Dominus) writes:
> >> In my experience it's a lot easier to write a portable Perl program
> >> than a portable shell script.
>
> I didn't think I could be clearer than that, but apparently it was not
> clear enough. Oh well, usenet.
>
> My experience has been that Perl is less poisonous than shell scripts,
> and I strongly dispute the guy who says it was the other way around.
> I wonder if he's really tried doing both, or had to port a shell
> script between (say) Solaris, IRIX, and HPUX.
I have use Perl to supply portability between platforms for the last
several years. Before that I used shell scripts. What I am trying to
point out is Perl has its own set of problems.
------------------------------
Date: 28 Aug 2001 19:29:41 GMT
From: abigail@foad.org (Abigail)
Subject: Re: perl "study" function in java?
Message-Id: <slrn9ons99.rpa.abigail@alexandra.xs4all.nl>
crypto_boy (crypto-boy@llnl.gov) wrote on MMCMXVIII September MCMXCIII in
<URL:news:646ea35e.0108271446.56ba5d98@posting.google.com>:
$$ Problem:
$$ -----------------
$$ I need to see if a one of many regexes match a fixed string in java.
That's a Java problem, not a Perl one.
$$ What I miss from perl is the "study" function.
So? Then program in Perl, not in Java if you want a study function.
The fact it's not there doens't hold any relevance in this Perl group.
Please take your discussion out of the Perl group.
Abigail
--
BEGIN {my $x = "Knuth heals rare project\n";
$^H {integer} = sub {my $y = shift; $_ = substr $x => $y & 0x1F, 1;
$y > 32 ? uc : lc}; $^H = hex join "" => 2, 1, 1, 0, 0}
print 52,2,10,23,16,8,1,19,3,6,15,12,5,49,21,14,9,11,36,13,22,32,7,18,24;
------------------------------
Date: 28 Aug 2001 19:23:54 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Perl in Non-IT Work Environments
Message-Id: <999026554.3926@itz.pp.sci.fi>
In article <9menev$9lf@dispatch.concentric.net>, James E Keenan wrote:
>
>I would like to hear from people who are employed in jobs where their
>official responsibilities are *not* primarily IT-related and who use Perl on
>the job.
I wonder if that includes me. I'm currently doing my civilian service
for the Finnish Nature League, an environmental youth organization.[1]
My duties include everything from answering the telephone and planning
demonstrations to hauling around furniture and designing publications.
They do, however, also include partial responsibility for the official
website of the organization, which could be considered to make my job
IT-related. Certainly it is that part of the job where I make the most
use of Perl. For example, I use it to make automatic daily incremental
off-site backups of the website. That's not actually part of my job, as
no-one has tasked me to implement such a scheme, but it makes my work a
lot easier when (not if) something goes wrong with the webserver.
I used to work as a Java programmer. Used a lot of Perl in _that_ job.
[1] Military or civilian service is mandatory for all male Finnish
citizens, with certain rare exceptions.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Tue, 28 Aug 2001 20:50:39 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Preliminary task description (v2)
Message-Id: <9mgp51$d0q$03$1@news.t-online.com>
Here's the task description updated with Ilmari's suggestions.
Changes for v2:
- mentions the topology of the playing ground.
- entities can distinguish between different enemy species.
- the matrix that is passed to the move method is now different.
-> I don't quite like it this way, though. The data is supposed to be
simple, but in order to allow the entries to distinguish between
enemy species, there needs to be a list of id's for each passed
space which translates into a list of lists of lists:
@matrix[$x][$y][$entities_in_x_y]
Any better ideas?
- the number of friendly entities to stack together is not limited
any more. They all participate equally in the encounters.
- when two entities of the same species meet, they may communicate.
Problems:
- What happens if: A number of entities of the same species meet in
the same place? How should inter-entity communication work for
more than two participants? Round-robin - again!?
- Even worse: What if a number (>2) of mates and some enemies meet?
Communication?
- The contest is basically a tournament, but works evolutionary.
- It is played through locally for a given number of turns.
- Entries submitted as a perl module.pm file.
- Entries have to follow certain guidelines:
-> They're basically a class.
-> and therefore provide certain methods to the platform
-> such as constructor (and if necessary a destructor!)
-> and content-specific methods such as:
-> $entry->move(arguments)
-> $entry->makeDecision(arguments)
(for the encounters)
-> They're passed certain arguments with the method call
such as:
-> what they can see on the playing plane (a small 2d
matrix) for the move method
-> What decision the opponent made in the last round
of the encounter.
-> Though they might include complex logic, they return
only little and very simple data. For the move method,
that would be a direction (small integer: 0-7) and for
the makeDecision method, that would be either a coop
or a defect flag (for classic PD).
This makes the problem and task simple to understand
without restricting the complexity of the entry.
- For every entry, a number of entities (object instances
in programming terms) is spawned each of which has an
absolute (and at first random) position on the playing
ground.
- Each turn, each entity's move(matrix) method is called
with their current view matrix (see below). The entity
returns an integer indicating the direction of movement.
Each entity can move one unit per turn horizontally,
vertically or diagonal.
- The entities don't know their absolute position. They
are only passed information on their surroundings.
- The playing ground is a 2-dimensional plane (a list of
lists) that has a fixed size, but whenever an entity
steps over its boundaries, it is 'teleported' to the
other edge of the 'world' without it knowing that.
Actually, this is a flat torus.
It can still see over the edge of the world to the
other side.
- A list of lists of lists is passed to the move method. Like:
@matrix[$x][$y][$entities_in_x_y]
@entities_in_x_y is a list of species' IDs.
Each element in the @entities_in_x_y list corresponds to one entity
of the species with the given species ID.
The entities can distinguish between different enemy
strategies.
They have a visible range of 2 units in each direction (horizontal,
vertical and diagonal.)
- Whenever a number of entities meet, a 'fight' or encounter
is performed:
-> It lasts for a fixed number of iterations (which are not
to be confused as the time unit 'turns'. An encounter is
carried out within one turn after the movement period.)
-> Regardless of how points are awarded, the entity that
has the highest score after the encounter assimilates
the others. That is, they become new instances of the
winning strategy.
-> The rules for the encounters still have to be specified.
Everything that follows in this section is preliminary:
-> Encounters are carried out as a round-robin tournament.
That is, each participating entity encounters all others
(for the given number of iterations).
By doing that, one can simplify the encounter logic to a
two-way encounter.
-> Each iteration, the makeDecision(arguments) method is
called for both entities. The argument passed to the
method is whichever decision the opposing entity made in
the previous iteration. In the first iteration, this
argument is omitted.
-> Points are awarded depending on the decisions of the
opponents:
-> Both chose cooperation: both get 3 points.
-> Both chose to defect: both get 1 point.
-> One chose to cooperate and one chose to defect:
-> Defecting entity gets 5 points.
-> Cooperating entity gets no points.
-> Problem: What if multiple instances (entities) of the same
strategy meet?
-> If only two entities of the same entry meet with no
opponents, they do not fight each other. Nothing happens.
-> (see below: inter-entity communication)
-> If a number of entities of the same strategy and any
opponents meet: (I'm very unsure about this section!)
-> The tournament could be carried out as normal with
the entities of the same strategy knowing when they
confont each other. They could try to adjust their
encounter-strategy if they meet a mate.
This way, they *do* have an advantage if they fight
in couples or more. However, they're less spread.
- Multiple entries allowed per contestant?
- Inter-entity communication
-> One could offer another layer of complexity by allowing the
programmers to implement some sort of inter-entity
communication. Because programmers could do different
implementations of the communication (no specification coming
from us!), only intra-'species' communication is allowed.
Entities can only talk to mates, not foes.
There can be a number of occasions that might call for
communication. All are to be implemented via the same method.
Let it be called communicate(). communicate() takes two arguments.
The first one is an integer flag that denotes the cause of the
communication. It is included in all the method calls. The other
argument is a scalar: Whenever communication occurs,
the corresponding method of one of the entries is called (first).
It gets the mentioned integer and a 'false' to denote that this
is the first method call of the decision-making process.
The entity returns a string that is then passed to the other
entity as the second scalar. This continues until one of the
entities returns 'false'.
For example, if a certain strategy implemented a counter how
many points an entity gathered in its life (or how many turns
it lasted), the meeting entities could compare their variables
and use the comparison to decide which of the two is to win the
tournament. Now, the one that isn't supposed to can cooperate
when they encounter each other, and the other one always defects
giving it an edge over the competition.
One could also compare movement patterns to form clusters of
entities to give them an edge in competition.
This option would really make the contest a competition...
Occasions on which to communicate:
-> number of mates meet.
-> number of mates meet enemies
-> (communication between each pair of mates before
tournament starts.)
-> communication between two mates before they are supposed to
confront each other.
I would suggest leaving out the pre-tournament communication.
It's a pain to implement more than 2-way.
Should the method be called with any further information? I don't
think so, because the other (single) participating entities do
not get additional info to base their decisions on.
Steffen
------------------------------
Date: Tue, 28 Aug 2001 20:52:28 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Preliminary task description
Message-Id: <9mgp52$d0q$03$2@news.t-online.com>
"Ilmari Karonen" <iltzu@sci.invalid> schrieb im Newsbeitrag
news:999019284.29801@itz.pp.sci.fi...
> One more issue -- you probably want to set time limits (alarm?) just in
> case there might be infinite decision-making or communication loops.
How would you do that?
What if the time limit runs out?
Just cut communication? That would mean the objects/data could be broken.
Thát would be a very bad thing to happen.
Steffen
------------------------------
Date: 28 Aug 2001 12:38:21 -0700
From: schen@caltech.edu (Shang-Lin Chen)
Subject: problem using a regex to format SGML
Message-Id: <ced2ab2d.0108281138.3bd285fe@posting.google.com>
I read the contents of an SGML file into a string called $data that
I'm trying to format and write to a text file. I want to remove a
block of SGML of the form:
<docinfo><author><firstname>Jane</firstname><surname>Doe</surname>
<affiliation><orgname>MyCompany Inc.</orgname></affiliation>
<date>August 27, 2001</date>
</docinfo> .
At first I tried:
$data =~ s/<\s*docinfo[^>]>[^(<\W+docinfo)]<\W+docinfo[^>]>//sgi;
to remove everything between the <docinfo> start and end tags,
but this line only killed the <docinfo> and <author> start tags. Since
my function later removed all SGML tags, all the non-tag content
between the <docinfo> tags was still displayed.
I also tried:
$data =~ s/<\s*docinfo[^>]>.*<\W+docinfo[^>]>//sgi;
but the regular expression didn't seem to match anything.
What regex would delete all content between the <docinfo> tags?
------------------------------
Date: Tue, 28 Aug 2001 21:10:29 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: problem using a regex to format SGML
Message-Id: <3B8C0937.1D238054@acm.org>
Shang-Lin Chen wrote:
>
> I read the contents of an SGML file into a string called $data that
> I'm trying to format and write to a text file. I want to remove a
> block of SGML of the form:
> <docinfo><author><firstname>Jane</firstname><surname>Doe</surname>
> <affiliation><orgname>MyCompany Inc.</orgname></affiliation>
> <date>August 27, 2001</date>
> </docinfo> .
>
> What regex would delete all content between the <docinfo> tags?
$data =~ s|<docinfo>.*?</docinfo>||si;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 28 Aug 2001 20:32:50 -0000
From: Craig Berry <cberry@cinenet.net>
Subject: Re: REGEX
Message-Id: <Xns910B89CF3E48Dcberrycinenetnet1@207.126.101.92>
Fredrik Andersson <fredrik.andersson@esavionics.se> wrote in
news:3B8B443E.63C57FED@esavionics.se:
> Hi, I'm trying to use a REGEX for adding integers.
> I have a file with ascii text and are seaching for lines
> with the text POS_Z (se below)
>
> BUTTON_01 = SYMBOL /POS_Z = -770 /POS_Z = -950 /DATA=#1
> BUTTON_45 = SYMBOL /POS_Z = 570 /POS_Z = 320 /DATA=#1
>
> I want to add an integer to the number after the POS_Z =
> Say 20 =>
> BUTTON_01 = SYMBOL /POS_Z = -750 /POS_Z = -950 /DATA=#1
> BUTTON_45 = SYMBOL /POS_Z = 590 /POS_Z = 320 /DATA=#1
Looks like you mean only the first occurrence of POS_Z. If so:
s/(?<=POS_Z = )(-?\d+)/$1 + 20/e;
If you actually want all occurrences, add a g modifier.
--
Craig Berry <http://www.cinenet.net/~cberry/>
"That which is now known, was once only imagined." - William Blake
------------------------------
Date: Tue, 28 Aug 2001 18:29:47 -0000
From: Jason Baker <baker@Akira.cyborgworkshop.com>
Subject: Re: RegEx?
Message-Id: <tonoorhavi5f36@news.supernews.com>
OK.. Now I'm going to beg for wisdom again. Let me see if I understand this correctly.
my ($from) = $row->[1] =~ /^([^<]*) </;
I'm doing the () around $from because otherwise I return a one or a zero, matchs or not.. But why?
For the Regex
/^ -> Start of the line
([^<]*) -> I have no idea
</l -> end the match
OK... could someone explain the middle part and why the ()'s? And for that matter, what if I wanted to get the second half, the email address. This wouldnt work would it?
David Wall <darkon@one.net> wrote:
> Samneric <samneric@tigerriverOMIT-THIS.com> wrote on 27 Aug 2001:
>> Ilya Martynov wrote:
>>> >>>>> Jason Baker said:
>>> JB> firstname lastname <email@wherever.com>
>>> JB> All I want to do is capture the name, not email address, into a
>>> JB> variable.
>>
>>> my ($from) = $row->[1] =~ /(.*?)</;
>>
>> my ($from) = $row->[1] =~ /(.*?) </;
>>
>> Removes the space before "<" :)
> As long as we're tweaking it,
> my ($from) = $row->[1] =~ /^([^<]*) </;
> is somewhat faster, as it doesn't have to backtrack as far. :-)
> --
> David Wall
> darkon@one.net
--
Jason
www.cyborgworkshop.com
...and the geek shall inherit the earth...
------------------------------
Date: Tue, 28 Aug 2001 20:59:12 GMT
From: "ninpo" <bla@bla.bla>
Subject: sharing sockets between processes
Message-Id: <ACTi7.47971$SC.1031821@amsnews02.chello.com>
Peops,
I'm looking for a way to have forked sockets
be able to write to eachother.
I've tried putting the sockets in shared memory
(IPC::Shareable) but that only accepts the basic classes scalar array and
hash.
I now have clients polling for values in shared mem, but that eats cpu. i
want the values directly printed to the socket. is that possible and can
someone give me a pointer how?
thanks a lot,
ninpoka.
------------------------------
Date: 28 Aug 2001 17:02:01 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: sharing sockets between processes
Message-Id: <9mh4cp$fs9$1@charity.cs.utexas.edu>
In article <ACTi7.47971$SC.1031821@amsnews02.chello.com>,
ninpo <bla@bla.bla> wrote:
>I'm looking for a way to have forked sockets
>be able to write to eachother.
>I've tried putting the sockets in shared memory
>(IPC::Shareable) but that only accepts the basic classes scalar array and
>hash.
>
>I now have clients polling for values in shared mem, but that eats cpu. i
>want the values directly printed to the socket. is that possible and can
>someone give me a pointer how?
You want to use pipe():
#! /usr/local/bin/perl
use IO::Handle;
$to_pipe = new IO::Handle;
$from_pipe = new IO::Handle;
pipe $from_pipe, $to_pipe;
if (fork())
{
# parent
$from_pipe->close; # only the other process uses this.
# send some lines of stuff to the other process.
foreach my $i (qw{ one two three })
{
$to_pipe->print("$i\n");
$to_pipe->flush;
sleep 2;
}
$to_pipe->close;
}
else
{
# child
$to_pipe->close; # only the other process uses this.
my $line;
# read what the other process sends to us.
while ($line = $from_pipe->getline())
{
chomp $line;
print STDOUT "I got '$line'.\n";
}
$from_pipe->close;
}
"perldoc perlipc" should have other stuff that might be helpful.
Hope that helps.
- Logan
--
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)
------------------------------
Date: 28 Aug 2001 13:49:25 -0700
From: http404@hot.ee (Daniel Harik)
Subject: stringTTF problem with AS Perl 629
Message-Id: <ecdb5c71.0108281249.10bd43d@posting.google.com>
Hello guys
I have this code from manual, crawled perlmonks for 1 hour and getting
back to same thing, the only think can be wrong is incompability
#!/usr/local/bin/perl
use GD;
# create a new image
$im = new GD::Image(200, 36);
# allocate some colors
$white = $im->colorAllocate(255,255,255);
$black = $im->colorAllocate(0,0,0);
$red = $im->colorAllocate(255,0,0);
$blue = $im->colorAllocate(0,0,255);
$im->stringTTF($black,"test.ttf", 12, 0, 0, 0,"Font Reactor") or die
$!;
open(IMAGE, ">test.png") or die;
binmode IMAGE;
print IMAGE $im->png;
Can any1 plz help, thnx a advance
------------------------------
Date: Tue, 28 Aug 2001 12:22:43 -0700
From: Ed Kulis <ekulis@apple.com>
Subject: Unix perl directory conventions??
Message-Id: <3B8BEF82.A0C35C10@apple.com>
Hi all,
Does any one know if there's a custom or convention for the placement of
perl on a unix system?
We've currently referencing perl it and links to it as
/bin/perl
/usr/bin/perl
/usr/local/bin/perl
Is there a traditional version migration scheme where new versions start
on the longer paths?
-ed
------------------------------
Date: Tue, 28 Aug 2001 20:53:52 -0000
From: Craig Berry <cberry@cinenet.net>
Subject: Re: Unix perl directory conventions??
Message-Id: <Xns910B8D60A7A7Ecberrycinenetnet1@207.126.101.92>
Ed Kulis <ekulis@apple.com> wrote in news:3B8BEF82.A0C35C10@apple.com:
> Does any one know if there's a custom or convention for the placement of
> perl on a unix system?
>
> We've currently referencing perl it and links to it as
> /bin/perl
> /usr/bin/perl
> /usr/local/bin/perl
>
> Is there a traditional version migration scheme where new versions start
> on the longer paths?
The most typical location used in shebang lines is /usr/bin/perl. I've seen
Perl actually installed in diverse other locations, but always allow it to
create a symlink from /usr/bin (or create one manually) for convenience.
--
Craig Berry <http://www.cinenet.net/~cberry/>
"That which is now known, was once only imagined." - William Blake
------------------------------
Date: 28 Aug 2001 16:41:40 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Unix perl directory conventions??
Message-Id: <9mh36k$fph$1@charity.cs.utexas.edu>
In article <3B8BEF82.A0C35C10@apple.com>, Ed Kulis <ekulis@apple.com> wrote:
>Does any one know if there's a custom or convention for the placement of
>perl on a unix system?
>
>We've currently referencing perl it and links to it as
> /bin/perl
> /usr/bin/perl
> /usr/local/bin/perl
On my system (Solaris):
$ cd /
$ ls -ld bin
lrwxrwxrwx 1 root root 9 Aug 27 17:27 bin -> ./usr/bin
$
So in this case, /bin/perl would have to be the same thing as
/usr/bin/perl.
Generally speaking, /bin/perl is the version that comes with the
operating system, and /usr/local/bin/perl is the version that the
system administrator has installed. Often /usr/local/bin/perl will be
newer, but it depends on the OS vendor and the administrator.
- Logan
--
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)
------------------------------
Date: 28 Aug 2001 19:09:03 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Will Perl report on variables no longer used??
Message-Id: <slrn9onr2j.rpa.abigail@alexandra.xs4all.nl>
Ilmari Karonen (iltzu@sci.invalid) wrote on MMCMXIX September MCMXCIII in
<URL:news:999017726.28618@itz.pp.sci.fi>:
!! In article <slrn9omefs.r1r.abigail@alexandra.xs4all.nl>, Abigail wrote:
!! >Ilmari Karonen (iltzu@sci.invalid) wrote on MMCMXIX September MCMXCIII in
!! ><URL:news:998960983.10957@itz.pp.sci.fi>:
!! >##
!! >## Well, the compiler certainly could be made to check for only-once-used
!! >## lexicals just as it currently checks for only-once-used globals. That
!! >## approach, of course, does produce both false positives and negatives.
!! >## It does not, to my knowledge, solve the halting problem.
!! >
!! >The "just as" isn't clear at all. The names of package variables live on,
!! >while they don't for lexicals.
!!
!! Well, that could be changed, if it presents a problem. I'm not familiar
!! with that part of perl guts, so I can't say if it will. But if one is
!! willing to accept a solution that is only as good as what we currently
!! have for package variables, then the rest is a SMOP.
!!
!! In any case, isn't the necessary information collected anyway, to allow
!! closures, string evals and redeclaration warnings?
It certainly isn't necessary for closures and redeclarations, as that
information can be gathered at compile time.
You're probably right for string evals though.
Abigail
--
perl -Mstrict='}); print "Just another Perl Hacker"; ({' -le1
# No woodpeckers in a
# birch tree. A pair of goldfish
# darting. Or Wunt.
------------------------------
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 1642
***************************************