[25435] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7680 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 21 14:15:37 2005

Date: Fri, 21 Jan 2005 11:15:30 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 21 Jan 2005     Volume: 10 Number: 7680

Today's topics:
    Re: Perl and waiting for execution of external program <noreply@gunnar.cc>
    Re: Perl and waiting for execution of external program <1usa@llenroc.ude.invalid>
    Re: Perl and waiting for execution of external program xhoster@gmail.com
    Re: Perl6 book <bik.mido@tiscalinet.it>
    Re: Perl6 book <bik.mido@tiscalinet.it>
        pod documents and shells? <mikee@mikee.ath.cx>
    Re: pod documents and shells? <jl_post@hotmail.com>
    Re: pod documents and shells? <mikee@mikee.ath.cx>
    Re: Question? Alternative to loading modules!!! ioneabu@yahoo.com
    Re: Question? Alternative to loading modules!!! xhoster@gmail.com
    Re: Question? Alternative to loading modules!!! <chicks_hate_me@hotmail.com>
    Re: Question? Alternative to loading modules!!! <cwilbur@mithril.chromatico.net>
    Re: Question? Alternative to loading modules!!! (Peter Scott)
    Re: Radix Sort in CPAN <ewijaya@singnet.com.sg.removethis>
    Re: Radix Sort in CPAN <spamtrap@dot-app.org>
    Re: Radix Sort in CPAN <ewijaya@singnet.com.sg.removethis>
    Re: regular expressions <eighner@io.com>
        saying my $a=0; my $b=0; more compactly <jidanni@jidanni.org>
    Re: saying my $a=0; my $b=0; more compactly <1usa@llenroc.ude.invalid>
    Re: saying my $a=0; my $b=0; more compactly <goedicke@goedsole.com>
    Re: saying my $a=0; my $b=0; more compactly <do-not-use@invalid.net>
    Re: saying my $a=0; my $b=0; more compactly <1usa@llenroc.ude.invalid>
    Re: switching to extended character set using curses &  someone92@hotmail.com
    Re: switching to extended character set using curses &  someone92@hotmail.com
        Thanks! (was: does foreach (@list) alter @list??) <hendrik_maryns@despammed.com>
    Re: The world's shortest 'Hello World!' program: a prop <troc@pobox.com>
    Re: The world's shortest 'Hello World!' program: a prop <responder_solo_en_el_grupo@yahoo.es>
    Re: The world's shortest 'Hello World!' program: a prop <bik.mido@tiscalinet.it>
    Re: The world's shortest 'Hello World!' program: a prop <perl@lennychallis.co.uk>
    Re: The world's shortest 'Hello World!' program: a prop <emschwar@fc.hp.com>
    Re: Whats the variable holding the dir seperator? <jgibson@mail.arc.nasa.gov>
        why not multiple statement modifiers? ioneabu@yahoo.com
    Re: why not multiple statement modifiers? <nobull@mail.com>
    Re: why not multiple statement modifiers? ioneabu@yahoo.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 20 Jan 2005 17:29:57 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl and waiting for execution of external program
Message-Id: <35a4r5F4jtm57U1@individual.net>

jonas.andersson@rocketmail.com wrote:
> here are the symptoms:
> 
> $linenumber=796;
> open (PROG, "|$MyProgram &> /dev/null") or &err;
> 
> print PROG "Load file $FileName\n";
> print PROG "Calculate all\n";
> $linenumber=801;
> close (PROG) or &err;
> $linenumber=$803;
> 
> ...
> 
> sub err {
> 
> print "error - last line to be noted was $linenumber \n";
> exit;
> }

You'd better make use of the $! variable to grab the *reason* for the 
failure:

     open PROG, "|$MyProgram &> /dev/null"
       or err("Error - couldn't open pipe to $MyProgram: $!");
     print PROG "Load file $FileName\n";
     print PROG "Calculate all\n";
     close PROG or err("Error - couldn't close pipe: $!");

     sub err { print shift; exit 1 }

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 20 Jan 2005 17:13:19 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl and waiting for execution of external program
Message-Id: <Xns95E47C5B2A53Casu1cornelledu@132.236.56.8>

jonas.andersson@rocketmail.com wrote in news:1106236867.183882.199950
@f14g2000cwb.googlegroups.com:

>> What the symptoms actually *are* would be more useful in solving
>> the problem then your interpretation of what they "look like."
>> You should be providing the first instead of the second, rather
>> than the other way around.

> here are the symptoms:

Something tells me you have made a delicious spaghetti and I do not have 
the inclination to go through it. You should read the posting guidelines 
which contains invaluable suggestions on how to help others help you.

> $linenumber=796;

$linenumber = __LINE__;

> open (PROG, "|$MyProgram &> /dev/null") or &err;

open my $prog, "|MyProgram &> /dev/null" 
    	or die $!;

> $linenumber=$803;

What is $803?

Sinan.


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

Date: 20 Jan 2005 18:31:33 GMT
From: xhoster@gmail.com
Subject: Re: Perl and waiting for execution of external program
Message-Id: <20050120133133.176$cT@newsreader.com>

jonas.andersson@rocketmail.com wrote:
> > What the symptoms actually *are* would be more useful in solving
> > the problem then your interpretation of what they "look like."
> > You should be providing the first instead of the second, rather
> > than the other way around.
>
> OK,
>
> here are the symptoms:
>
> $linenumber=796;
> open (PROG, "|$MyProgram &> /dev/null") or &err;
>
> print PROG "Load file $FileName\n";
> print PROG "Calculate all\n";
> $linenumber=801;
> close (PROG) or &err;
> $linenumber=$803;
>
> ...
>
> sub err {
>
> print "error - last line to be noted was $linenumber \n";
> exit;
> }

Why have such a pointless err subroutine?  die will automatically
tell you the line number, with greater precision, and without polluting
your code with the global variable $linenumber.


>
> The symptoms being that it sometimes ends with sub err printing 801,
> suggesting that it ended on the line 'close (PROG) or &err;', ie

Instead of asking us why the close is failing, try asking your computer.
That is what $! is for.

> failure to close the program [premature close attempt?].

I've never heard of that error.

Most likely your pipe open failed, but perl doesn't realize this until
close is called.  I would guess it is a permission or path issue with
the external program.  But use $! to find out.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Thu, 20 Jan 2005 20:56:35 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl6 book
Message-Id: <lm10v0pcb7pl4ua3fo7ibtlg4b918tto22@4ax.com>

On 19 Jan 2005 14:52:42 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:

>> matters: after staying for some time in p6l I realized it was obsolete
>> the very moment trees were cut or even before...
>
>While true, and acknowledged by the authors, this doesn't mean the book
>is useless.  The book doesn't (and can't) tell you how to program in Perl
>6, but it does give you an idea what it will be like to program
>in Perl 6, and that is much less likely to change.  I, for one, have
>bought it and enjoyed the outlook a lot, even if I know better than to
>memorize syntax at this stage.

I would like to point out to the OP and to everyone else that I second
completely your cmt and to stress that my claim was _not_ meant to
picture it as _useless_.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 20 Jan 2005 20:56:39 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl6 book
Message-Id: <rq10v0ttt54a4thv5gf48pvcldjk962jjp@4ax.com>

On 19 Jan 2005 07:20:15 -0800, "Jim Keenan"
<jkeen_via_google@yahoo.com> wrote:

>> matters: after staying for some time in p6l I realized it was
>> obsolete
>> the very moment trees were cut or even before...
>>
>
>An overly harsh judgment, IMHO.

I must admit that in some sense it is.

>I did not buy the first edition of the book; I waited for the second.
>I do not regret buying it.  Are you going to use it to implement
>production code in Perl 6?  No.  But if you haven't had the time to
>keep up with the development of Perl 6 as reported in the weekly
>summaries, the second edition gives you a good starting point.  I, for
>one, found it a considerably more challenging read than I would have
>expected.

However please note that even if my words may suggest the contrary, I
never wanted to suggest that the book has no value whatsoever. See
also my followup to Anno's post.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 20 Jan 2005 20:49:21 GMT
From: Mike <mikee@mikee.ath.cx>
Subject: pod documents and shells?
Message-Id: <lPUHd.1068$jr7.7@fe03.lga>

Is there a way to document shells (sh, ksh, csh, etc.) using pod?


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

Date: 20 Jan 2005 13:55:42 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: pod documents and shells?
Message-Id: <1106258142.211155.113540@f14g2000cwb.googlegroups.com>

Mike wrote:
> Is there a way to document shells (sh, ksh, csh, etc.) using pod?


Sure.

Just save the following (without the "|") in a file called "ksh.pod":


|=head1 NAME
|
|ksh - a shell
|
|=head1 SYNOPSIS
|
|   ksh
|
|=head1 DESCRIPTION
|
|Description goes here.
|
|=cut


Then you can type "perldoc ksh" to see the documentation, or "pod2html
ksh > ksh.html" to create an HTML file.
Hope this helps,

   -- Jean-Luc



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

Date: Thu, 20 Jan 2005 22:35:50 GMT
From: Mike <mikee@mikee.ath.cx>
Subject: Re: pod documents and shells?
Message-Id: <anWHd.1086$CF.106@fe03.lga>

In article <lPUHd.1068$jr7.7@fe03.lga>, Mike wrote:
> Is there a way to document shells (sh, ksh, csh, etc.) using pod?

This is a 'duh' moment.

#!/bin/sh

cp this that

 ...

exit 0

=pod

=head1 NAME

someshell.sh

=cut


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

Date: 20 Jan 2005 08:43:56 -0800
From: ioneabu@yahoo.com
Subject: Re: Question? Alternative to loading modules!!!
Message-Id: <1106239436.455406.66470@f14g2000cwb.googlegroups.com>


ChicksHateMe wrote:
> I consider myself still a newbie so I am looking for help, not
flaming.
> Thanks in advance.
[...]
> 3 Is there an EASY way to convert a module to a simple include, or
will
> I OFTEN run into issues?? Things like assigned vars, etc??
>

Just went through the same problem recently.  Read about CPAN.pm at
cpan.org.

here is what I did:

http://groups-beta.google.com/group/comp.lang.perl.misc/browse_frm/thread/a5a407da6a24a76f/04b1ba9d56dd12cc?q=ioneabu@yahoo.com&_done=%2Fgroups%3Fq%3Dioneabu@yahoo.com%26start%3D0%26scoring%3Dd%26&_doneTitle=Back+to+Search&&d#04b1ba9d56dd12cc



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

Date: 20 Jan 2005 18:20:49 GMT
From: xhoster@gmail.com
Subject: Re: Question? Alternative to loading modules!!!
Message-Id: <20050120132049.424$8Y@newsreader.com>

"ChicksHateMe" <chicks_hate_me@hotmail.com> wrote:
> I consider myself still a newbie so I am looking for help, not flaming.
> Thanks in advance.
>
> I have written a few Perl programs, and I enjoy it. I like it more than
> doing stuff in PHP. I don't want to start the whole PHP - Perl thing,
> but I like the power and ease of Perl, and who's faster doesn't matter
> to me.
>
> The one thing I dislike is trying to deal with website/hosts and
> getting the modules installed that I need. It's a PITA.

Do you get command line access to the hosting service, or only
the ability to upload files to your cgi directories?

> I have Sometimes taken modules and just simplified them and used them
> as an "include" instead of loading them. For some simple ones this
> seems to work fine.

When possible, describe Perl things in Perl, not in English.  There are
many ways to "include" things, and we don't know which one you are using.

> 1. Where I am doing this for my own specific sites, what I am wondering
> is, if there are any issues I may run into?

Yes, but what they are depend on what you mean by "include".

> 2. Would installed modules run faster than using the modules as a
> simple include where possible and needed??

No.  Or at least not meaningfully faster.

> I've only used some simple modules so far this way, so I am wondering
> also;
>
> 3 Is there an EASY way to convert a module to a simple include, or will
> I OFTEN run into issues?? Things like assigned vars, etc??

It depends on what you mean by "a simple include".

If you just copy the code from the .pm and paste it into your own
code, then you don't need to invoke "use" on the module, but (I think) that
means that you will need to explicitly call "import" for the module if the
module needs things exported.

BTW, I've done "includes" this way in the past, and I don't recommend it.
Installing the modules locally is much better if you can do it.  If you
can't install them locally using CPAN and whatnot (because you don't have
CLI access), then you can still install them locally for pure perl modules
only by uploading the .pm file to the right directory and using -I in your
scripts.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 20 Jan 2005 13:13:52 -0800
From: "ChicksHateMe" <chicks_hate_me@hotmail.com>
Subject: Re: Question? Alternative to loading modules!!!
Message-Id: <1106255632.666329.259490@f14g2000cwb.googlegroups.com>

No, I'm not able to get to the shell, or a command prompt for my
server.  I would actually prefer to find another way that would be
simpler, and easier for installation on generic hosting services.

Thanks for the input and direction towards installing modules in my own
directories, That sounds like the way to go for me.

It's been a while since I did much programming, but I really like Perl,
and like what I've been able to do so far. So I am looking to learn
more. My goal is to build for myself, and possibly for others, a Basic
CMS framework that has just the basics, and loads easily on any web
server without the need to deal with addional module installation if
possible.

The Idea of loading them in a local filespace is what I need.
Thanks again for your time, answers and direction!



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

Date: Thu, 20 Jan 2005 22:29:29 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: Question? Alternative to loading modules!!!
Message-Id: <871xcfn3n8.fsf@mithril.chromatico.net>

>>>>> "CHM" == ChicksHateMe  <chicks_hate_me@hotmail.com> writes:

    CHM> I consider myself still a newbie so I am looking for help,
    CHM> not flaming.  Thanks in advance.

    CHM> The one thing I dislike is trying to deal with website/hosts
    CHM> and getting the modules installed that I need. It's a PITA.

perldoc -q 'my own module'

For that matter, you can get webspace with shell access in the
neighborhood of $30 a month.  If you are at all competent at a
programmer, that's what 20 minutes of your time costs.  In other
words, for every hour you spend working around stupid web hosts, you
could pay for three months of hosting at a competent web host.

Charlton



-- 
cwilbur at chromatico dot net
cwilbur at mac dot com


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

Date: Fri, 21 Jan 2005 16:14:27 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Question? Alternative to loading modules!!!
Message-Id: <DT9Id.135891$8l.129025@pd7tw1no>

In article <1106255632.666329.259490@f14g2000cwb.googlegroups.com>,
 "ChicksHateMe" <chicks_hate_me@hotmail.com> writes:
>No, I'm not able to get to the shell, or a command prompt for my
>server.  I would actually prefer to find another way that would be
>simpler, and easier for installation on generic hosting services.

It's easy to write a CGI that'll let you enter arbitrary shell
commands from a browser.  Just secure it so no one else can
use it :-)

Never done one that could deal with interactive programs, although
it doesn't sound hard if you know what the questions are going to
be.

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/


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

Date: Fri, 21 Jan 2005 10:56:02 +0800
From: "Edward Wijaya" <ewijaya@singnet.com.sg.removethis>
To: "Sherm Pendley" <spamtrap@dot-app.org>
Subject: Re: Radix Sort in CPAN
Message-Id: <opskxmfoaiavcff0@news.singnet.com.sg>

On Fri, 21 Jan 2005 07:26:24 -0500, Sherm Pendley <spamtrap@dot-app.org>  
wrote:

> Looking at the docs, I see "Edward Wijaya" listed as the implementor. If
> you're not lying about your name,

I did not lie about my name. What for?

> pimp your module. I see the copyright is 2005, so obviously it's new. Go  
> to the

My OP is not meant to "pimp" the module. It's a sincere question.
Don't jump into quick and negative conclusion if you are not sure, it's  
unfair.

I submitted the module since I didn't hear any feedback from it.

-- 
Regards,
Edward WIJAYA
SINGAPORE


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

Date: Fri, 21 Jan 2005 10:23:51 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Radix Sort in CPAN
Message-Id: <m4WdnZ5EFcEUg2zcRVn-vw@adelphia.com>

Edward Wijaya wrote:

> My OP is not meant to "pimp" the module.

Sorry for overreacting.

You should understand though - I saw a question asking whether a module
exists, and when I looked, I saw that not only did the module exist, the
question had been posted by the module's author. To a cynical old fart like
me, that looks like astroturfing.

> I submitted the module since I didn't hear any feedback from it.

You posted your question yesterday. I didn't even see it until this morning.
Usenet posts take time to propogate, and few people respond immediately. If
you wanted feedback, you should have been a bit more patient and given it a
few days.

Please don't get me wrong - My hat's off to you for contributing to CPAN.
I'm commenting on the announcement/question, not the module itself.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Fri, 21 Jan 2005 11:57:41 +0800
From: "Edward Wijaya" <ewijaya@singnet.com.sg.removethis>
Subject: Re: Radix Sort in CPAN
Message-Id: <opskxpaftvavcff0@news.singnet.com.sg>

On 21 Jan 2005 13:58:46 GMT, A. Sinan Unur <1usa@llenroc.ude.invalid>  
wrote:


Thanks so much for your notice, Sinan.

I really appreciate it. I have made the correction to the module under ver  
0.02.
Hope it works ;-)

-- 
Regards,
Edward WIJAYA
SINGAPORE


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

Date: Thu, 20 Jan 2005 11:30:09 -0600
From: Lars Eighner <eighner@io.com>
Subject: Re: regular expressions
Message-Id: <slrncuvqg9.1i6h.eighner@goodwill.io.com>

In our last episode, 
<358n9nF4jap49U1@individual.net>, 
the lovely and talented Sokar 
broadcast on comp.lang.perl.misc:

> hi,

> I have the string

> $variable = ",1,2,3,4,5";

> I was wondering if anyone knew a regular expression that would remove the
> first "," so that I would have

Yes, there are many, many ways of doing that as the first few
follow-ups have shown.  It is pointless to discuss regular
expressions in a specific case and you haven't described a
general case well enough.  Do you mean:

a) remove the first character in a string,
b) remove the first character in a string if it is a comma,
c) remove the first comma in a string (whether it precedes
another character or not),
d) remove the first comma in a string only if it precedes a
numeral,
e) some other possibile interpretations of your requirements I
haven't thought of.

and

Do you know the 1) the comma you want removed will always be
there or 2) the comma you want removed may or may not be there?

> $variable = "1,2,3,4,5"

> Thanks and regards

-- 
Lars Eighner              eighner@io.com           http://www.io.com/~eighner/
        Maintain thy airspeed, lest the ground rise up and smite thee.


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

Date: Fri, 21 Jan 2005 04:31:05 +0800
From: Dan Jacobson <jidanni@jidanni.org>
Subject: saying my $a=0; my $b=0; more compactly
Message-Id: <87oefjlu5y.fsf_-_@jidanni.org>

How does one write
my $a=0; my $b=0; my $c=0;
as compactly as possible (blanks OK)?
my ($a,$b,$c); $a=$b=$c=0;?
my ($a,$b,$c)=(0,0,0);?
But always I end up saying something over again.

Under use strict, I've got a lot of variables to declare and
initialize to zero, but all I can find are non streamlined ways of
doing it. Perhaps I should consider map()...


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

Date: 20 Jan 2005 22:49:59 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: saying my $a=0; my $b=0; more compactly
Message-Id: <Xns95E4B56EE9CE4asu1cornelledu@132.236.56.8>

Dan Jacobson <jidanni@jidanni.org> wrote in news:87oefjlu5y.fsf_-
_@jidanni.org:

> How does one write
> my $a=0; my $b=0; my $c=0;
> as compactly as possible (blanks OK)?
> my ($a,$b,$c); $a=$b=$c=0;?
> my ($a,$b,$c)=(0,0,0);?
> But always I end up saying something over again.
> 
> Under use strict, I've got a lot of variables to declare and
> initialize to zero, but all I can find are non streamlined ways of
> doing it. Perhaps I should consider map()...

use strict;
use warnings;

my ($a, $b, $c) = ( 0 ) x 3;

print "$a\t$b\t$c\n";
__END__

C:\Home\asu1> t
0       0       0

Sinan


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

Date: Fri, 21 Jan 2005 09:58:30 -0500
From: William Goedicke <goedicke@goedsole.com>
Subject: Re: saying my $a=0; my $b=0; more compactly
Message-Id: <m3pszy25ih.fsf@smtp.comcast.net>

Dear Dan - 

>>>>> "Dan" == Dan Jacobson <jidanni@jidanni.org> writes:

    Dan> How does one write my $a=0; my $b=0; my $c=0; as compactly as
    Dan> possible (blanks OK)?

I'm probably missing some potential gotcha' but, I've been successfully
using:

my( $a, $b, $c);

for years.  This is, of course, only good for initializing to null/0.
It's worthy of note that it handles arrays and hashes as well as
scalars.

I'd be very interested in hearing what bugs this technique exposes me
to.

     - Billy

============================================================
     William Goedicke     goedicke@goedsole.com            
     Cell 617-510-7244    http://www.goedsole.com:8080      
============================================================

          Lest we forget:

All big projects are completed through the execution of little
manageable steps.

		- William Goedicke


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

Date: 21 Jan 2005 16:15:47 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: saying my $a=0; my $b=0; more compactly
Message-Id: <yzd4qhalsnw.fsf@invalid.net>


William Goedicke <goedicke@goedsole.com> writes:
> >>>>> "Dan" == Dan Jacobson <jidanni@jidanni.org> writes:
> 
>     Dan> How does one write my $a=0; my $b=0; my $c=0; as compactly as
>     Dan> possible (blanks OK)?
> 
> I'm probably missing some potential gotcha' but, I've been successfully
> using:
> 
> my( $a, $b, $c);
> 
> for years.  This is, of course, only good for initializing to null/0.
> It's worthy of note that it handles arrays and hashes as well as
> scalars.

Initializing to 'undef', rather. "Null" does not have a specific meaning
in Perl, as far as I know (but I'm still fairly new in this group) (*);
and they are definitely not initialized to 0.

> I'd be very interested in hearing what bugs this technique exposes me
> to.

Probably few bugs by itself, but I suspect you do not use
        use warnings;
in your code, because if you do, then I would guess (though I may be
wrong) you get warnings for uninitialized variables here and there,
when they are used numerically.  And if you shut off warnings, you
miss a lot of warnings that really point to bugs.

This is the warning in question:
    (W) An undefined value was used as if it were already defined.  It was
    interpreted as a "" or a 0, but maybe it was a mistake.  To suppress this
    warning assign an initial value to your variables.

(*) Actually, a search through the documentations seems to indicate
that "null" mostly means "empty", and sometimes "empty string". It's
also used for Nul (ASCII code 0), which I think is wrong, but maybe
that usage is more confusing in the C world, where there are null pointers
too.


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

Date: 21 Jan 2005 15:20:33 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: saying my $a=0; my $b=0; more compactly
Message-Id: <Xns95E5693CBA241asu1cornelledu@132.236.56.8>

William Goedicke <goedicke@goedsole.com> wrote in 
news:m3pszy25ih.fsf@smtp.comcast.net:

> Dear Dan - 
> 
>>>>>> "Dan" == Dan Jacobson <jidanni@jidanni.org> writes:
> 
>     Dan> How does one write my $a=0; my $b=0; my $c=0; as compactly as
>     Dan> possible (blanks OK)?
> 
> I'm probably missing some potential gotcha' but, I've been successfully
> using:
> 
> my( $a, $b, $c);
> 
> for years.  This is, of course, only good for initializing to null/0.

That initializes the variables to undef, not 0 or any other value.

IMNSHO, it is rarely necessary to initialize a whole list of variables to 
the same value at the same time if one sticks with declaring variables at 
the point of first use.

Sinan,


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

Date: 20 Jan 2005 08:44:48 -0800
From: someone92@hotmail.com
Subject: Re: switching to extended character set using curses & perl
Message-Id: <1106239487.983568.40900@z14g2000cwz.googlegroups.com>

I'm sorry I think I ment alternate character set not extended character
set. I also tried to modify my /etc/termcap file for each terminals I
use(vt320 & xterm) by adding this in the corresponding sections:

:as=^N:ae=^O:aE=\E(B\E)0:ac=``aaffggjjkkllmmnnooppqqrr
ssttuuvvwwxxyyzz{{||}}~~..--++  ,,hhII00:

But still curses doesn't switch to alternate character set. Should I do
something special to update the /etc/termcap.db database ? if I use
"tset -S" I see that one of my terminal already have the as,ae,ac,aE
settings configured (vt320), my xterm (from putty) terminal's settings
are not updated when I change /etc/termcap

If someone has another solution than updating the termcap info and
still using curses that would be better since if I distribute the code
I don't want the users to have to mess with termcap.

Thanks



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

Date: 20 Jan 2005 12:12:23 -0800
From: someone92@hotmail.com
Subject: Re: switching to extended character set using curses & perl
Message-Id: <1106251943.281844.5200@z14g2000cwz.googlegroups.com>

I finally found a way to print an alternate character on screen with
perl & curses:

my $char=&Curses::ACS_LTEE;
$win->move($dy,$dx);
$win->hline($char,1);
But it's not very nice, I'm sure there's a better way to do this.



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

Date: Fri, 21 Jan 2005 17:26:16 +0100
From: Hendrik Maryns <hendrik_maryns@despammed.com>
Subject: Thanks! (was: does foreach (@list) alter @list??)
Message-Id: <V6adnYSAHaO7sGzcRVnysA@scarlet.biz>

A. Sinan Unur schreef:
> Hendrik Maryns <hendrik_maryns@despammed.com> wrote in
> news:maWdneQiKfU-tW3cRVnyjQ@scarlet.biz: 
> 
> 
>>use strict;
>>use warnings;
>>use diagnostics;
>>
>>my @dir= <*.pos>;     # feel free to change this for testing purposes
>>
>>for (@dir){
>>     open(my $in, '<', $_)||die($!);
>>          # do something
>>     close $in;
>>} #endfor
>>
>># @dir= <*.pos>;
>>
>>for (@dir){
>>     open(my $in, '<', $_ )||die($!);
>>          #do something else
>>     close $in;
>>} #endfor
>>
>>So my question is: how come?  Where does @dir get altered, or how come
>>$_ is undefined there.
>>
>>For "do something" you could for example use
>>
>>my $counter=0;
>>     while (<$in>){$counter++;
>>          print $counter, ' ';
> 
> 
> You might want to read perldoc perlsyn. Look for the section "Foreach 
> Loops".
> 
> When you have while(<$in>), $_ set to the line that was read from $in 
> each time. The loop terminates when no more lines can be read, and 
> hence, $_ is set to undef. Since $_ was an alias to an element of @dir, 
> that element is set to undef in return. 
> 
> The simple solution to this is to use an explicit lexically scoped loop 
> variable, as in 
> 
> for my $file (@dir) {
> 
> }
> 
> Sinan.

I understand now, thanks for pointing out!

Cheers, H.


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

Date: Fri, 21 Jan 2005 18:08:34 GMT
From: Rocco Caputo <troc@pobox.com>
Subject: Re: The world's shortest 'Hello World!' program: a proposal
Message-Id: <slrncv2hbj.1i76.troc@eyrie.homenet>

On Thu, 20 Jan 2005 23:09:39 -0500, Wes Groleau wrote:
> A. Sinan Unur wrote:
>> Wes Groleau <groleau+news@freeshell.org> wrote in
>>>
>>>Nothing in, nothing out.  Basic computer science.
>> 
>> Actually, that is "Garbage in, garbage out"

"What you C is what you get."

-- 
Rocco Caputo - http://poe.perl.org/


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

Date: Thu, 20 Jan 2005 19:42:21 +0000 (UTC)
From: Hue-Bond <responder_solo_en_el_grupo@yahoo.es>
Subject: Re: The world's shortest 'Hello World!' program: a proposal
Message-Id: <slrncv02ct.1u9.responder_solo_en_el_grupo@genus.hue-bond.com>

Arndt Jonasson, jue20050120@09:43:45(CET):
>
> arndt ~/perl 4011> perl -e ''
> arndt ~/perl 4012> 
>
> Empty in, empty out. (No, I didn't say "nothing".)

$ strace perl -e '' > strace1 2>&1
$ strace perl -e 'print "hello, world\n"' > strace2 2>&1
$ diff -u strace*

This shows that in the first case, nothing (apart from perl initialization
and so on) is executed, so no code -> no program.

I'm quitting this thread since IMO it's stupid to argue about whether an
empty string is a program.


-- 
 David Serrano


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

Date: Thu, 20 Jan 2005 20:56:32 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: The world's shortest 'Hello World!' program: a proposal
Message-Id: <pf10v0di1str7lalc4m83elhvm7i9ubsi6@4ax.com>

On Wed, 19 Jan 2005 21:31:09 +0000 (UTC), Hue-Bond
<responder_solo_en_el_grupo@yahoo.es> wrote:

>> _What_ is "0 bytes in length"? I can't see anything in your example!!
>
>Of course, it's 0 bytes ;^).

;-)

>> Note that the empty program _is_ a valid program, and it's also the
>> simples trie, in that it _does_ print itself, i.e. nothing.
>
>Hmm? How could an empty program *print* something? Even if that something is
>the empty string.

I think this may get more into phyolosophy than computer programming.
But _no_ output is the output of an "empty" print, thus the effects
are indistinguishable. Since we're talking about _output_ this point
of view seems sensible to me. If you want to take into account
"internal degrees of freedom", then yes: in one case you have a call
to print() and in one you don't. Does it matter?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 20 Jan 2005 21:55:35 -0000
From: "Leonard Challis" <perl@lennychallis.co.uk>
Subject: Re: The world's shortest 'Hello World!' program: a proposal
Message-Id: <csp9cn$lc8$1@newsg4.svr.pol.co.uk>

I think the _original_ point was that if you had "script.pl" and that 
contained _no_ data, instead of doing nothing, the Perl Interpreter cheekily 
outputted "Hello World!" or something.

Let us not argue! :D
Lenny 




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

Date: Thu, 20 Jan 2005 16:10:47 -0700
From: Eric Schwartz <emschwar@fc.hp.com>
Subject: Re: The world's shortest 'Hello World!' program: a proposal
Message-Id: <etoy8enbsso.fsf@wilson.emschwar>

"Leonard Challis" <perl@lennychallis.co.uk> writes:
> I think the _original_ point was that if you had "script.pl" and that 
> contained _no_ data, instead of doing nothing, the Perl Interpreter cheekily 
> outputted "Hello World!" or something.

Only, it doesn't.

emschwar@wilson:~$ touch script.pl
emschwar@wilson:~$ perl script.pl
emschwar@wilson:~$ 

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Thu, 20 Jan 2005 10:04:22 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Whats the variable holding the dir seperator?
Message-Id: <200120051004221434%jgibson@mail.arc.nasa.gov>

In article <slrncuvb2u.7uj.tadmc@magna.augustmail.com>, Tad McClellan
<tadmc@augustmail.com> wrote:

> ipellew@pipemedia.co.uk <ipellew@pipemedia.co.uk> wrote:
> 
> > Is there a variable that holds the dot character?
> 
> 
> No, but it is easy to create one:
> 
>    my $var = '.';


Tad:

You have ignored your own advice to use meaningful variable names:

> On Wed, 03 May 2000 16:29:27 GMT, bing...@tamu.edu <bing...@tamu.edu>
> wrote:
> 
> >I want to make an interactive perl to
> >prompt user questions for answers, such as:
> > what's your name: <user's input>
> >How should I refer those user's input in my script? 
> 
> With meaningful variable names.
> 
>    print q/what's your name: /;
>    chomp(my $name = <STDIN>);
> 
> -- 
>     Tad McClellan                          SGML Consulting
>     t...@metronet.com                     Perl programming
>     Fort Worth, Texas


Shouldn't that be

   $variable_that_holds_the_dot_character = '.';

:^)


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: 20 Jan 2005 08:13:20 -0800
From: ioneabu@yahoo.com
Subject: why not multiple statement modifiers?
Message-Id: <1106237599.971532.220620@z14g2000cwz.googlegroups.com>

Just curious, would it be possible for a future version of Perl to
support this sort of statement?

print for @a if $a;

or

print for @$_ if /^a/ while(<A>);

I imagine that a module could be written to do it:

multiples 'print for @a if $a'

where the multiples function would construct a function to execute the
statement properly.  The problem is that it already looks ugly and the
implementation would probably be very difficult.

Is there a logic problem with allowing more than one statement
modifier?

Thanks!

wana



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

Date: Thu, 20 Jan 2005 17:44:55 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: why not multiple statement modifiers?
Message-Id: <csoqcr$1hd$1@sun3.bham.ac.uk>



ioneabu@yahoo.com wrote:
> Just curious, would it be possible for a future version of Perl to
> support this sort of statement?
> 
> print for @a if $a;

No.

It has been decided and it ain't gonna change. Very many people 
(including myself) have said they want it but Larry Wall has put his 
foot down on this.

Some people 'round 'ere (notably Uri) here claim that there are real
technical reasons to be found in the p5p mailing list archives. I've
looked and I can't find them.

All I can find are:

   [1] Because you can't, so there!
   [2] Because you could abuse it to produce unreadable code
   [3] Because using for without an explicit loop variable is bad
   [4] For well known reasons I won't repeat

You'll note that [1] and [4] are no sort of explaintion. [2] applies
to pretty much everyting in Perl. [3] is an argument against the
"for" statement modifier per-se, not an argument against being able to
chain statement modifiers. Let's not rake over this again.

The above is taken form a previous thread:

http://groups-beta.google.com/group/comp.lang.perl.misc/msg/c87ec3bf248e75e3

KILL THIS THREAD NOW!

Do not contribute to this thread unless you have something _new_ to say.



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

Date: 20 Jan 2005 12:53:18 -0800
From: ioneabu@yahoo.com
Subject: Re: why not multiple statement modifiers?
Message-Id: <1106254398.851665.169300@f14g2000cwb.googlegroups.com>


Brian McCauley wrote:
> ioneabu@yahoo.com wrote:
> > Just curious, would it be possible for a future version of Perl to
> > support this sort of statement?
> >
> > print for @a if $a;
>
> No.
>
> It has been decided and it ain't gonna change. Very many people
> (including myself) have said they want it but Larry Wall has put his
> foot down on this.
>
> Some people 'round 'ere (notably Uri) here claim that there are real
> technical reasons to be found in the p5p mailing list archives. I've
> looked and I can't find them.

Thanks!  Sorry I didn't find the earlier post before asking.  I
personally think it might lead to a more natural flow of certain
statements.

How often have people had to change:

dosomething() if $true;

to

if ($true)
{
dosomething() for @list;
}

or something similar that could have been done in a single statement if
multiple modifiers were allowed.  I know it has happened to me a few
times.  Like the Switch module, it might be interesting if it could be
implemented as a module just to show it can be done and might benefit
some people.

wana



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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 7680
***************************************


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