[31530] in Perl-Users-Digest
Perl-Users Digest, Issue: 2789 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 26 00:09:25 2010
Date: Mon, 25 Jan 2010 21:09:10 -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 Mon, 25 Jan 2010 Volume: 11 Number: 2789
Today's topics:
How to print each line as a perl script executes? <pengyu.ut@gmail.com>
Re: How to print each line as a perl script executes? <jurgenex@hotmail.com>
Re: How to print each line as a perl script executes? <pengyu.ut@gmail.com>
Re: How to print each line as a perl script executes? <ben@morrow.me.uk>
Re: How to print each line as a perl script executes? <ben@morrow.me.uk>
Re: How to print each line as a perl script executes? <jurgenex@hotmail.com>
Re: How to print each line as a perl script executes? <uri@StemSystems.com>
Re: How to print each line as a perl script executes? <jurgenex@hotmail.com>
Re: How to print each line as a perl script executes? <john@castleamber.com>
Re: How to print each line as a perl script executes? <derykus@gmail.com>
Re: print array with separator? <tadmc@seesig.invalid>
Re: print array with separator? <ben@morrow.me.uk>
Re: print array with separator? <bmb@mail.libs.uga.edu>
Re: print array with separator? <john@castleamber.com>
Re: print array with separator? <uri@StemSystems.com>
Re: What are the minimum and maximum float numbers and <bmb@mail.libs.uga.edu>
Re: What are the minimum and maximum float numbers and <sreservoir@gmail.com>
When to use "use strict;"? <pengyu.ut@gmail.com>
Re: When to use "use strict;"? <jurgenex@hotmail.com>
Re: When to use "use strict;"? <anfi@onet.eu>
Re: When to use "use strict;"? <ben@morrow.me.uk>
Re: When to use "use strict;"? <bmb@mail.libs.uga.edu>
Re: When to use "use strict;"? <sreservoir@gmail.com>
Re: When to use "use strict;"? <tadmc@seesig.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 25 Jan 2010 15:47:32 -0800 (PST)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: How to print each line as a perl script executes?
Message-Id: <328bdba9-9ff5-4c22-8884-e72ff057b967@m16g2000yqc.googlegroups.com>
Is there a way to print the corresponding line in the perl script as
the script executes?
------------------------------
Date: Mon, 25 Jan 2010 15:58:58 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: How to print each line as a perl script executes?
Message-Id: <m1csl51rsfsc5s8nj3bf9hcb1ibat3cgul@4ax.com>
Peng Yu <pengyu.ut@gmail.com> wrote:
>Is there a way to print the corresponding line in the perl script as
>the script executes?
perldoc debug
jue
------------------------------
Date: Mon, 25 Jan 2010 16:12:41 -0800 (PST)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: Re: How to print each line as a perl script executes?
Message-Id: <58e4757e-56a4-4bcd-8fda-2be3cc475db3@u41g2000yqe.googlegroups.com>
On Jan 26, 5:58=A0pm, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> Peng Yu <pengyu...@gmail.com> wrote:
> >Is there a way to print the corresponding line in the perl script as
> >the script executes?
>
> perldoc debug
I don't find which option I should use. Would you please be a little
bit specific?
------------------------------
Date: Tue, 26 Jan 2010 00:17:44 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How to print each line as a perl script executes?
Message-Id: <8uo137-a48.ln1@osiris.mauzo.dyndns.org>
Quoth Jürgen Exner <jurgenex@hotmail.com>:
> Peng Yu <pengyu.ut@gmail.com> wrote:
> >Is there a way to print the corresponding line in the perl script as
> >the script executes?
>
> perldoc debug
ITYM perldoc perldebug.
Ben
------------------------------
Date: Tue, 26 Jan 2010 00:23:11 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How to print each line as a perl script executes?
Message-Id: <f8p137-a48.ln1@osiris.mauzo.dyndns.org>
Quoth Peng Yu <pengyu.ut@gmail.com>:
> On Jan 26, 5:58 pm, Jürgen Exner <jurge...@hotmail.com> wrote:
> > Peng Yu <pengyu...@gmail.com> wrote:
> > >Is there a way to print the corresponding line in the perl script as
> > >the script executes?
> >
> > perldoc debug
>
> I don't find which option I should use. Would you please be a little
> bit specific?
You want
PERLDB_OPTS="NonStop AutoTrace" perl -d ...
(suitably adjusted for your shell, of course).
Ben
------------------------------
Date: Mon, 25 Jan 2010 17:48:14 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: How to print each line as a perl script executes?
Message-Id: <hdisl5596n6n0u8ajb5hovs56h42fp0jh8@4ax.com>
Ben Morrow <ben@morrow.me.uk> wrote:
>
>Quoth J?Exner <jurgenex@hotmail.com>:
>> Peng Yu <pengyu.ut@gmail.com> wrote:
>> >Is there a way to print the corresponding line in the perl script as
>> >the script executes?
>>
>> perldoc debug
>
>ITYM perldoc perldebug.
Interestingly enough "perldoc debug" launches the same man page.
jue
------------------------------
Date: Mon, 25 Jan 2010 20:58:13 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: How to print each line as a perl script executes?
Message-Id: <874om9ocei.fsf@quad.sysarch.com>
>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:
JE> Ben Morrow <ben@morrow.me.uk> wrote:
>>
>> Quoth J?Exner <jurgenex@hotmail.com>:
>>> Peng Yu <pengyu.ut@gmail.com> wrote:
>>> >Is there a way to print the corresponding line in the perl script as
>>> >the script executes?
>>>
>>> perldoc debug
>>
>> ITYM perldoc perldebug.
JE> Interestingly enough "perldoc debug" launches the same man page.
perldoc debug
No documentation found for "debug".
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Mon, 25 Jan 2010 19:01:03 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: How to print each line as a perl script executes?
Message-Id: <sjmsl59q6oii1ib5frirvegfrgvuc0hl3q@4ax.com>
"Uri Guttman" <uri@StemSystems.com> wrote:
>>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:
> JE> Ben Morrow <ben@morrow.me.uk> wrote:
> >> ITYM perldoc perldebug.
>
> JE> Interestingly enough "perldoc debug" launches the same man page.
>
>perldoc debug
>No documentation found for "debug".
Hmmmmm, as I said, works just fine here:
C:\Users\jue>perldoc debug
NAME
perldebug - Perl debugging
[....]
C:\Users\jue>perl -v
This is perl, v5.10.1 built for MSWin32-x64-multi-thread
(with 2 registered patches, see perl -V for more detail)
Copyright 1987-2009, Larry Wall
Binary build 1006 [291086] provided by ActiveState
http://www.ActiveState.com
Built Aug 24 2009 13:45:20
jue
------------------------------
Date: Mon, 25 Jan 2010 21:16:17 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: How to print each line as a perl script executes?
Message-Id: <87d40xk132.fsf@castleamber.com>
Jürgen Exner <jurgenex@hotmail.com> writes:
> "Uri Guttman" <uri@StemSystems.com> wrote:
>>>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:
>> JE> Ben Morrow <ben@morrow.me.uk> wrote:
>> >> ITYM perldoc perldebug.
>>
>> JE> Interestingly enough "perldoc debug" launches the same man page.
>>
>>perldoc debug
>>No documentation found for "debug".
>
> Hmmmmm, as I said, works just fine here:
>
> C:\Users\jue>perldoc debug
> NAME
> perldebug - Perl debugging
> [....]
C:\Documents and Settings\John>perldoc debug
NAME
perldebug - Perl debugging
DESCRIPTION
First of all, have you tried using the -w switch?
:
C:\Documents and Settings\John>perl -v
This is perl, v5.10.1 built for MSWin32-x86-multi-thread
(with 2 registered patches, see perl -V for more detail)
Copyright 1987-2009, Larry Wall
Binary build 1006 [291086] provided by ActiveState http://www.ActiveState.com
Built Aug 24 2009 13:48:26
:
Windows XP + SP3
However, on Ubuntu 8.10:
No documentation found for "debug".
perl -v
This is perl, v5.10.0 built for x86_64-linux-gnu-thread-multi
So, "blame" ActiveState I guess?
--
John Bokma j3b
Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
------------------------------
Date: Mon, 25 Jan 2010 19:45:42 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: How to print each line as a perl script executes?
Message-Id: <2878dd34-8888-45d3-9ee2-df3d1a16de5d@b10g2000yqa.googlegroups.com>
On Jan 25, 5:58=A0pm, "Uri Guttman" <u...@StemSystems.com> wrote:
> >>>>> "JE" =3D=3D J rgen Exner <jurge...@hotmail.com> writes:
>
> =A0 JE> Ben Morrow <b...@morrow.me.uk> wrote:
> =A0 >>
> =A0 >> Quoth J?Exner <jurge...@hotmail.com>:
> =A0 >>> Peng Yu <pengyu...@gmail.com> wrote:
> =A0 >>> >Is there a way to print the corresponding line in the perl scrip=
t as
> =A0 >>> >the script executes?
> =A0 >>>
> =A0 >>> perldoc debug
> =A0 >>
> =A0 >> ITYM perldoc perldebug.
>
> =A0 JE> Interestingly enough "perldoc debug" launches the same man page.
>
> perldoc debug
> No documentation found for "debug".
>
>
I notice both Strawberry and ActiveState 5.10.1 perldoc's
(v3.15) -- I don't have a 5.10.1 Unix system handy --
apparently apply FWIM (find what I mean) and prepend
'perl' during the search:
c:\strawberry\perl\lib\pods>perldoc -D debug
...
Searching for debug
Looking for debug in C:\Perl\bin C:/Perl/site/lib C:/Perl/lib . C:\Perl
\site\bin ...
Looking for perldebug in C:\Perl\bin C:/Perl/site/lib C:/Perl/lib .
Loosely found as C:\Perl\lib\pods\perldebug.pod
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--
Charles DeRykus
------------------------------
Date: Mon, 25 Jan 2010 17:10:24 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: print array with separator?
Message-Id: <slrnhls90g.5ul.tadmc@tadbox.sbcglobal.net>
Peng Yu <pengyu.ut@gmail.com> wrote:
> @array=("a", "b", "c");
You should always enable strictures in your Perl programs:
use strict;
then make that
my @array=("a", "b", "c");
> print "@array\n";
>
> The above code will not print a separator (say a newline) between the
> elements.
print join("\n", @array), "\n";
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
------------------------------
Date: Mon, 25 Jan 2010 23:11:53 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: print array with separator?
Message-Id: <p2l137-kt7.ln1@osiris.mauzo.dyndns.org>
Quoth Peng Yu <pengyu.ut@gmail.com>:
> @array=("a", "b", "c");
> print "@array\n";
>
> The above code will not print a separator (say a newline) between the
> elements. I could use a foreach loop to do so. But I feel that there
> might be a more convenient way. Could somebody let me know if there is
> one?
See $" in perlvar, and remember to restrict the scope of any changes
with local.
Ben
------------------------------
Date: Mon, 25 Jan 2010 20:36:22 -0500
From: Brad Baxter <bmb@mail.libs.uga.edu>
Subject: Re: print array with separator?
Message-Id: <hjlguk$1tcn$1@news.telesweet.net>
On 1/25/2010 5:25 PM, Peng Yu wrote:
> @array=("a", "b", "c");
> print "@array\n";
>
> The above code will not print a separator (say a newline) between the
> elements. I could use a foreach loop to do so. But I feel that there
> might be a more convenient way. Could somebody let me know if there is
> one?
>
> foreach (@array) {
> print;
> print "\n";
> }
The above code positively does printer a separator (a space)
between the elements. Change $" to the separator you want.
use warnings;
use strict;
my @array=("a", "b", "c");
print "@array\n";
$" = "\n";
print "@array\n";
--
Brad
------------------------------
Date: Mon, 25 Jan 2010 20:37:55 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: print array with separator?
Message-Id: <87hbq9k2v0.fsf@castleamber.com>
"John W. Krahn" <someone@example.com> writes:
> John Bokma wrote:
>>
>> and one I which I don't like much:
>>
>> map { print "$_\n" } @array;
>
> Because it *should* be:
>
> print map "$_\n", @array;
Duh, that one is nearly the same as the first one I listed under "other
options" ;-)
As for *should*, I don't like map in void context but that's nowadays
more a matter of taste than anything else as far as I know.
I wouldn't use it though, but like Abigail, IIRC, once wrote, there is
no reason to have a problem with map in void context because we use
other functions in void context without problems (like print).
--
John Bokma j3b
Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
------------------------------
Date: Mon, 25 Jan 2010 23:23:44 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: print array with separator?
Message-Id: <87wrz5mr3j.fsf@quad.sysarch.com>
>>>>> "JB" == John Bokma <john@castleamber.com> writes:
JB> I wouldn't use it though, but like Abigail, IIRC, once wrote, there is
JB> no reason to have a problem with map in void context because we use
JB> other functions in void context without problems (like print).
the point with map in void context is not efficiency but in conveying
meaning to the reader. map is intended to generate a list, not execute
side effects. for modifier does the same thing and is meant for side
effects as it doesn't generate a list. perl has many related things like
this and you should choose the one with better semantics for your
intentions. map generates lists so use it that way. for modifier doesn't
generate lists so use it for side effects.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Mon, 25 Jan 2010 20:53:26 -0500
From: Brad Baxter <bmb@mail.libs.uga.edu>
Subject: Re: What are the minimum and maximum float numbers and integers?
Message-Id: <hjlhul$1ueu$1@news.telesweet.net>
On 1/25/2010 4:19 PM, Peng Yu wrote:
> Is there a way to get the minimum and maximum float numbers and
> integers?
use warnings;
use strict;
sub min { $_[$_[0]>$_[1]] }
sub max { $_[$_[0]<$_[1]] }
my @a = ( 1, 2, 3 );
my( $max, $min ) = ($a[0])x2;
for( 1 .. $#a ) {
$max = max( $max, $a[$_] );
$min = min( $min, $a[$_] );
}
print "Max is: $max\n";
print "Min is: $min\n";
But you probably meant something else. :-)
--
Brad
------------------------------
Date: Mon, 25 Jan 2010 21:01:15 -0500
From: sreservoir <sreservoir@gmail.com>
Subject: Re: What are the minimum and maximum float numbers and integers?
Message-Id: <hjlidm$j7f$2@speranza.aioe.org>
On 1/25/2010 4:19 PM, Peng Yu wrote:
> Is there a way to get the minimum and maximum float numbers and
> integers?
you mean epsilon and, iirc, omega?
--
"Six by nine. Forty two."
"That's it. That's all there is."
"I always thought something was fundamentally wrong with the universe"
------------------------------
Date: Mon, 25 Jan 2010 15:34:46 -0800 (PST)
From: Peng Yu <pengyu.ut@gmail.com>
Subject: When to use "use strict;"?
Message-Id: <c17204f2-3ac8-4dca-a8b4-c4e9e45ee48a@a5g2000yqi.googlegroups.com>
I was told to always use "use strict;" in another thread in this
newsgroup. However, I checked Programming Perl. It seems that "use
strict" is not necessary for small program.
In my case, each my perl script is less than 100 lines and would be
reused anywhere else. Do I still need to add "use strict" to my perl
program?
------------------------------
Date: Mon, 25 Jan 2010 15:50:29 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: When to use "use strict;"?
Message-Id: <u0bsl5ds2c3olktj2qasfnkhp4s645q09s@4ax.com>
Peng Yu <pengyu.ut@gmail.com> wrote:
>I was told to always use "use strict;" in another thread in this
>newsgroup. However, I checked Programming Perl. It seems that "use
>strict" is not necessary for small program.
Please define "necessary". The Perl interpreter doesn't care, in so
fartechnically strict is never necessary. Is it a pretty stupid idea not
to use it? You bet!
>In my case, each my perl script is less than 100 lines and would be
>reused anywhere else. Do I still need to add "use strict" to my perl
>program?
Will you be send to jail if you don't? No.
Will you be criticized when posting snippets of that code and asking for
evaluation? Very likely yes.
Will strict() help you catch and identify stupid programming errors like
typos in variable names? Very likely yes.
Ultimately it is up to you if you want to use the assistance that is
available to you or if you are a hardcore I-don't-need-no-f****-help guy
and prefer to make your coding more difficult than necessary.
Most people prefer to leverage all the help they can get and make their
life easier.
jue
------------------------------
Date: Tue, 26 Jan 2010 00:52:22 +0100
From: Andrzej Adam Filip <anfi@onet.eu>
Subject: Re: When to use "use strict;"?
Message-Id: <5abdmcn4bj-A1P@esther.brudna.chmurka.net>
Peng Yu <pengyu.ut@gmail.com> wrote:
> I was told to always use "use strict;" in another thread in this
> newsgroup. However, I checked Programming Perl. It seems that "use
> strict" is not necessary for small program.
>
> In my case, each my perl script is less than 100 lines and would be
> reused anywhere else. Do I still need to add "use strict" to my perl
> program?
"use strict;" helps to detect a lot of "typing mistakes".
You do not need it if you never do such mistakes :-)
P.S.
There are some "tricks" disabled by "use strict;".
Do you use them? No => use "use strict;"
--
[pl>en Andrew] Andrzej Adam Filip : anfi@onet.eu : Andrzej.Filip@gmail.com
"Rembrandt's first name was Beauregard, which is why he never used it."
-- Dave Barry
------------------------------
Date: Tue, 26 Jan 2010 00:16:39 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: When to use "use strict;"?
Message-Id: <7so137-a48.ln1@osiris.mauzo.dyndns.org>
Quoth Peng Yu <pengyu.ut@gmail.com>:
> I was told to always use "use strict;" in another thread in this
> newsgroup. However, I checked Programming Perl. It seems that "use
> strict" is not necessary for small program.
>
> In my case, each my perl script is less than 100 lines and would be
> reused anywhere else. Do I still need to add "use strict" to my perl
> program?
I use strict in every program longer than a one-liner, and my one-liners
are generally strict-clean (mostly out of habit).
Ben
------------------------------
Date: Mon, 25 Jan 2010 20:33:10 -0500
From: Brad Baxter <bmb@mail.libs.uga.edu>
Subject: Re: When to use "use strict;"?
Message-Id: <hjlgol$1t36$1@news.telesweet.net>
On 1/25/2010 6:34 PM, Peng Yu wrote:
> I was told to always use "use strict;" in another thread in this
> newsgroup. However, I checked Programming Perl. It seems that "use
> strict" is not necessary for small program.
>
> In my case, each my perl script is less than 100 lines and would be
> reused anywhere else. Do I still need to add "use strict" to my perl
> program?
It doesn't hurt. Always use strict (I do). Well, except
for one-liners (most of the time).
perl -Mstrict -lwe'print "Just another Perl Hacker"'
--
Brad
------------------------------
Date: Mon, 25 Jan 2010 20:59:36 -0500
From: sreservoir <sreservoir@gmail.com>
Subject: Re: When to use "use strict;"?
Message-Id: <hjliaj$j7f$1@speranza.aioe.org>
On 1/25/2010 6:52 PM, Andrzej Adam Filip wrote:
> Peng Yu<pengyu.ut@gmail.com> wrote:
>> I was told to always use "use strict;" in another thread in this
>> newsgroup. However, I checked Programming Perl. It seems that "use
>> strict" is not necessary for small program.
>>
>> In my case, each my perl script is less than 100 lines and would be
>> reused anywhere else. Do I still need to add "use strict" to my perl
>> program?
>
> "use strict;" helps to detect a lot of "typing mistakes".
> You do not need it if you never do such mistakes :-)
>
> P.S.
> There are some "tricks" disabled by "use strict;".
> Do you use them? No => use "use strict;"
{ no strict qw(what you want); tricks }
--
"Six by nine. Forty two."
"That's it. That's all there is."
"I always thought something was fundamentally wrong with the universe"
------------------------------
Date: Mon, 25 Jan 2010 21:32:05 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: When to use "use strict;"?
Message-Id: <slrnhlsob5.6a7.tadmc@tadbox.sbcglobal.net>
Peng Yu <pengyu.ut@gmail.com> wrote:
> I was told to always use "use strict;" in another thread in this
> newsgroup. However, I checked Programming Perl. It seems that "use
> strict" is not necessary for small program.
But "Feature Creep" often turns small programs into large programs.
http://en.wikipedia.org/wiki/Feature_creep
Retrofitting strictures in a large program can be a pain.
Observing strictures right from the start is easy.
I've been programming in Perl for quite a while, and I am convinced
that enabling strictures is the most efficient use of my time.
If you'd rather spend second, minutes or hours MANually troubleshooting
your program rather than have a machine find the problem in a few
milliseconds, then feel free to leave strictures off.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 2789
***************************************