[6796] in Perl-Users-Digest
Perl-Users Digest, Issue: 421 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 4 19:27:17 1997
Date: Sun, 4 May 97 16:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 4 May 1997 Volume: 8 Number: 421
Today's topics:
@r=($a=~/./g) Sets @r to the list of matching elements (Etienne Grossmann)
Re: [DRAFT] RFD: comp.lang.perl.{data-structure,inter-p (A.Deckers)
Re: Bug in goto? (David Alan Black)
Re: Combining 2 GIFs in Perl? (Andrew M. Langmead)
Re: Help Use 1 file to edit another <rootbeer@teleport.com>
Re: How to use perl to fill up a web form and save resu <rootbeer@teleport.com>
Re: moderation (Steffen Beyer)
Re: Pattern Match Question (David Alan Black)
Re: Perl auto-replier (Steffen Beyer)
Re: scalar holds compiled code (Abigail)
Re: variable names in array problem (David Alan Black)
Re: variable names in array problem (Andrew M. Langmead)
Re: variable substitution (M.J.T. Guy)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 May 1997 16:04:41 GMT
From: etienne@isr.isr.ist.utl.pt (Etienne Grossmann)
Subject: @r=($a=~/./g) Sets @r to the list of matching elements
Message-Id: <5kfnmp$30g@ci.ist.utl.pt>
Keywords: regexp regular expression array list context
Is the fact that
@r=($a=~/./g) Sets @r to the list of matching elements
a normal perl feature? (I did not see it in the man pages)
Etienne
------------------------------
Date: 3 May 1997 15:03:23 GMT
From: I-hate-cyber-promo@man.ac.uk (A.Deckers)
Subject: Re: [DRAFT] RFD: comp.lang.perl.{data-structure,inter-process,programmer,regex}
Message-Id: <slrn5mmktr.frq.I-hate-cyber-promo@news.rediris.es>
In comp.lang.perl.misc,
I-hate-cyber-promo@man.ac.uk wrote:
[...]
The moderation panel will consist of no fewer than 5 and no more
>than 9 members, and shall always comprise an odd number of
>members. [...]
We need 2 more moderators to get off the ground. Come one folks, this
would neither take up much of your time nor require inordinate ammounts
of work. I envisage a system whereby the moderation panel "convenes"
(prolly via a distribution list) once a month to deal with routine
issues, and takes other decisions on a weekly basis or on the spot if
urgency demands it. We're talking a couple of hours a week, tops.
Please reply by email. :-)
Cheers,
Alain
--
Perl information: <URL:http://www.perl.com/perl/>
Perl FAQ: <URL:http://www.perl.com/perl/faq/>
Perl archive: <URL:http://www.perl.com/CPAN/>
------------------------------
Date: 3 May 1997 11:47:25 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: Bug in goto?
Message-Id: <5kf8kd$59f@pirate.shu.edu>
Hello -
"Geoff Mottram" <minaret@sprynet.com> writes:
>Is there a known bug in Perl 5.003 with regards goto statements and
>contexts?
There may be (or have been), but as no one has spoken up, the next
step would be to post some code. I, at least, can't reliably
construct a (non-)working example from your description.
David Black
dblack@icarus.shu.edu
------------------------------
Date: Sat, 3 May 1997 12:51:02 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Combining 2 GIFs in Perl?
Message-Id: <E9Lvp2.1ur@world.std.com>
galfano@ucla.edu (Steven Galfano) writes:
>I have 5 images - a background, and possible five layers to go on top. I
>would like to let the user decide which layers to see on top of the
>background, and then give the the customized output...
>I was hoping (although I knew it wouldn't be that easy) that I could just
>print one GIF file after the other (see my loser code below). Nope -
>didn't work.
>Anyone know a way of conquering this? Are GIFs combinable?
A program that is going to combine to GIF images needs to decode each
GIF file figure out what it wants to do to combine each image, and
build up a new GIF file from scratch. Its probably a task best suited
to be coded in C.
Luckily, there is a graphics library called GD and a perl interface
for it. According to the Perl Win32 FAQ, it is located at
<ftp://ftp.activeware.com/contrib/Win32GD_v960527.zip>
--
Andrew Langmead
------------------------------
Date: Sat, 3 May 1997 07:11:20 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mike Hammernik <mhammer@execpc.com>
Subject: Re: Help Use 1 file to edit another
Message-Id: <Pine.GSO.3.96.970503070117.10951B-100000@kelly.teleport.com>
On Thu, 1 May 1997, Mike Hammernik wrote:
> I would like to cat a file and use each line in that file to delete a
> line in another file. My scenario is having a file with 1744 lines. I
> want to delete lines in a file of 16000 lines that contains the first 2
> fields in file_1.
I find your request confusing. Here is what I _think_ you want.
You want to scan file1 to see what values you can find in the first two
fields of each line. Then, for file2, you want to delete any lines whose
first two fields have the same values you found from file1. Is that right?
A good way to do this sort of thing in Perl is with a hash, which allows
you to quickly look up any key. Since a key can be an arbitrary string,
it's just a matter of having a way to turn each pair of field values into
a unique key string.
I'd probably use something like this rough outline in pseudo-code.
open FILE1, FILE2 for input, open OUT for output; check for success
my %seen; # The hash of field values which have been seen
while (<FILE1>) {
($field1, $field2) = split /\|/; # Or however
$key = "$field1\0$field2"; # Or however
$seen{$key} = 1;
}
# Now every pair of field values is represented in the keys of %seen
while (<FILE2>) {
($field1, $field2) = split /\|/; # Or however
$key = "$field1\0$field2"; # Or however
print OUT unless $seen{$key};
}
close filehandles.
Now you can replace your original file with the new one. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Sat, 3 May 1997 07:23:44 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Alex Dong Li <li@globalserve.net>
Subject: Re: How to use perl to fill up a web form and save result in a file?
Message-Id: <Pine.GSO.3.96.970503072241.10951C-100000@kelly.teleport.com>
On Fri, 2 May 1997, Alex Dong Li wrote:
> I would appreciate it if anyone can tell me where I can find a sample or
> solution to do so: Use a program in perl to access a remote web
> searching machineand save results as local files automatically.
Maybe you're looking for LWP, possibly in connection with cron. LWP is
available from CPAN, and your system probably already has cron, or the
equivalent. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 3 May 1997 16:43:31 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Re: moderation
Message-Id: <5kfpvj$r4d$1@en1.engelschall.com>
Douglas Seay <seay@absyss.fr> wrote:
> Would it be possible to build an auto-moderating robot that looks at the
> sender's address and if the sender is on the "approved" list, allow the
> post, otherwise send a copy of the FAQ and forward the post to the human
> moderator(s).
I think this is better than the authoring.cgi-newsgroup policy that just
sends you the FAQ the first time you post, and then gives you free access:
that wouldn't reduce the high noise/signal ratio, IMHO.
> The human(s) could then accept or reject the post
> depending upon content, complexity, phase of the moon, personal whim,
> whatever. As for this "approved" list, it isn't be in our best
> interests to keep this a closed, good-ol-boy network, so this list
> should be fairly open. If someone has been approved for posting by the
> human moderator(s) 3 times, they are on the list.
Sounds very good. 3 times is a good number! :-)
> Maybe also build some
> sort of Perl test, and if someone can score well enough (knows the
> basics), then let them on the list.
Frankly, I think this is a bad idea.
> Oh yea, I think this moderated group should be in addition to a
> open-to-anybody group. Cutting people off from any Usenet source of
> help would be counter productive.
Seconded vividly!
Yours,
--
Steffen Beyer <sb@sdm.de> http://www.engelschall.com/u/sb/
"There is enough for the need of everyone in this world,
but not for the greed of everyone." - Mahatma Gandhi
>> Unsolicited commercial email goes directly to /dev/null <<
------------------------------
Date: 3 May 1997 11:45:24 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: Pattern Match Question
Message-Id: <5kf8gk$503@pirate.shu.edu>
Hello -
maclaudi@cps.msu.edu (Claudia Ma) writes:
>Hi there,
>Can someone tell me how to get rid of special chars like !, #, (, .. ?
>I used
>$var =~ /\!+|\#+\\(+//g;
>but it didn't work. :(
First of all, you need either s/// or tr/// (but you knew that :-)
If you use s///, put the characters you want to remove into a
character class:
$var =~ s/[\\!#']//g;
A tr/// version, which is somewhat faster, would be:
$var =~ tr/\\!#'//d;
David Black
dblack@icarus.shu.edu
------------------------------
Date: 3 May 1997 16:00:21 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Re: Perl auto-replier
Message-Id: <5kfnel$n7q$1@en1.engelschall.com>
jp <jp@here.com> wrote:
> As always there are ignorant selfish people around. It is very easy to
> answer the question if you can and to also point them to a more
> appropriate group in a not so insulting manner.
> And as far as calling them clueless, those of you that think you can
> answer the questions of the clueless, remember something, you once
> were clueless too.
> If you ignorant people are not yourselves clueless, perhaps you could
> take a look at the name of the group and/or groups.
> Maybe if you were not yourselves clueless you'd understand why the
> clueless come here to find answers to their questions.
> They may well be clueless as you put it, but at least they have common
> sense, the common sense to ask the question that they need the answer
> to in a group with a name that sounds like they'll find it there.
> Most of you, when you do answer a question, only appear to know very
> little yourselves. You never seem to get a grasp of what the person
> realy wants to know and you rarely give the best answer to suit their
> needs. So perhaps we are all a little clueless. ?
I think you are missing a central point, while on the other hand, I
admit that you have a point there.
I'll explain:
We were not talking about some snob elite which looks down on newbies
as though they were trash.
The point is that there are people ABUSING of other people by asking questions
the answers to which they could EASILY have found in the man pages, the FAQ,
or a book.
This is an "I'm too lazy to look for myself, and I don't care about you,
give me what I want" attitude.
It's what we were talking about here.
And we were also talking about the problem of people who LET THEMSELVES
ABUSE by answering these questions.
It is sometimes difficult not to do this, but that's very ungratifying and
frustrating in the long run.
Which is what happened to Tom Christiansen, I think.
On the other hand side, you have a point there when you say that sometimes
people are so clueless about what their problem *is* that they ask something
which may look foolish or obvious to people who know.
Of course nobody wants to exclude or otherwise dissuade those people.
You are right about emphasizing this point, we should keep that in mind.
Yours sincerely,
--
Steffen Beyer <sb@sdm.de> http://www.engelschall.com/u/sb/
"There is enough for the need of everyone in this world,
but not for the greed of everyone." - Mahatma Gandhi
>> Unsolicited commercial email goes directly to /dev/null <<
------------------------------
Date: Sat, 3 May 1997 08:31:40 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: scalar holds compiled code
Message-Id: <E9LJos.zo@nonexistent.com>
On 2 May 1997 20:50:59 GMT, Tom Vaughan wrote in comp.lang.perl.misc
URL: news:01bc573a$6aac7ce0$228118ac@mtn_view_guffey:
++
++ given:
++
++ $stuff = << 'END_OF_STUFF';
++ [compiled program, eg. C]
++ END_OF_STUFF
++
++ how do I execute what $stuff holds?
Look up in the manual or the Camel:
system, qx, backticks and exec.
Abigail
------------------------------
Date: 3 May 1997 11:54:01 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: variable names in array problem
Message-Id: <5kf90p$5a5@pirate.shu.edu>
Hello -
Peter Poranski <poranski@riter.computize.com> writes:
>What I need help with is storing variable names in a array, but not the
>variable.
>lets sat that
> $example[0] = "varName1";
> $example[1] = "varName2";
>if I wanted to call the variable $varName1 using the Array, how would I?
>I have tried quite a few combos including $$example[0] (which, by the
>way, did not work)
$$example[0] first dereferences $$example, and then takes the 0'th
element of the referenced list... except it doesn't, because
$example isn't an array reference (as far as we know).
To get $example[0] treated as a symbolic reference (which is what you
need), you have to override the default evaluation order:
$example[0] = "varName1";
$varName1 = "abc";
print ${$example[0]}; # prints abc - note use of curly braces
David Black
dblack@icarus.shu.edu
------------------------------
Date: Sat, 3 May 1997 13:11:18 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: variable names in array problem
Message-Id: <E9LwMu.6w4@world.std.com>
Peter Poranski <poranski@riter.computize.com> writes:
>What I need help with is storing variable names in a array, but not the
>variable.
>lets sat that
> $example[0] = "varName1";
> $example[1] = "varName2";
>if I wanted to call the variable $varName1 using the Array, how would I?
What you want is a reference to the variable. See the perlref man page
for details.
$example[0] = \$varName1;
$varName1 = 'this is varName1';
print ${$example[0]};
Or using the less desirable symbolic references (so undesireable that
the "use strict" directive flags all symbolic references as an error.)
$example[0] = 'varName1';
$varName1 = 'this is varName1';
print ${$example[0]};
The problem you had before was that
$$example[0]
First tries to get the reference to the variable stored in $example,
and look up the first element of the array that it references.
@array = qw(elem0 elem1 elem2 elem3 elem4);
$example = 'array';
print $$example[0], "\n";
print ${$example}[0],"\n";
--
Andrew Langmead
------------------------------
Date: 4 May 1997 11:59:58 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: variable substitution
Message-Id: <5khtnu$anr@lyra.csx.cam.ac.uk>
In article <3368D7B5.1671@nortel.ca>, Bob Lockie <bjlockie@nortel.ca> wrote:
>I want to do the following inside a print statement.
>
>print "$type_ac$index\n";
>
>but Perl treats "$type_ac" as a variable name.
>
>I tried "$type\_ac" with no luck.
That works for me. But the general mechanism is to put the variable name
in {}:
print "${type}_ac${index}\n";
>From the perldata man page:
Variable substitution inside strings is limited to scalar
variables, arrays, and array slices. (In other words, names
beginning with $ or @, followed by an optional bracketed
expression as a subscript.) The following code segment
prints out "The price is $100."
$Price = '$100'; # not interpreted
print "The price is $Price.\n"; # interpreted
As in some shells, you can put curly brackets around the <<<<<<<<<<<<<<<
name to delimit it from following alphanumerics. <<<<<<<<<<<<<<<
Mike Guy
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 421
*************************************