[11894] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5494 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 27 05:06:49 1999

Date: Tue, 27 Apr 99 02: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           Tue, 27 Apr 1999     Volume: 8 Number: 5494

Today's topics:
    Re: autoincrement magic a..z <uri@sysarch.com>
    Re: autoincrement magic a..z <bgilbert@sgi.com>
    Re: autoincrement magic a..z (Sam Holden)
        Core dump prevented by 'print "";' <alan@chelz.com>
    Re: Extracting emails from array (Bart Lateur)
    Re: FAQ 4.31: How do I pad a string with blanks or pad  (Bart Lateur)
    Re: Fork goddamit! Fork! <Michael.Cameron@no.spam.technologist.com>
        HELP : about ARGV usage smgpage@hotmail.com
    Re: HELP : about ARGV usage <gellyfish@gellyfish.com>
        how block to open file for read? <globus@infonet.ee>
    Re: how block to open file for read? <bdp@mutagenic.org>
    Re: how block to open file for read? <gellyfish@gellyfish.com>
        Installing a module locally: Problem with man pages <ronald_f@my-dejanews.com>
    Re: Installing DBD-Pg-0.91 in RH 5.2 (Jim Britain)
    Re: list of list (Sam Holden)
    Re: MacPerl to AS (well, vice versa) (Carl Stern)
    Re: problem with single quotes or abuse by programmer (Abigail)
        question from a newbie slash_ben@my-dejanews.com
    Re: question from a newbie (Andrew Johnson)
    Re: question from a newbie <gellyfish@gellyfish.com>
    Re: Statistics for comp.lang.perl.misc (Tad McClellan)
        what's wrong with $x = $y or "" renenyffenegger@my-dejanews.com
    Re: what's wrong with $x = $y or "" (Sam Holden)
    Re: what's wrong with $x = $y or "" (Andrew Johnson)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 27 Apr 1999 01:27:44 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: autoincrement magic a..z
Message-Id: <x74sm2aazz.fsf@home.sysarch.com>

>>>>> "b" == bgilbert  <bgilbert@sgi.com> writes:

  b> In article <x7btgaamgg.fsf@home.sysarch.com>,

  b> So in lexical space ... you can go up, but not down?

  b>     for ($i="z"; $i gt "a"; $i--) {print "$i";}

  b> doesn't work, $i-- generates -1 stopping the code next time around ...

  b> Can someone help me understand how the increment works? Is it using ASCII
  b> decimal codes ... and if so how come it can't do the reverse? Thanks.

very simple. magical autoincrement is what its name means, it is only
defined for increment!

and it is using the ascii values (not ascii decimal codes) for the chars
it increments. it is well documented in perlop.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


------------------------------

Date: Mon, 26 Apr 1999 23:41:02 -0700
From: Ben Gilbert <bgilbert@sgi.com>
To: uri@sysarch.com
Subject: Re: autoincrement magic a..z
Message-Id: <37255BFE.7A6D8B86@sgi.com>

Uri Guttman wrote:
> 
> >>>>> "b" == bgilbert  <bgilbert@sgi.com> writes:
>
>   b> So in lexical space ... you can go up, but not down?
> 
>   b>     for ($i="z"; $i gt "a"; $i--) {print "$i";}
> 
>   b> doesn't work, $i-- generates -1 stopping the code next time around ...
> 
>   b> Can someone help me understand how the increment works? Is it using ASCII
>   b> decimal codes ... and if so how come it can't do the reverse? Thanks.
> 
> very simple. magical autoincrement is what its name means, it is only
> defined for increment!
> 
> and it is using the ascii values (not ascii decimal codes) for the chars
> it increments. it is well documented in perlop.

Actually, I looked at perlop and don't think the section on
auto-decrement was well documented. It says: "The auto-decrement
operator is not magical." Straight and to the point, but not detailed by
any means. 

The section on auto-increment is pretty detailed, but it does not
mention anything about incrementing using ascii values, that is why I
asked. 

As to the second part of my question ... why doesn't it work in reverse?

Thanks.


-- 
Ben Gilbert                                     bgilbert(at)sgi.com
Technical Consultant, SGI          http://reality.sgi.com/bgilbert/
-------------------------------------------------------------------
Get out the time fracture wickets Hobbes! We're playing Calvinball!
-------------------------------------------------------------------


------------------------------

Date: 27 Apr 1999 06:25:20 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: autoincrement magic a..z
Message-Id: <slrn7iam2g.71d.sholden@pgrad.cs.usyd.edu.au>

On Mon, 26 Apr 1999 23:41:02 -0700, Ben Gilbert <bgilbert@sgi.com> wrote:
>Uri Guttman wrote:
>> 
>> and it is using the ascii values (not ascii decimal codes) for the chars
>> it increments. it is well documented in perlop.
>
>Actually, I looked at perlop and don't think the section on
>auto-decrement was well documented. It says: "The auto-decrement
>operator is not magical." Straight and to the point, but not detailed by
>any means. 

Not magical means it does what the rest of the documentation says it should.
Strings used as numbers get converted to a number and then have the operation
applied...

>
>The section on auto-increment is pretty detailed, but it does not
>mention anything about incrementing using ascii values, that is why I
>asked. 

Since it is only defined for strings matching ^[a-zA-Z]*[0-9]*$ and not
empty, it does what one would expect by taking a->b->c->...->z->a->... and the
same with uppercase and 0->1->2->...->9->0->... (with carry on all of those)

>
>As to the second part of my question ... why doesn't it work in reverse?

Because -- isn't magical and thus does what the rest of the perl documentation
tells you it should do. It decrements the numeric value o the variable. Thus
the standard stuff happens : If the value isn't a number it gets converted to
a number, and then decremented...

-- 
Sam

the Emacs editor is horrible
	--Linus Torvalds


------------------------------

Date: Tue, 27 Apr 1999 16:23:18 +1000
From: "Alan Fahrner" <alan@chelz.com>
Subject: Core dump prevented by 'print "";'
Message-Id: <XJcV2.3539$116.4356@news2.ozemail.com.au>

Hi all...

I've been recently running into a strange core dumping problem with Perl
5.005_2 and Perl 5.005_3 in AIX 4.3.2.

Although it doesn't always core dump, scripts have been frequently seg
faulting. Once when it happened, the only difference between it faulting and
not faulting was a "print STDERR ..." I had added.  For the heck of it, I
stuck a 'print ""' in the program, and voila...no problems.

After more occassions, some times I have to add more than one 'print ""',
others I have to remove the ones I've added.  Really strange...

Has anyone out there run into this?  Any pointers?

I'm wondering if it has something to do with the "C for AIX 4.3.0.0"
compiler.  It has proven to be buggy with an Apache issue, and I have had it
"optimize" in an infinite loop where there wasn't one once.

Thanks tons

Alan




------------------------------

Date: Tue, 27 Apr 1999 08:20:41 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Extracting emails from array
Message-Id: <372662bf.1648079@news.skynet.be>

Randal L. Schwartz wrote:

>Do you dare exclude the CTO of a company that hasn't got a "nice clean
>c-symbol@foo.bar.com" email address wanting to buy a bunch of your
>stuff, but his email address is "pager:fred"@bob.big.com?

>Just do it right.  Remember that to the left of the "@" can be
>ANYTHING and you won't go wrong.  Stop being so narrow minded.

Well, "pager:fred@bob.big.com" IS an illegal e-mail address. True, left
of the "@" can be anything, but ONLY if quoted, either between "" or
immediately following \ . Otherwise, these are excluded:

	[ ] ( ) < > \ , ; : @ " SPACE CONTROL

(source: RFC-821 original text version pages 30-31, which describes the
canonical e-mail address, i.e. the format an SMTP server expects,
comments etc. removed)

	Bart.


------------------------------

Date: Tue, 27 Apr 1999 08:20:39 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: FAQ 4.31: How do I pad a string with blanks or pad a number with zeroes?
Message-Id: <372560bf.1136343@news.skynet.be>

Tom Christiansen wrote (quoting uri):

>  How do I pad a string with blanks or pad a number with zeroes?

>    The simplest method use the `sprintf' function. It can pad on the
>    left or right with blanks and on the left with zeroes.
>
>        # Left padding with blank:
>        $padded = sprintf( "%${pad_len}s", $text ) ;

Funny that this FAQ doesn't mention pack().

	# Left padding with blank:
	$padded = pack("A$pad_len",$text);

There's a difference with sprintf() when length($text)>$pad_len:

 * pack() -> break off string so resulting length is $pad_len
 * sprintf() -> resulting string is longer than $pad_len

	Bart.


------------------------------

Date: Tue, 27 Apr 1999 08:17:19 +0000
From: Michael Cameron <Michael.Cameron@no.spam.technologist.com>
To: ralawrence@my-dejanews.com
Subject: Re: Fork goddamit! Fork!
Message-Id: <3725728F.206749D@no.spam.technologist.com>

Not the problem which you are trying to solve but:

> open (BLAH, ">>/tmp/blah.txt" || die "erk!");

Shouldn't this read:

open (BLAH, ">>/tmp/blah.txt") || die "erk!";

Michael


------------------------------

Date: Tue, 27 Apr 1999 07:00:29 GMT
From: smgpage@hotmail.com
Subject: HELP : about ARGV usage
Message-Id: <7g3nac$334$1@nnrp1.dejanews.com>

I want to send an argument by ARGV, it is a url of an image says

/james/picture.jpg

my cgi is show.pl

so when I type www.~.com/cgi-bin/show.pl?/james/picture.jpg

there is an eror asking me whether I want to download the file or not.

I think there is problem passing the URL (after the ?)

Dear perl user, how could I correct this problem.

2nd question.
ARGV[0] is the arguments or the cgi filename itself
I am confuse because I know C and I dunno perl.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: 27 Apr 1999 09:39:10 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: HELP : about ARGV usage
Message-Id: <372577ae@newsread3.dircon.co.uk>

smgpage@hotmail.com wrote:
> I want to send an argument by ARGV, it is a url of an image says
> 

The @ARGV array holds the command line arguments to the program.

> /james/picture.jpg
> 
> my cgi is show.pl
> 
> so when I type www.~.com/cgi-bin/show.pl?/james/picture.jpg
> 
> there is an eror asking me whether I want to download the file or not.
> 
> I think there is problem passing the URL (after the ?)
> 
> Dear perl user, how could I correct this problem.
> 
> 2nd question.
> ARGV[0] is the arguments or the cgi filename itself
> I am confuse because I know C and I dunno perl.
> 

You certainly are confused. $0 holds the program filename not $ARGV[0]
which is the first argument.  However you seem to be having some 
difficulty understanding the CGI *and* that Perl is not synonomous with
Programs written to that interface.

I would recommend that you read the CGI specification at:

<http://hoohoo.ncsa.uiuc.edu>

Before you go any further.  Immediately followed bu the CGI FAQ at:

<http://www.webthing.com/tutorials/cgifaq.html>

If then you have any further questions that relate to the CGI (as opposed
to Perl) you should ask them in comp.infosystems.www.authoring.cgi

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



------------------------------

Date: Tue, 27 Apr 1999 09:07:41 +0300
From: Gleb Ekker <globus@infonet.ee>
Subject: how block to open file for read?
Message-Id: <3725542D.AC6DAE80@infonet.ee>

Hi everybody,

please help me with a practical problem.  If some my CGI/Perl script
opens the file for read how can I block to open the same file for
another exemplar of the same CGI/Pepl script?

Thanks,
Gleb.



------------------------------

Date: Tue, 27 Apr 1999 02:17:25 -0600
From: Brian Peisley <bdp@mutagenic.org>
Subject: Re: how block to open file for read?
Message-Id: <37257295.752CDE6@mutagenic.org>

> please help me with a practical problem.  If some my CGI/Perl script
> opens the file for read how can I block to open the same file for
> another exemplar of the same CGI/Pepl script?

The function flock() will do this.

perldoc -f flock

Brian Peisley


------------------------------

Date: 27 Apr 1999 09:46:22 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: how block to open file for read?
Message-Id: <3725795e@newsread3.dircon.co.uk>

Gleb Ekker <globus@infonet.ee> wrote:
> Hi everybody,
> 
> please help me with a practical problem.  If some my CGI/Perl script
> opens the file for read how can I block to open the same file for
> another exemplar of the same CGI/Pepl script?
> 

You would use flock()

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



------------------------------

Date: Tue, 27 Apr 1999 08:37:33 GMT
From: Ronny <ronald_f@my-dejanews.com>
Subject: Installing a module locally: Problem with man pages
Message-Id: <7g3t0d$8lk$1@nnrp1.dejanews.com>

Hi!

Not having root permission, I installed a module locally (MIME-Base64-2.11,
to be precise). I did this using

	gmake  PREFIX=$HOME install

Installation of the Perl files went fine, but it insisted in putting the man
pages under the MAN-tree where the regular man pages reside and where I do not
have access rights. Obviously, PREFIX does not apply to the man path.

Of course I can manually copy the man pages, but is there a neater way to do
this?

Ronald
--
Ronald Fischer <ronald_f@my-dejanews.com>
http://ourworld.compuserve.com/homepages/ronald_fischer/

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Tue, 27 Apr 1999 05:51:50 GMT
From: jbritain@home.com (Jim Britain)
Subject: Re: Installing DBD-Pg-0.91 in RH 5.2
Message-Id: <37274fc1.129154774@news>

On Tue, 27 Apr 1999 03:12:58 GMT, gcellis@my-dejanews.com wrote:

>I am linux newbie (4 months but I have done quite a lot of reading) trying to
>install DBD-Pg 0.91 on a RH5.2 systen with DBI 1.06 and Perl
>5.004.04 with postgresql 6.4.2. I installed postgresql 6.4.2 using RPMs.
>Postgresql is properly installed as I am able to create and maintain databases
>and tables using psql. I get the following:
>
>output from 'perl Makefile.PL'
>
>Configuring Pg
>Remember to actually read the README file !
>$POSTGRES_HOME not defined. Searching for PostgreSQL...
>Found PostgreSQL in
>Writing Makefile for DBD::Pg
>
>******
>
>output from 'make'
>
>cc -c -I/include -I/usr/local/include/pgsql -I/usr/include/pgsql
>-I/usr/lib/perl 5/site_perl/i386-linux/auto/DBI
>-I/usr/lib/perl5/i386-linux/5.00404/DBI -I/auto/ DBI -I/DBI -Dbool=char
>-DHAS_BOOL -I/usr/local/include -O2  -DVERSION=\"0.91\" 
>-DXS_VERSION=\"0.91\" -fpic -I/usr/lib/perl5/i386-linux/5.00404/CORE  Pg.c In
>file included from Pg.xs:13: Pg.h:13: libpq-fe.h: No such file or directory
>make: *** [Pg.o] Error 1
>
>******
>
>I am hoping somebody has done this or seen it before and will be able to help
>me. I have been trying to do this for the last 4 days, including all weekend
>and I am desperate.


If you downloaded the precompiled binary file, then it is quite
likely, you don't have the source file headers required to link other
code.

You'd be better off to download and compile Postgres on your machine
(which would install the header, and library files).

One step back, and two steps forward..


------------------------------

Date: 27 Apr 1999 06:26:47 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: list of list
Message-Id: <slrn7iam57.71d.sholden@pgrad.cs.usyd.edu.au>

On Tue, 27 Apr 1999 04:34:11 GMT, Sheila  Eugenio <seugenio@man.amis.com> wrote:
>I already have a script but my looping doesn't work the way I want it. It
>computed for the sum & avg of all 4 rows. I know there's an easier and
>better way to do it. Thanks for all the help!

Well post the code snippet and some one might be able to point out what is
wrong, rather than doing the whole thing from scratch themselves... 

I can't say what you;ve messed up since you haven't posted the code, and I
don't want to write all the code myself.

-- 
Sam

There's no such thing as a simple cache bug.
	--Rob Pike


------------------------------

Date: Tue, 27 Apr 1999 16:14:10 +0900
From: cwstern@mitXYZZY.edu (Carl Stern)
Subject: Re: MacPerl to AS (well, vice versa)
Message-Id: <cwstern-2704991614100001@sparrow.riken.go.jp>

In article <pudge-2604990959050001@192.168.0.77>, pudge@pobox.com (Chris
Nandor) wrote:
> In article <cwstern-2504992100220001@sparrow.riken.go.jp>,
> cwstern@mitXYZZY.edu (Carl Stern) wrote:
> 
> # The problem is passing the variables along.  Do Script doesn't appear to
> # permit any ARGV
> 
> It does.
> 
>   tell app "MacPerl"
>     Do Script {"MacPerl::Reply(join ':', @ARGV)", 0, 1, 2, 3, 4, 5, 6, 7, 8}
>   end
> 

   Ah, I see.  That works fine, thank you.

   Is this documented somewhere, though?  I looked through all the
associated MacPerl PODs, and your very helpful book, but was unable to
find any reference to this.  It wasn't even mentioned that you could pass
a file name through Do Script and have that script execute, instead of
passing raw text -- something I only found via a experimentation on a
whim.  The Applescript Dictionary is (as usual) somewhat terse.

> Hope that does it for you.  Note that other places to answer this question
> include the newsgroup alt.comp.lang.applescript (which is for Mac
> scripting in general, with a primary focus on AppleScript) and the MacPerl
> mailing lists (http://www.macperl.org/).  This is an OK place to ask, but
> your question has less of a chance of getting a good answer here.  :)

   I would have asked on ACLA, but my wobbly new server unfortunately
carries it without any of the messages (among many it so "carries").  I
tend to avoid mailing lists, especially high-traffic ones, but now I've
read the archives and they seem to be high-bandwidth enough to warrant a
subscription.

   Thanks again.  Now I can put away the RAM disk I was using to pass the
temp file... (eheh)

-- 
Carl Stern          MIT '98 SB Math (Who needs employable skills?)
"Ryan, I've got a plan!  Smack him around the face a few times...
while I hit him with this Buick!"  "Brilliant!  Let's do it!"
           -Fred Perry, Ninja High School No. 57


------------------------------

Date: 27 Apr 1999 05:13:41 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: problem with single quotes or abuse by programmer
Message-Id: <7g3h25$s3n$1@client2.news.psi.net>

fire@dataflo.net (fire@dataflo.net) wrote on MMLXV September MCMXCIII in
<URL:news:37250AF5.5DA010B6@dataflo.net>:
;; 
;; Aren't single quotes supposed to be SACRED?
;; 
;; The error messages make it very clear to me that the \ before the '
;; causes it to not be interpreted as a single quote paired with previous one.
;; Is this because it is in pre compile stage?

No.

This is explained in perlop.

\\ and \' are special inside single quoted strings. \\ means a \, and
\' means a '. You need \', otherwise you cannot put a ' in a '-quoted string.
And because you have \', you need \\, otherwise you cannot have a
\-terminated '-quoted string.

Hence you need:

   BEGIN {
        push(@INC, 'C:\inetpub\wwwroot\mck-shared\\');
        push(@INC, 'C:\inetpub\wwwroot\test-mck\mck-cgi\\');
   }


Of course, there's no need to use backslashes as path separators, 
/ will work just fine. Nor do you need to push on @INC, use lib
will work fine too.



Abigail
-- 
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
                       -> define ("foldoc", "perl")) [0] -> print'


------------------------------

Date: Tue, 27 Apr 1999 05:45:44 GMT
From: slash_ben@my-dejanews.com
Subject: question from a newbie
Message-Id: <7g3iu7$vkp$1@nnrp1.dejanews.com>

how can I print just two lines and all the lines in between them in a file?

Thanks
Slash_Ben

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Tue, 27 Apr 1999 08:01:56 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: question from a newbie
Message-Id: <U9eV2.9271$mR1.430284@news1.rdc1.on.wave.home.com>

In article <7g3iu7$vkp$1@nnrp1.dejanews.com>,
!  slash_ben@my-dejanews.com <slash_ben@my-dejanews.com> wrote: how can
!  I print just two lines and all the lines in between them in a file?

finally, a question with all the necessary information to answer
completely and unequivocally:

1) print your two lines
2) print all the lines in between them

No offense, but how do we know if you want to print line 13, then
line 32, then lines 14 to 31 ... or perhaps every line from line 13
to 32, or maybe every line from one that contains 'foo' to one that
contains 'bar' ... or maybe something else entirely?

One piece of advice: You must learn to clearly define your problem
statement --- doing so will take you more than halfway to a solution.

Also, don't ignore the FAQ's that come with perl: Even with a vague
description such as yours a quick grep of the FAQ's for questions
containing 'between' brings up 10 hits, one of which is:

perlfaq6.pod: How can I pull out lines between two patterns that 
              are themselves on different lines?

If that is no help, please reformulate your question and post again
(leaving 'newbie' out of the subject might net a better response).

regards
andrew

-- 
Andrew L. Johnson   http://members.home.com/andrew-johnson/
      The generation of random numbers is too 
      important to be left to chance.
      


------------------------------

Date: 27 Apr 1999 09:44:57 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: question from a newbie
Message-Id: <37257909@newsread3.dircon.co.uk>

slash_ben@my-dejanews.com wrote:
> how can I print just two lines and all the lines in between them in a file?
> 

Check out the discussion of the range operator in the perlop manpage.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



------------------------------

Date: Mon, 26 Apr 1999 20:09:41 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <58v2g7.0e4.ln@magna.metronet.com>

I R A Aggie (fl_aggie@thepentagon.com) wrote:
: On 26 Apr 1999 21:06:56 GMT, John Callender
: <jbc@shell2.la.best.com>, in <3724d570$0$229@nntp1.ba.best.com> wrote:

: + I suppose I'm not sure what I'm questioning, except that I identify
: + with these newbies, and have a hard time processing it when I see you,
: + in particular, whom I admire greatly for the part you've played in
: + opening so many newbie eyes to the joys of Perl, reflexively putting us
: + down.

: The term "newbie" has certain connotations that are negative.

[snip]

: Let's tackle the subject line issue, since that's what's triggering this.

[snip]

: Personally, I skip most anything with "newbie" in the subject, even if 
: I don't have an entry in my killfile. Why? 


   I often do the same thing. Here's my "why?":

   Anybody who reads this newsgroup knows that there are about
   200 messages a day.

   How many Experts do you suppose read all 200 of them?

   (none, I expect)

   How many Good Enough to Answer My Question type folks do you 
   suppose read all 200 of them?

   (none, I expect)

   How many Learned Perl Last Week type folks do you suppose 
   read all 200 of them?

   (none, I expect)



   So *nobody* reads all 200 messages.

   It does not take an Einstein to see that there is tremendous
   competition to get your article read by someone who happens
   to know the answer.


   How do folks decide what to read and what to skip?
  
   By the contents of the Subject header!


   If the best that a poster can come up with is "Help!"
   or "Perl question", or if they spend some of the
   precious Subject characters pleading (newbie, urgent...)
   instead of using them to state what Perl content is to
   be found inside their article, then they are not very
   logical thinkers.

   Logical thinking is important for programming.


   I want to spend my "newsgroup reading" time to achieve the
   maximum effect, so I tend to aim my meager efforts at helping
   where there is a high probability that the answer will be
   understood.
  
   Following up to an illogical thinkers post has a low 
   probability of being understood, along with a high
   probability of growing to several rounds of followups.

   It's a Darwinian sort of thing...


: Call it "tough love", if you want...

   Call it "survival of the fittest".


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 27 Apr 1999 08:15:19 GMT
From: renenyffenegger@my-dejanews.com
Subject: what's wrong with $x = $y or ""
Message-Id: <7g3rmk$7mp$1@nnrp1.dejanews.com>

Hi

I intend to assigne the value of $y to $x (if $y is defined)
or the empty string (otherwise).

So, I thought I'd be a good idea to go with
$x = $y or "";
Not so perl, saying: Useless use of constant in void context at....

So what's wrong with that and how can I have a shorter version than
the hated
$x = $y if defined $y;
$x = "" unless defined $y;


Thanks


Rene

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: 27 Apr 1999 08:34:22 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: what's wrong with $x = $y or ""
Message-Id: <slrn7iatke.kam.sholden@pgrad.cs.usyd.edu.au>

On Tue, 27 Apr 1999 08:15:19 GMT, renenyffenegger@my-dejanews.com wrote:
>Hi
>
>I intend to assigne the value of $y to $x (if $y is defined)
>or the empty string (otherwise).
>
>So, I thought I'd be a good idea to go with
>$x = $y or "";
>Not so perl, saying: Useless use of constant in void context at....

Precedence. 

You have : ($x = $y) or "". Probably not what you intended... Add some
braces to indicate what you mean or use ||.



-- 
Sam

I don't want Perl to be beautiful--I want you to write beautiful
programs in Perl.
	--Larry Wall


------------------------------

Date: Tue, 27 Apr 1999 08:48:43 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: what's wrong with $x = $y or ""
Message-Id: <LReV2.9274$mR1.431797@news1.rdc1.on.wave.home.com>

In article <7g3rmk$7mp$1@nnrp1.dejanews.com>,
 renenyffenegger@my-dejanews.com <renenyffenegger@my-dejanews.com> wrote:
!  Hi
!  
!  I intend to assigne the value of $y to $x (if $y is defined)
!  or the empty string (otherwise).
!  
!  So, I thought I'd be a good idea to go with
!  $x = $y or "";
!  Not so perl, saying: Useless use of constant in void context at....

precendence for one thing ... '=' has higher precendence than 'or'
so that parses as:

($x = $y) or "";

you would want (but not really) either:

$x = ($y or '');
# or
$x = $y || '';

But, this will assign '' to $x when $y is merely false, not just
when it is undefined...

!  So what's wrong with that and how can I have a shorter version than
!  the hated
!  $x = $y if defined $y;
!  $x = "" unless defined $y;

if you do want to test defined (other than $y evaluating as true as
the two above examples do), then you actually have to use a defined
test. You can do this using the ?: ternary conditional:

$x = defined($y) ? $y : '';

which assigns $y to $x if $y is defined, or else it assigns '' to $x.

regards
andrew


------------------------------

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 5494
**************************************

home help back first fref pref prev next nref lref last post