[15855] in Perl-Users-Digest
Perl-Users Digest, Issue: 3268 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 6 18:10:52 2000
Date: Tue, 6 Jun 2000 15:10:36 -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: <960329436-v9-i3268@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 6 Jun 2000 Volume: 9 Number: 3268
Today's topics:
Re: good perl coding style (Abigail)
Re: good perl coding style <sariq@texas.net>
Re: good perl coding style (Eric Bohlman)
Re: good perl coding style <dan@tuatha.sidhe.org>
Re: good perl coding style <lauren_smith13@hotmail.com>
Re: good perl coding style <lr@hpl.hp.com>
Re: good perl coding style (Abigail)
Re: good perl coding style <sariq@texas.net>
Having trouble matching <ccoffey@humor.wr.usgs.gov>
Re: Having trouble matching <lr@hpl.hp.com>
Re: Having trouble matching <ccoffey@humor.wr.usgs.gov>
Re: Having trouble matching purl_gurl@my-deja.com
Re: How to set an arguments to the environment (Abigail)
Re: How to set an arguments to the environment <kennylim@techie.com>
new Object() vs. Object->new() <lfriedl@genome.wi.mit.edu>
Re: new Object() vs. Object->new() (Greg Bacon)
Re: new Object() vs. Object->new() <lfriedl@genome.wi.mit.edu>
Newbie looking to add autoreply... <dbhost@longhornpenguin.com>
Re: Ordering Elements in an Array <nospam@devnull.com>
Re: Ordering Elements in an Array <sariq@texas.net>
Re: Ordering Elements in an Array <lr@hpl.hp.com>
Re: Perl and PDF Files <randy@theoryx5.uwinnipeg.ca>
Re: Perl and PDF Files rmore1@my-deja.com
Re: Perl gurus: help a C++ programmer optimize his ways (Tad McClellan)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Jun 2000 18:34:38 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: good perl coding style
Message-Id: <8hjg7u$su1$1@news.panix.com>
On Tue, 6 Jun 2000 09:57:41 -0700,
Lauren Smith <lauren_smith13@hotmail.com> wrote:
++
++ W Kemp <bill.kemp@wire2.com> wrote in message
++ news:960279422.516.0.nnrp-07.c3ad6973@news.demon.co.uk...
++ > "do something" if "test condition"
++ >
++ > rather than
++ >
++ > if (test condition){
++ > "do something";
++ > }
++ >
++ > I suppose the second looks more like what a C programmer would expect.
++ > My question is - where did the first style come from? (is it in other
++ > languages). does it have any real advantages?
++
++ I'd answer this question if I could think of any languages where this
++ construct was frequently used.
Would you answer the question if I told you to think about English?
Abigail
------------------------------
Date: Tue, 06 Jun 2000 14:01:53 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: good perl coding style
Message-Id: <393D4AA1.9BA83F19@texas.net>
Abigail wrote:
>
> On Tue, 6 Jun 2000 09:57:41 -0700,
> Lauren Smith <lauren_smith13@hotmail.com> wrote:
> ++
> ++ W Kemp <bill.kemp@wire2.com> wrote in message
> ++ news:960279422.516.0.nnrp-07.c3ad6973@news.demon.co.uk...
> ++ > "do something" if "test condition"
> ++ >
> ++ > rather than
> ++ >
> ++ > if (test condition){
> ++ > "do something";
> ++ > }
> ++ >
> ++ > I suppose the second looks more like what a C programmer would expect.
> ++ > My question is - where did the first style come from? (is it in other
> ++ > languages). does it have any real advantages?
> ++
> ++ I'd answer this question if I could think of any languages where this
> ++ construct was frequently used.
>
> Would you answer the question if I told you to think about English?
I believe that was Lauren's intent (think about English). In fact, I
found Lauren's response to be very Abigailian. :)
- Tom
------------------------------
Date: 6 Jun 2000 19:09:29 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: good perl coding style
Message-Id: <8hji99$1q0$1@slb2.atl.mindspring.net>
Lauren Smith (lauren_smith13@hotmail.com) wrote:
: I'd answer this question if I could think of any languages where this
: construct was frequently used.
As Greg pointed out, human languages rather than programming languages.
Although Perl has a (not well-deserved) reputation for being unreadable
by humans, Larry actually designed it with natural-language principles in
mind, to give programmers the ability to make their programs more
human-readable. Why? For mostly social, rather than technical,
reasons. The majority of a typical programmer's time is spent doing
maintenance rather than creating new code from scratch, and maintenance
accounts for a majority of the total life-cycle cost of a typical piece
of software. Thus programs *do* get read by humans, and making that
process easier is economically valuable.
------------------------------
Date: Tue, 06 Jun 2000 19:16:54 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: good perl coding style
Message-Id: <G6c%4.103334$hT2.419538@news1.rdc1.ct.home.com>
Lauren Smith <lauren_smith13@hotmail.com> wrote:
> W Kemp <bill.kemp@wire2.com> wrote in message
> news:960279422.516.0.nnrp-07.c3ad6973@news.demon.co.uk...
>> "do something" if "test condition"
>>
>> rather than
>>
>> if (test condition){
>> "do something";
>> }
>>
>> I suppose the second looks more like what a C programmer would expect.
>> My question is - where did the first style come from? (is it in other
>> languages). does it have any real advantages?
> I'd answer this question if I could think of any languages where this
> construct was frequently used.
BASIC-PLUS, from the PDPs. (I used it under RSTS/E, but I think it wored
under RSX and might've under RT1 too) Quite a nice feature, and one that
maps well to the way people (as opposed to compilers) think.
Dan
------------------------------
Date: Tue, 6 Jun 2000 12:23:42 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: good perl coding style
Message-Id: <8hjj2n$goi$1@brokaw.wa.com>
Abigail <abigail@arena-i.com> wrote in message
news:8hjg7u$su1$1@news.panix.com...
> On Tue, 6 Jun 2000 09:57:41 -0700,
> Lauren Smith <lauren_smith13@hotmail.com> wrote:
> ++
> ++ W Kemp <bill.kemp@wire2.com> wrote in message
> ++ news:960279422.516.0.nnrp-07.c3ad6973@news.demon.co.uk...
> ++ > "do something" if "test condition"
> ++ > My question is - where did the first style come from? (is it in other
> ++ > languages). does it have any real advantages?
> ++
> ++ I'd answer this question if I could think of any languages where this
> ++ construct was frequently used.
>
>
> Would you answer the question if I told you to think about English?
use English;
require Mental::Energy;
&answer_question('THEN_IF');
Can't locate Mental/Energy.pm in @INC (@INC contains: C:/Perl/lib
C:/Perl/site/l
ib .) at - line 2.
Is there any way to extend a compound statement in then_if-style with an
'else'?
my $foo = $1 if (/(ab*?c)xyz/) else undef $bar;
After thinking about this for a little bit, it seems like it would become
awkward beyond a single condition (or two if you count the 'else').
BLOCK if EXPR else BLOCK if EXPR;
It doesn't seem to have any readability benefit over
if (EXPR) BLOCK elsif (EXPR) BLOCK;
But it does have a 2 character (at first glance, I haven't counted brackets)
advantage. (Assuming, of course that it was legal syntax.)
Lauren
------------------------------
Date: Tue, 6 Jun 2000 12:44:01 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: good perl coding style
Message-Id: <MPG.13a6f460a891c97d98ab2a@nntp.hpl.hp.com>
In article <8hjg7u$su1$1@news.panix.com> on 6 Jun 2000 18:34:38 GMT,
Abigail <abigail@arena-i.com> says...
+ On Tue, 6 Jun 2000 09:57:41 -0700,
+ Lauren Smith <lauren_smith13@hotmail.com> wrote:
+ ++
+ ++ W Kemp <bill.kemp@wire2.com> wrote in message
+ ++ news:960279422.516.0.nnrp-07.c3ad6973@news.demon.co.uk...
+ ++ > "do something" if "test condition"
+ ++ >
+ ++ > rather than
+ ++ >
+ ++ > if (test condition){
+ ++ > "do something";
+ ++ > }
+ ++ >
+ ++ > I suppose the second looks more like what a C programmer would
+ ++ > expect. My question is - where did the first style come from?
+ ++ > (is it in other languages). does it have any real advantages?
+ ++
+ ++ I'd answer this question if I could think of any languages where
+ ++ this construct was frequently used.
+
+ Would you answer the question if I told you to think about English?
Cute, cute, cute, as always.
Uri Guttman initiated a thread (much more than a year ago) on the
origins of Perl locutions, but Deja.com doesn't come up with it at all.
I suggested SNOBOL as the origin, but looking at that now I see my
memory was wrong; the conditional-branching instructions are to the
right of the predicate.
I don't recall if anyone else suggested an origin for this. I do recall
thinking how weird it was when I began to learn Perl. Now it makes
eminent sense, of course. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 6 Jun 2000 19:59:27 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: good perl coding style
Message-Id: <8hjl6t$1ec$1@news.panix.com>
On Tue, 6 Jun 2000 12:44:01 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
++
++ Uri Guttman initiated a thread (much more than a year ago) on the
++ origins of Perl locutions, but Deja.com doesn't come up with it at all.
++ I suggested SNOBOL as the origin, but looking at that now I see my
++ memory was wrong; the conditional-branching instructions are to the
++ right of the predicate.
And there's also PostScript, that has
COND {BLOCK} {BLOCK} ifelse
(Of course, that still has the condition on the left).
Abigail
------------------------------
Date: Tue, 06 Jun 2000 15:27:22 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: good perl coding style
Message-Id: <393D5EAA.5F47CFAA@texas.net>
Larry Rosler wrote:
>
> In article <8hjg7u$su1$1@news.panix.com> on 6 Jun 2000 18:34:38 GMT,
> Abigail <abigail@arena-i.com> says...
> + On Tue, 6 Jun 2000 09:57:41 -0700,
> + Lauren Smith <lauren_smith13@hotmail.com> wrote:
> + ++
> + ++ W Kemp <bill.kemp@wire2.com> wrote in message
> + ++ news:960279422.516.0.nnrp-07.c3ad6973@news.demon.co.uk...
> + ++ > "do something" if "test condition"
> + ++ >
> + ++ > rather than
> + ++ >
> + ++ > if (test condition){
> + ++ > "do something";
> + ++ > }
> + ++ >
> + ++ > I suppose the second looks more like what a C programmer would
> + ++ > expect. My question is - where did the first style come from?
> + ++ > (is it in other languages). does it have any real advantages?
> + ++
> + ++ I'd answer this question if I could think of any languages where
> + ++ this construct was frequently used.
> +
> + Would you answer the question if I told you to think about English?
>
> Cute, cute, cute, as always.
Agreed, but I still claim that you're not giving Lauren her due...
- Tom
------------------------------
Date: Tue, 6 Jun 2000 18:51:03 GMT
From: Chris Coffey <ccoffey@humor.wr.usgs.gov>
Subject: Having trouble matching
Message-Id: <Pine.LNX.4.10.10006061131140.15362-100000@humor.wr.usgs.gov>
I can't seem to match a "?". I thought that the "." would match anything
but when I use it, it won't match a "?". Am I wrong or does the "." not
match a "?". Maybe the way I'm going about my problem is wrong. I have a
line of text like this:
avit_001 ????????? BAD TAPE - CANT READ; Site: Mt. Ranier 1, ADF Fixed
File Labels, Sun Data Format, AVIRIS Calibrated Data Tape ID: PG03030,
Flight 940719B, Run 7, Scenes: 3
I want to take this line (above) and break into 3 parts. Label: avit_001,
Date: ?????????, Description: rest of line.
Here is what I thought I would do:
($labe, $date, $desc) = /^(\w+)\s+(\w+)\s+(\w.+)/i;
Is this a good way of going about solving my problem? This works fine if
there is no question mark in the line of text.
Thanks for your help in advance!
Chris
------------------------------
Date: Tue, 6 Jun 2000 12:52:52 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Having trouble matching
Message-Id: <MPG.13a6f66fba60c81f98ab2b@nntp.hpl.hp.com>
In article <Pine.LNX.4.10.10006061131140.15362-100000@humor.wr.usgs.gov>
on Tue, 6 Jun 2000 18:51:03 GMT, Chris Coffey
<ccoffey@humor.wr.usgs.gov> says...
> I can't seem to match a "?". I thought that the "." would match anything
> but when I use it, it won't match a "?". Am I wrong or does the "." not
> match a "?".
It does, but there is no '.' at that point in your regex.
> Maybe the way I'm going about my problem is wrong. I have a
> line of text like this:
>
>
> avit_001 ????????? BAD TAPE - CANT READ; Site: Mt. Ranier 1, ADF Fixed
> File Labels, Sun Data Format, AVIRIS Calibrated Data Tape ID: PG03030,
> Flight 940719B, Run 7, Scenes: 3
>
>
> I want to take this line (above) and break into 3 parts. Label: avit_001,
> Date: ?????????, Description: rest of line.
>
> Here is what I thought I would do:
>
> ($labe, $date, $desc) = /^(\w+)\s+(\w+)\s+(\w.+)/i;
>
> Is this a good way of going about solving my problem? This works fine if
> there is no question mark in the line of text.
Your regex says that the second field ($date) is all 'word' characters
(\w+). '?' isn't a word character.
Rather than hacking that into the regex, try a different approach, using
split().
my ($label, $date, $desc) = split " ", $_, 3;
perldoc -f split
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 6 Jun 2000 20:48:00 GMT
From: Chris Coffey <ccoffey@humor.wr.usgs.gov>
Subject: Re: Having trouble matching
Message-Id: <Pine.LNX.4.10.10006061347390.18931-100000@humor.wr.usgs.gov>
Thanks for your help. I appreciate it!
Chris
On Tue, 6 Jun 2000, Larry Rosler wrote:
> In article <Pine.LNX.4.10.10006061131140.15362-100000@humor.wr.usgs.gov>
> on Tue, 6 Jun 2000 18:51:03 GMT, Chris Coffey
> <ccoffey@humor.wr.usgs.gov> says...
> > I can't seem to match a "?". I thought that the "." would match anything
> > but when I use it, it won't match a "?". Am I wrong or does the "." not
> > match a "?".
>
> It does, but there is no '.' at that point in your regex.
>
> > Maybe the way I'm going about my problem is wrong. I have a
> > line of text like this:
> >
> >
> > avit_001 ????????? BAD TAPE - CANT READ; Site: Mt. Ranier 1, ADF Fixed
> > File Labels, Sun Data Format, AVIRIS Calibrated Data Tape ID: PG03030,
> > Flight 940719B, Run 7, Scenes: 3
> >
> >
> > I want to take this line (above) and break into 3 parts. Label: avit_001,
> > Date: ?????????, Description: rest of line.
> >
> > Here is what I thought I would do:
> >
> > ($labe, $date, $desc) = /^(\w+)\s+(\w+)\s+(\w.+)/i;
> >
> > Is this a good way of going about solving my problem? This works fine if
> > there is no question mark in the line of text.
>
> Your regex says that the second field ($date) is all 'word' characters
> (\w+). '?' isn't a word character.
>
> Rather than hacking that into the regex, try a different approach, using
> split().
>
> my ($label, $date, $desc) = split " ", $_, 3;
>
> perldoc -f split
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
>
>
------------------------------
Date: Tue, 06 Jun 2000 20:56:17 GMT
From: purl_gurl@my-deja.com
Subject: Re: Having trouble matching
Message-Id: <8hjoh6$kas$1@nnrp1.deja.com>
Chris Coffey <ccoffey@humor.wr.usgs.gov> asks:
> I can't seem to match a "?". I thought that the "." would match
> anything but when I use it, it won't match a "?". Am I wrong or
> does the "." not match a "?". Maybe the way I'm going about my
> problem is wrong. I have a line of text like this:
(snipped)
A different perspective on this may be of help. A notion I stress
on a regular basis is to precondition your input data whenever
possible for ease in manipulation, especially if you cannot setup
your data base in a clean logical manner with clear delimiters.
Within my test script below, you will find two methods. My first
method deals with question marks for your date. Second method,
deals with a common date format in place of your question marks.
Either can be easily adapted as needed for changing circumstances.
You really have no need for razzle dazzle substitution operators
which might introduce errors with different characters in your
data input. One or two very basic simple substitution operators
resolve your problem and precondition your input.
Should your data base contain both question marks for a date
and actual dates, easy enough to use this logic:
if my data matches question marks for a date,
use this substitution scheme.
else use my other substitution scheme.
Have a look at my printed results and test script. This will work
fine as long as your input maintains a fairly consistent input
format as you show in your example. If not, this is certainly
easy to modify and adapt as needed. Your commas and colons are
critical components for this data base manipulation methodolgy,
to keep those first two sets of spaces 'clean' and easy to locate.
PRINTED RESULT
===============
Question Marks For Date Method:
_______________________________
Input:
avit_001 ????????? BAD TAPE - CANT READ; Site: Mt. Ranier 1, ADF Fixed
File Labels, Sun Data Format, AVIRIS Calibrated Data Tape ID: PG03030,
Flight 940719B, Run 7, Scenes: 3
Output:
Variable 1:
avit_001
Variable 2:
?????????
Variable 3:
BAD TAPE - CANT READ; Site: Mt. Ranier 1, ADF Fixed
File Labels, Sun Data Format, AVIRIS Calibrated Data Tape ID: PG03030,
Flight 940719B, Run 7, Scenes: 3
Date In Place Of Question Marks Method:
_______________________________________
Input:
avit_001 06/06/2000 BAD TAPE - CANT READ; Site: Mt. Ranier 1, ADF Fixed
File Labels, Sun Data Format, AVIRIS Calibrated Data Tape ID: PG03030,
Flight 940719B, Run 7, Scenes: 3
Output:
Variable 1:
avit_001
Variable 2:
06/06/2000
Variable 3:
BAD TAPE - CANT READ; Site: Mt. Ranier 1, ADF Fixed
File Labels, Sun Data Format, AVIRIS Calibrated Data Tape ID: PG03030,
Flight 940719B, Run 7, Scenes: 3
TEST SCRIPT
===========
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
## Method One:
$string = "avit_001 ????????? BAD TAPE - CANT READ; Site: Mt. Ranier 1,
ADF Fixed
File Labels, Sun Data Format, AVIRIS Calibrated Data Tape ID: PG03030,
Flight 940719B, Run 7, Scenes: 3";
print "Question Marks For Date Method:
_______________________________\n\n";
print "Input:\n\n$string\n\n";
$string =~ s/([0-9]) /$1¦/;
$string =~ s/(\?) /$1¦/;
local ($var1, $var2, $var3) = split (/¦/, $string);
print "Output:\n";
print "
Variable 1:
$var1\n
Variable 2:
$var2\n
Variable 3:
$var3";
## Method Two:
$string = "avit_001 06/06/2000 BAD TAPE - CANT READ; Site: Mt. Ranier
1, ADF Fixed
File Labels, Sun Data Format, AVIRIS Calibrated Data Tape ID: PG03030,
Flight 940719B, Run 7, Scenes: 3";
print "\n\n\nDate In Place Of Question Marks Method:
_______________________________________\n\n";
print "Input:\n\n$string\n\n";
$string =~ s/([0-9]) /$1¦/g;
local ($var1, $var2, $var3) = split (/¦/, $string);
print "Output:\n";
print "
Variable 1:
$var1\n
Variable 2:
$var2\n
Variable 3:
$var3";
exit;
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 6 Jun 2000 19:38:27 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: How to set an arguments to the environment
Message-Id: <8hjjvj$sm$4@news.panix.com>
On Tue, 6 Jun 2000 10:29:43 -0700, Kenny Lim <kennylim@techie.com> wrote:
++
++
++ It would be greatly appreciated if anyone can advise me or provide a sample
++ as to how I can achieve the following objective..
++
++ (a) Parse an argument from script A to script B ?
perldoc -f system
++ If this is not possible.....
++
++ (b) How to set to the environment variables for each shell being invoked.
++ (There would be multiple shell being invoked from the first script to
++ the second
++ and I would like to ensure that each shell being invoked has the
++ argument
++ set to the environment)
man perlvar
Abigail
------------------------------
Date: Tue, 6 Jun 2000 13:15:59 -0700
From: "Kenny Lim" <kennylim@techie.com>
Subject: Re: How to set an arguments to the environment
Message-Id: <rYc%4.35067$5k2.58637@dfw-read.news.verio.net>
Thanks for the pointers !
Kenny-
"Abigail" <abigail@arena-i.com> wrote in message
news:8hjjvj$sm$4@news.panix.com...
> On Tue, 6 Jun 2000 10:29:43 -0700, Kenny Lim <kennylim@techie.com> wrote:
> ++
> ++
> ++ It would be greatly appreciated if anyone can advise me or provide a
sample
> ++ as to how I can achieve the following objective..
> ++
> ++ (a) Parse an argument from script A to script B ?
>
> perldoc -f system
>
> ++ If this is not possible.....
> ++
> ++ (b) How to set to the environment variables for each shell being
invoked.
> ++ (There would be multiple shell being invoked from the first script
to
> ++ the second
> ++ and I would like to ensure that each shell being invoked has the
> ++ argument
> ++ set to the environment)
>
> man perlvar
>
>
>
> Abigail
------------------------------
Date: Tue, 06 Jun 2000 15:57:21 -0400
From: Lisa Friedland <lfriedl@genome.wi.mit.edu>
Subject: new Object() vs. Object->new()
Message-Id: <393D57A1.7B7688A9@genome.wi.mit.edu>
$tmp = new Parse::FastaQuality();
This statement works in various places throughout my program, but when I
copied it to where I now want it, I get the error "Undefined subroutine
&Parse::FastaQuality::new called at ..."
The package Parse::FastaQuality seems fine enough. It does inherit its
"new" method (which, as man perlobj tells me, means
Parse::FastaQuality::new() won't find the function), but as far as I can
tell the above call should always be equivalent to
$tmp = Parse::FastaQuality->new(), which does work everywhere.
Has anyone seen this before? I just can't explain it at all.
thanks,
-Lisa
------------------------------
Date: Tue, 06 Jun 2000 21:03:29 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: new Object() vs. Object->new()
Message-Id: <sjqpp1ct2t567@corp.supernews.com>
Terminology nit: your Subject: really ought to be
new Class() vs. Class->new()
In article <393D57A1.7B7688A9@genome.wi.mit.edu>,
Lisa Friedland <lfriedl@genome.wi.mit.edu> wrote:
: $tmp = new Parse::FastaQuality();
: This statement works in various places throughout my program, but when I
: copied it to where I now want it, I get the error "Undefined subroutine
: &Parse::FastaQuality::new called at ..."
Have you loaded the Parse::FastaQuality package? One way to do this is
to stick its code in Parse/FastaQuality.pm and say
C<use Parse::FastaQuality;>. Another way is to stick its code in
Parse/FastaQuality.pl and say
use lib 'Parse';
require 'FastaQuality.pl';
: The package Parse::FastaQuality seems fine enough. It does inherit its
: "new" method (which, as man perlobj tells me, means
: Parse::FastaQuality::new() won't find the function), but as far as I can
: tell the above call should always be equivalent to
: $tmp = Parse::FastaQuality->new(), which does work everywhere.
Does the Parse::FastaQuality class load its superclasses?
Greg
--
The O-O languages give you more of course - prettier syntax, derived types and
so on - but conceptually they provide little extra.
-- Rob Pike
------------------------------
Date: Tue, 06 Jun 2000 17:21:46 -0400
From: Lisa Friedland <lfriedl@genome.wi.mit.edu>
Subject: Re: new Object() vs. Object->new()
Message-Id: <393D6B6A.6DE44448@genome.wi.mit.edu>
> : $tmp = new Parse::FastaQuality();
> : This statement works in various places throughout my program, but when I
> Have you loaded the Parse::FastaQuality package?
> Does the Parse::FastaQuality class load its superclasses?
yes, and yes.
It does work elsewhere (a different method of the same package I'm
writing), which shows it loaded itself & superclasses without errors (at
the start of the program). And the other syntax of the call should have
broken if that were the case, no?
For what it's worth, 2 people I've asked about this say "yeah, I've seen
that sort of thing before but didn't know why, so just switched to using
the Object->new() form".
-Lisa
------------------------------
Date: Tue, 06 Jun 2000 14:02:47 -0500
From: David Hostetler <dbhost@longhornpenguin.com>
Subject: Newbie looking to add autoreply...
Message-Id: <393D4AD7.B3E3F7DE@longhornpenguin.com>
I have been trying to add an Autoreply feature to a form mailer script
and I am not sure where it is broken.
When I run the thing from the command prompt I get no errors. It just
does not seem to work. Not only does it not send email to the address
that was specified in $FORM('EMAIL') but it also no longer sends mail to
$recipient = user@domain.com (a B.S. address but you get the idea.).
Would somebody be so kind as to direct me to a tuorial on how to do
this?
Thanks.
Dave.
#!/usr/bin/perl
print "Content-type:text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
$mailprog = '/usr/sbin/sendmail';
# change this to your own email address
$recipient = 'user@domain.com';
# this field is used to mandate that the FNAME LNAME and EMAIL fields
are filled in
if ($FORM{'FNAME'} eq "" or $FORM{'LNAME'} eq "" or $FORM{'EMAIL'} eq
"") {
dienice("Please make sure the fields for your First Name, Last Name, and
Email address are filled in
correctly.");
}
# this opens an output stream and pipes it directly to the sendmail
# program. If sendmail can't be found, abort nicely by calling the
# dienice subroutine (see below)
open (MAIL, "|$mailprog -t") or &dienice("Can't access $mailprog!\n");
# here we're printing out the header info for the mail message. You must
# specify who it's to, or it won't be delivered:
print MAIL "To: $recipient\n";
# Reply-to can be set to the email address of the sender, assuming you
# have actually defined a field in your form called 'email'.
print MAIL "Reply-to: $FORM{'email'} ($FORM{'name'})\n";
# print out a subject line so you know it's from your form cgi.
# The two \n\n's end the header section of the message. anything
# you print after this point will be part of the body of the mail.
print MAIL "Subject: Form Data\n\n";
# here you're just printing out all the variables and values, just like
# before in the previous script, only the output is to the mail message
# rather than the followup HTML page.
foreach $key (keys(%FORM)) {
print MAIL "$key = $FORM{$key}\n";
}
# when you finish writing to the mail message, be sure to close the
# input stream so it actually gets mailed.
close(MAIL);
# now print something to the HTML page, usually thanking the person
# for filling out the form, and giving them a link back to your homepage
print <<EndHTML;
<h2>Thank You</h2>
Thank you for writing. Your mail has been delivered.<p>
Return to our <a
href="http://www.domain.com/~user/home.html">home page</a>.
</body></html>
EndHTML
sub dienice {
($errmsg) = @_;
print "<h2>Error</h2>\n";
print "$errmsg<p>\n";
print "</body></html>\n";
exit;
}
------------------------------
Date: 6 Jun 2000 18:21:36 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: Ordering Elements in an Array
Message-Id: <8hjffg$gqs$0@216.155.32.134>
In article <8hb879$73u$1@mawar.singnet.com.sg>, "Swee Heng"
<sweeheng@usa.net> wrote:
| > I would like to have the @items array in a particular order.
| >
| > Right now the array looks like this:
| > @items =CJ1 CJ2 FU1 FU2 0 3 21 1
| >
| > I would like this:
| >
| > @items =CJ1 0 CJ2 3 FU1 21 FU2 1
|
| Try this:
|
| @one = qw(a b c d e);
| @two = qw(1 2 3 4 5);
| push @items, (shift @one, shift @two) while @one;
| print "@items\n";
why not use a hash instead, if they are always to be paired?
#!perl -w
@one = qw(a b c d e);
@two = qw(1 2 3 4 5);
for (0 .. $#one) { $items{$one[$_]} = $two[$_] };
foreach (keys %items) { print "$_ = $items{$_}\n" };
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Tue, 06 Jun 2000 13:40:40 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Ordering Elements in an Array
Message-Id: <393D45A8.BF9576E3@texas.net>
The WebDragon wrote:
>
> In article <8hb879$73u$1@mawar.singnet.com.sg>, "Swee Heng"
> <sweeheng@usa.net> wrote:
>
> | > I would like to have the @items array in a particular order.
> | >
> | > Right now the array looks like this:
> | > @items =CJ1 CJ2 FU1 FU2 0 3 21 1
> | >
> | > I would like this:
> | >
> | > @items =CJ1 0 CJ2 3 FU1 21 FU2 1
> |
> | Try this:
> |
> | @one = qw(a b c d e);
> | @two = qw(1 2 3 4 5);
> | push @items, (shift @one, shift @two) while @one;
> | print "@items\n";
>
> why not use a hash instead, if they are always to be paired?
>
> #!perl -w
>
No strict pragma?
> @one = qw(a b c d e);
> @two = qw(1 2 3 4 5);
>
> for (0 .. $#one) { $items{$one[$_]} = $two[$_] };
@items{@one} = @two;
http://www.sysarch.com/perl/tutorials/hash_slices.txt
- Tom
------------------------------
Date: Tue, 6 Jun 2000 11:48:07 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Ordering Elements in an Array
Message-Id: <MPG.13a6e740c3ac098898ab28@nntp.hpl.hp.com>
In article <8hjffg$gqs$0@216.155.32.134> on 6 Jun 2000 18:21:36 GMT, The
WebDragon <nospam@devnull.com> says...
> In article <8hb879$73u$1@mawar.singnet.com.sg>, "Swee Heng"
> <sweeheng@usa.net> wrote:
> | > I would like to have the @items array in a particular order.
> | >
> | > Right now the array looks like this:
> | > @items =CJ1 CJ2 FU1 FU2 0 3 21 1
> | >
> | > I would like this:
> | >
> | > @items =CJ1 0 CJ2 3 FU1 21 FU2 1
> |
> | Try this:
> |
> | @one = qw(a b c d e);
> | @two = qw(1 2 3 4 5);
> | push @items, (shift @one, shift @two) while @one;
> | print "@items\n";
>
> why not use a hash instead, if they are always to be paired?
But that loses the order, which may be important.
> #!perl -w
use strict;
my
> @one = qw(a b c d e);
my
> @two = qw(1 2 3 4 5);
>
> for (0 .. $#one) { $items{$one[$_]} = $two[$_] };
# A hash slice is MUCH faster:
my %items;
@items{@one} = @two;
> foreach (keys %items) { print "$_ = $items{$_}\n" };
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 6 Jun 2000 18:33:45 GMT
From: Randy Kobes <randy@theoryx5.uwinnipeg.ca>
Subject: Re: Perl and PDF Files
Message-Id: <8hjg69$263$1@canopus.cc.umanitoba.ca>
In comp.lang.perl.misc, 572_dex@my-deja.com wrote:
> Am Wanting to Generate Index Pages for directories
> the HTML pages are reasonably transparent anybody know
> of a Perl Module to Extract the Document Properties from a
> Acrobat PDF file.
Try the PDF module - see, for example,
http://theoryx5.uwinnipeg.ca/CPAN/data/PDF/PDF.html
for documentation on its use and where to get it.
best regards,
randy kobes
------------------------------
Date: Tue, 06 Jun 2000 18:29:12 GMT
From: rmore1@my-deja.com
Subject: Re: Perl and PDF Files
Message-Id: <8hjft2$d3l$1@nnrp1.deja.com>
In article <8hjb2q$946$1@nnrp1.deja.com>,
572_dex@my-deja.com wrote:
> Am Wanting to Generate Index Pages for directories
> the HTML pages are reasonably transparent anybody know
> of a Perl Module to Extract the Document Properties from a
> Acrobat PDF file.
>
Try:
http://search.cpan.org/doc/ANTRO/PDF-111/PDF/Parse.pm
http://search.cpan.org/search?mode=module&query=pdf
--
=============================
Richard More
http://www.richmore.com/
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 6 Jun 2000 10:20:39 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl gurus: help a C++ programmer optimize his ways
Message-Id: <slrn8jq5m7.q1.tadmc@maxim.metronet.com>
On Tue, 6 Jun 2000 21:41:42 +0200, Michael Schlueter
<michael.schlueter@philips.com> wrote:
>Some reply to your reply.
>
>* The right way to do it with use strict; is:
>
> !#/usr/local/bin/perl -w
> use strict;
>
> my $global_var; # global in this namespace = this package-file
^^^^^^^^^^^^^^
No.
my() variables are NEVER in a package.
The right way (to have a "global" local() variable) is with "use vars".
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3268
**************************************