[30557] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1800 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 17 18:09:43 2008

Date: Sun, 17 Aug 2008 15:09:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 17 Aug 2008     Volume: 11 Number: 1800

Today's topics:
    Re: array comparision <nnill@pp.info>
    Re: array comparision <rvtol+news@isolution.nl>
    Re: FAQ 4.75 How do I define methods for every class/ob <brian.d.foy@gmail.com>
    Re: FAQ 4.75 How do I define methods for every class/ob <ben@morrow.me.uk>
    Re: Help with Array Usage <siva0825@gmail.com>
        Help: Debug perl codes <openlinuxsource@gmail.com>
    Re: Help: Debug perl codes <jurgenex@hotmail.com>
    Re: Help: Debug perl codes <Peter@PSDT.com>
    Re: Help: Debug perl codes <jurgenex@hotmail.com>
    Re: Help: Debug perl codes <openlinuxsource@gmail.com>
    Re: Help: Debug perl codes <tadmc@seesig.invalid>
    Re: List Context in a Boolean Expression <mjcarman@mchsi.com>
    Re: The Importance of Terminology's Quality <m@rtij.nl.invlalid>
    Re: The Importance of Terminology's Quality <martin@see.sig.for.address.invalid>
    Re: This is very OT, and its just a request. It has to  <rvtol+news@isolution.nl>
    Re: Tone generation question plus Windows XP and Vista  <rvtol+news@isolution.nl>
    Re: Tone generation question plus Windows XP and Vista  <m@rtij.nl.invlalid>
    Re: Tone generation question plus Windows XP and Vista  <edgrsprj@ix.netcom.com>
    Re: Tone generation question plus Windows XP and Vista  <edgrsprj@ix.netcom.com>
    Re: Tone generation question plus Windows XP and Vista  <m@rtij.nl.invlalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 17 Aug 2008 00:36:45 -0700
From: Nonni Nil <nnill@pp.info>
Subject: Re: array comparision
Message-Id: <v7lfa450tcj54orvut4hb0cn1letf59vef@4ax.com>

On Fri, 15 Aug 2008 22:22:26 -0700 (PDT), Marek
<mstep@podiuminternational.org> wrote:

>
>
>
>my @array1 = split( /\t\s*/, $line1 );
did you mean my @array1 = split( /[\t\s]*/, $line1 );  ?
>my @array2 = split( /\t\s*/, $line2 );
same here?
>


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

Date: Sun, 17 Aug 2008 11:56:30 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: array comparision
Message-Id: <g893uk.1k8.1@news.isolution.nl>

Nonni Nil schreef:
> Marek:

>> my @array1 = split( /\t\s*/, $line1 );
>
> did you mean my @array1 = split( /[\t\s]*/, $line1 );  ?


Not very likely, because "[\t\s]" is equivalent to just "\s". You were
probably looking for "\s+", but you were losing that the TAB should be
at the start and that the full regex should match 1-or-more, not
0-or-more.

More likely, OP meant that the field separator is TAB, and the fields
have optional SPC's at the start.
So OP was probably looking for /\t */.

In two steps it is clearer:

   my @values = split /\t/, $line; # FS is TAB
   s/^ +// for @values;  # ltrim

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Sun, 17 Aug 2008 10:07:25 +0200
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 4.75 How do I define methods for every class/object?
Message-Id: <170820081007256682%brian.d.foy@gmail.com>

In article <bpbkn5-u341.ln1@osiris.mauzo.dyndns.org>, Ben Morrow
<ben@morrow.me.uk> wrote:

> Quoth PerlFAQ Server <brian@stonehenge.com>:
> > 
> > 4.75: How do I define methods for every class/object?
> > 
> >     Use the "UNIVERSAL" class (see UNIVERSAL).
> 
> Ouch! Should this *really* be recommended in the FAQ?

Do you have another answer for the question? As far as I know there
isn't another way to do it.


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

Date: Sun, 17 Aug 2008 21:28:07 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: FAQ 4.75 How do I define methods for every class/object?
Message-Id: <n7emn5-o52.ln1@osiris.mauzo.dyndns.org>


Quoth brian d  foy <brian.d.foy@gmail.com>:
> In article <bpbkn5-u341.ln1@osiris.mauzo.dyndns.org>, Ben Morrow
> <ben@morrow.me.uk> wrote:
> 
> > Quoth PerlFAQ Server <brian@stonehenge.com>:
> > > 
> > > 4.75: How do I define methods for every class/object?
> > > 
> > >     Use the "UNIVERSAL" class (see UNIVERSAL).
> > 
> > Ouch! Should this *really* be recommended in the FAQ?
> 
> Do you have another answer for the question? As far as I know there
> isn't another way to do it.

No, I don't; the answer is of course correct. However, something
like 

    Please be very careful to consider the consequences of doing this:
    adding methods to every object is very likely to have unintended
    consequences. If possible, it would be better to have all your
    object inherit from some common base class, or to use an object
    system like Moose that supports roles.

should be added, if the question is actually asked frequently enough
that the documentation in perlobj is deemed insufficient. I would have
thought that anyone who should be modifying UNIVERSAL would know enough
to find that on their own.

Ben

-- 
#!/bin/sh
quine="echo 'eval \$quine' >> \$0; echo quined"
eval $quine
#                                                        [ben@morrow.me.uk]


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

Date: Sun, 17 Aug 2008 04:31:27 -0700 (PDT)
From: "siva0825@gmail.com" <siva0825@gmail.com>
Subject: Re: Help with Array Usage
Message-Id: <ba6ff280-74d7-40a6-9bb8-32e657017f39@v57g2000hse.googlegroups.com>

On Aug 16, 5:23 pm, Deepu <pradeep...@gmail.com> wrote:
> Hi All,
>
> I need some help on how i can proceed for the question below.
>
> I have a file <test.txt> with the contents as below:
>
> test 1 1 0
> testa 1 1 0
> test 2 2 0
> test 1 2 0
> test 2 3 0
> testb 2 2 0
> testc 3 3 0
> test 2 4 0
> test 3 3 0
>
> Next i need to get the 'unique' numbers in the first column for the
> row which starts with 'test'.
>
> Next i need to overwrite the same file <test.txt> with the same
> contents as above and in addition i need to add a line like 'testfinal
> 1 0 0' for the unique numbers.
>
> Example Output file <test.txt>:
>
> test 1 1 0
> testa 1 1 0
> test 2 2 0
> test 1 2 0
> test 2 3 0
> testb 2 2 0
> testc 3 3 0
> test 2 4 0
> test 3 3 0
> <-- New lines below-->
> testfinal 1 0 0
> testfinal 2 0 0
> testfinal 3 0 0
>
> Thanks for the help.

open(I, "test.txt") or die "Can't open test.txt: $!";

open(O, "> testout.txt") or die "Can't open testout.txt for writing:
$!";

my %thash;

while (<I>) {
    print O;
    next if (! /^test\s+/);
    my @a = split;
    $thash{"$a[0]final $a[1] 0 0"} = $_;
}

print O "\n\n\n";

for my $key (sort keys %thash) {
    print O $key, "\n";
}

close(I); close(O);

rename("testout.txt", "test.txt") or die "Can't rename: $!";




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

Date: Sun, 17 Aug 2008 20:15:27 +0800
From: Amy Lee <openlinuxsource@gmail.com>
Subject: Help: Debug perl codes
Message-Id: <pan.2008.08.17.12.15.27.524076@gmail.com>

Hello,

Is there any way to debug perl codes like shell script with "sh -x"?

Thank you very much~

Best Regards,

Amy


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

Date: Sun, 17 Aug 2008 12:52:11 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Help: Debug perl codes
Message-Id: <ip7ga41nbluec37m3o8mnpp4vmj087c0am@4ax.com>

Amy Lee <openlinuxsource@gmail.com> wrote:
>Is there any way to debug perl codes like shell script with "sh -x"?

Is there anything wrong with the answer to 'perldoc -q debug':
	  How do I debug my Perl programs?

jue


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

Date: Sun, 17 Aug 2008 13:39:03 GMT
From: Peter Scott <Peter@PSDT.com>
Subject: Re: Help: Debug perl codes
Message-Id: <pan.2008.08.17.13.39.02.659095@PSDT.com>

On Sun, 17 Aug 2008 12:52:11 +0000, Jürgen Exner wrote:
> Amy Lee <openlinuxsource@gmail.com> wrote:
>>Is there any way to debug perl codes like shell script with "sh -x"?
> 
> Is there anything wrong with the answer to 'perldoc -q debug':
> 	  How do I debug my Perl programs?

Perhaps that it doesn't answer Amy's question?  She wants:

  Devel::Trace	Print out each line before it is executed (like sh -x) 

http://search.cpan.org/~mjd/Devel-Trace-0.10/

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



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

Date: Sun, 17 Aug 2008 14:06:56 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Help: Debug perl codes
Message-Id: <b4cga4lni8r307f5cfisovn4oie9mc4e6s@4ax.com>

Peter Scott <Peter@PSDT.com> wrote:
>On Sun, 17 Aug 2008 12:52:11 +0000, Jürgen Exner wrote:
>> Amy Lee <openlinuxsource@gmail.com> wrote:
>>>Is there any way to debug perl codes like shell script with "sh -x"?
>> 
>> Is there anything wrong with the answer to 'perldoc -q debug':
>> 	  How do I debug my Perl programs?
>
>Perhaps that it doesn't answer Amy's question?  She wants:

Fair enough. 

>  Devel::Trace	Print out each line before it is executed (like sh -x) 

Because 'sh' is not a Perl command if would have helped to explain what
it does, just like you did in just half a sentence.

jue


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

Date: Sun, 17 Aug 2008 23:36:27 +0800
From: Amy Lee <openlinuxsource@gmail.com>
Subject: Re: Help: Debug perl codes
Message-Id: <pan.2008.08.17.15.36.26.333532@gmail.com>

On Sun, 17 Aug 2008 13:39:03 +0000, Peter Scott wrote:

> On Sun, 17 Aug 2008 12:52:11 +0000, Jürgen Exner wrote:
>> Amy Lee <openlinuxsource@gmail.com> wrote:
>>>Is there any way to debug perl codes like shell script with "sh -x"?
>> 
>> Is there anything wrong with the answer to 'perldoc -q debug':
>> 	  How do I debug my Perl programs?
> 
> Perhaps that it doesn't answer Amy's question?  She wants:
> 
>   Devel::Trace	Print out each line before it is executed (like sh -x) 
> 
> http://search.cpan.org/~mjd/Devel-Trace-0.10/
Thanks. I need this module to debug a script. Thanks to Jue~

Amy


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

Date: Sun, 17 Aug 2008 07:55:38 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Help: Debug perl codes
Message-Id: <slrngag7ua.12a.tadmc@tadmc30.sbcglobal.net>

Amy Lee <openlinuxsource@gmail.com> wrote:


> Is there any way to debug perl codes like shell script with "sh -x"?


Please do not continue to use this newsgroup as a service
that reads the docs to you.

Make at least some small effort to answer your questions yourself
before resorting to asking here.

Have you seen the Posting Guidelines that are posted here frequently?


    perldoc -q debug

        How do I debug my Perl programs?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Sun, 17 Aug 2008 14:41:35 GMT
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: List Context in a Boolean Expression
Message-Id: <zMWpk.247146$TT4.111511@attbi_s22>

Jürgen Exner wrote:
> Michael Carman <mjcarman@mchsi.com> wrote:
>> That's the warning, but I don't think you quoted quite enough to
>> explain the behavior.
> 
> Well, no, of course I didn't. It was a teaser ...
> 
>> I had to look it up myself because it seemed odd to me
> 
> ... to have you do exactly that. After all, I assume you are old
> enough not to need someone to read the man pages to you.

I read this newsgroup for discussions about Perl, not to get homework
assignments. While I can RTFM I'd rather discuss the behavior,
particularly when that behavior is unintuitive.

Getting back on-topic...

It's obvious that the left operand must be evaluated in scalar context
because it's a boolean test. I would have expected the || operator to
impose scalar context on the right operand as well; that just seems like
the obvious thing to do. I find the (potential) propagation of list
context curious. Was it a deliberate design decision or just a side
effect? If it was deliberate then someone must have thought that it
might be useful. Has anyone ever found an application for this behavior?
 I'm having a hard time envisioning a situation where

  @foo = $bar || @baz;

is useful. Does anyone have an example?

-mjc


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

Date: Sun, 17 Aug 2008 11:31:11 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: The Importance of Terminology's Quality
Message-Id: <pan.2008.08.17.09.31.10@rtij.nl.invlalid>

On Sat, 16 Aug 2008 21:46:18 -0400, John W Kennedy wrote:

>> The 1401 was a decent enough processor for many industrial tasks -- at
>> that time -- but for general programming it was sheer horror.
> 
> But the easiest machine language /ever/.

True, very true.

M4


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

Date: Sun, 17 Aug 2008 10:38:43 +0000 (UTC)
From: Martin Gregorie <martin@see.sig.for.address.invalid>
Subject: Re: The Importance of Terminology's Quality
Message-Id: <g88v3j$jc8$3@localhost.localdomain>

On Sat, 16 Aug 2008 21:46:18 -0400, John W Kennedy wrote:

> Martijn Lievaart wrote:
>> On Thu, 14 Aug 2008 18:33:30 -0400, John W Kennedy wrote:
>> 
>>> Actually, I was thinking of the 1401. But both the 1620 and the 1401
>>> (without the optional Advanced Programming Feature) share the basic
>>> omission of any instruction that could do call-and-return without
>>> hard-coding an adcon with the address of the point to be returned to.
>>> (The Advanced Programming Feature added a 1401 instruction, Store
>>> B-address Register, that, executed as the first instruction of a
>>> subroutine, could store the return-to address.)
>> 
>> Raaaagh!!!!
>> 
>> Don't. Bring. Back. Those. Nightmares. Please.
>> 
>> The 1401 was a decent enough processor for many industrial tasks -- at
>> that time -- but for general programming it was sheer horror.
> 
> But the easiest machine language /ever/.

What? Even easier than ICL 1900 PLAN or MC68000 assembler? That would be 
difficult to achieve.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |


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

Date: Sun, 17 Aug 2008 12:09:10 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: This is very OT, and its just a request. It has to do with Ashton Tate Framework 2/PC World contest in the 1980's
Message-Id: <g894hh.1fg.1@news.isolution.nl>

sln@netherlands.com schreef:

> However, don't be fooled, my software depicts exactly in word and deed
> an art used today to a very fine detail. Specifically, Lotus Notes
> (the big guy).
>
> If you can find a genisis before my proof, then hey, tell me where...
> Hey, now you can say you know one of the pioneers of modern day
> technology.
> Who happens to own the technology copyright!

OT threads gets very boring after 2 or 3 messages. *PLONK*

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Sun, 17 Aug 2008 12:04:59 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Tone generation question plus Windows XP and Vista information
Message-Id: <g89482.1g0.1@news.isolution.nl>

E.D.G. schreef:

> Also, the Sound command documentation says to use the form
> Win32::Sound::Play("file.wav");
>
> I had to use Win32::Sound::Play('file.wav'); for it to work.

Looks like you are testing from the command line in a DOS box. There,
the local shell rules apply.

Putting your code in a whatever.pl file will make testing more
convenient, for example because you can have different windows for
editing and running.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Sun, 17 Aug 2008 12:14:50 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Tone generation question plus Windows XP and Vista information
Message-Id: <pan.2008.08.17.10.14.50@rtij.nl.invlalid>

On Sat, 16 Aug 2008 23:06:59 -0500, E.D.G. wrote:

> "E.D.G." <edgrsprj@ix.netcom.com> wrote in message
> news:IradnaMlysnVPTrVnZ2dnUVZ_qLinZ2d@earthlink.com...
>> Problem solved or at least identified.
>>
>>
> Also, the Sound command documentation says to use the form
> Win32::Sound::Play("file.wav");
> 
> I had to use Win32::Sound::Play('file.wav'); for it to work.

These are identical. If they give different results, which they actually 
don't, your Perl is really screwy, which it isn't.

HTH,
M4


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

Date: Sun, 17 Aug 2008 16:19:53 -0500
From: "E.D.G." <edgrsprj@ix.netcom.com>
Subject: Re: Tone generation question plus Windows XP and Vista information
Message-Id: <CaydnfTzQLdzCDXVnZ2dnUVZ_hCdnZ2d@earthlink.com>

"Martijn Lievaart" <m@rtij.nl.invlalid> wrote in message 
news:pan.2008.08.17.10.14.50@rtij.nl.invlalid...
>> I had to use Win32::Sound::Play('file.wav'); for it to work.
>
> These are identical. If they give different results, which they actually
> don't, your Perl is really screwy, which it isn't.
>

The double quote version caused Windows to generate an error message.  The 
single quote version worked.  Since you and the documentation both stated 
that it should work I will give it another try.  But I did originally enter 
the data multiple times and got the same result.



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

Date: Sun, 17 Aug 2008 16:25:28 -0500
From: "E.D.G." <edgrsprj@ix.netcom.com>
Subject: Re: Tone generation question plus Windows XP and Vista information
Message-Id: <tuedndLru7emCjXVnZ2dnUVZ_tPinZ2d@earthlink.com>

"Dr.Ruud" <rvtol+news@isolution.nl> wrote in message 
news:g89482.1g0.1@news.isolution.nl...
> Looks like you are testing from the command line in a DOS box. There,
> the local shell rules apply.
>
> Putting your code in a whatever.pl file will make testing more
> convenient, for example because you can have different windows for
> editing and running.

The code was actually stored at the beginning of my regular .pl program for 
testing purposes.  I will have to give it another try as I stated in another 
posting.  Perhaps part of the command that looked correct was actually 
entered wrong.




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

Date: Sun, 17 Aug 2008 23:55:55 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Tone generation question plus Windows XP and Vista information
Message-Id: <pan.2008.08.17.21.55.55@rtij.nl.invlalid>

On Sun, 17 Aug 2008 16:19:53 -0500, E.D.G. wrote:

> "Martijn Lievaart" <m@rtij.nl.invlalid> wrote in message
> news:pan.2008.08.17.10.14.50@rtij.nl.invlalid...
>>> I had to use Win32::Sound::Play('file.wav'); for it to work.
>>
>> These are identical. If they give different results, which they
>> actually don't, your Perl is really screwy, which it isn't.
>>
>>
> The double quote version caused Windows to generate an error message. 
> The single quote version worked.  Since you and the documentation both
> stated that it should work I will give it another try.  But I did
> originally enter the data multiple times and got the same result.

As another poster said, it may have been caused by entering stuff on the 
commandline. The Windows commandline is particularly screwy when it comes 
to quoting[1]. I would advice to only run scripts from files, or install 
cygwin (which I recommend anyhow).

M4

[1] The unix commandline is weird, but very consistent in a way that 
actually works once you learn it. The windows commandline is even 
weirder, not consistent and some things are plain impossible.


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

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 V11 Issue 1800
***************************************


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