Re: Passing "class" objects to a function

2008-10-01 Thread Dr.Ruud
"Mr. Shawn H. Corey" schreef: > Inside a sub, shift without a parameter will shift @_. Outside a sub, > it will shift @ARGV. Since it does two different things in different > context, always give it a parameter. Things that do different things > should look different. I hardly ever use "shift"

Re: Passing "class" objects to a function

2008-10-01 Thread James Coupe
In message <[EMAIL PROTECTED]>, Rob Dixon <[EMAIL PROTECTED]> writes: >Mr. Shawn H. Corey wrote: >> "Real Perl Programmers prefer things to be visually distinct." >> Larry Wall >> >> I wasn't the first to have the idea. > >I can't find anywhere where that is quoted in context. Not quite that, bu

Re: Passing "class" objects to a function

2008-10-01 Thread Jeff Pang
> Message du 01/10/08 13:08 > De : "Mr. Shawn H. Corey" > A : "Jeff Pang" > Copie à : "Rob Dixon" , "Perl Beginners" > Objet : Re: Passing "class" objects to a function > > > On Wed, 2008-10-01 at 05:04 +0200, Jeff Pan

Re: Passing "class" objects to a function

2008-10-01 Thread Mr. Shawn H. Corey
On Wed, 2008-10-01 at 05:04 +0200, Jeff Pang wrote: > For an experienced *Perl* programmer, using shift rather than shift @_ > is more comfortable and natural. You have just proven my point. You have overlooked the fact the outside a sub, shift without a parameter will shift @ARGV, not @_. Even

Re: Passing "class" objects to a function

2008-09-30 Thread Jeff Pang
> Message du 01/10/08 02:54 > De : "Rob Dixon" > A : "Perl Beginners" > Copie à : "Mr. Shawn H. Corey" > Objet : Re: Passing "class" objects to a function > > > Mr. Shawn H. Corey wrote: > > On Tue, 2008-09-30 at 22:5

Re: I would like to have an argument (WAS: Passing "class" objects to a function)

2008-09-30 Thread Raymond Wan
Mr. Shawn H. Corey wrote: On Wed, 2008-10-01 at 10:40 +0900, Raymond Wan wrote: I don't think Shawn is fighting a losing battle...at least I agree with him...maybe I'm on the "losing side". :-) I know I'm fighting a losing battle. Computers hate me; I know this. And someday they're g

Re: I would like to have an argument (WAS: Passing "class" objects to a function)

2008-09-30 Thread Mr. Shawn H. Corey
On Wed, 2008-10-01 at 10:40 +0900, Raymond Wan wrote: > I don't think Shawn is fighting a losing battle...at least I agree > with him...maybe I'm on the "losing side". :-) I know I'm fighting a losing battle. Computers hate me; I know this. And someday they're going to do me in. ;) -- Just

Re: Passing "class" objects to a function

2008-09-30 Thread Raymond Wan
Hi all, Paul Johnson wrote: On Tue, Sep 30, 2008 at 11:40:21AM -0400, Mr. Shawn H. Corey wrote: No. Inside a sub, shift without a parameter will shift @_. Outside a sub, it will shift @ARGV. Since it does two different things in different context, always give it a parameter. Things th

Re: I would like to have an argument, please (WAS: Passing "class" objects to a function)

2008-09-30 Thread Mr. Shawn H. Corey
On Wed, 2008-10-01 at 01:53 +0100, Rob Dixon wrote: > Mr. Shawn H. Corey wrote: > > On Tue, 2008-09-30 at 22:55 +0200, Paul Johnson wrote: > >>> > >>> Inside a sub, shift without a parameter will shift @_. Outside a sub, > >>> it will shift @ARGV. Since it does two different things in different >

Re: Passing "class" objects to a function

2008-09-30 Thread Rob Dixon
Mr. Shawn H. Corey wrote: > On Tue, 2008-09-30 at 22:55 +0200, Paul Johnson wrote: >>> >>> Inside a sub, shift without a parameter will shift @_. Outside a sub, >>> it will shift @ARGV. Since it does two different things in different >>> context, always give it a parameter. Things that do differ

Re: Passing "class" objects to a function

2008-09-30 Thread Mr. Shawn H. Corey
On Tue, 2008-09-30 at 22:55 +0200, Paul Johnson wrote: > > Inside a sub, shift without a parameter will shift @_. Outside a sub, > > it will shift @ARGV. Since it does two different things in different > > context, always give it a parameter. Things that do different things > > should look diffe

Re: Passing "class" objects to a function

2008-09-30 Thread Paul Johnson
On Tue, Sep 30, 2008 at 11:40:21AM -0400, Mr. Shawn H. Corey wrote: > On Tue, 2008-09-30 at 23:17 +0800, Sandy lone wrote: > > 2008/9/30 Vyacheslav Karamov <[EMAIL PROTECTED]>: > > > > > sub SomeFunc > > > { > > > my $node = shift @_; > > > > or: > > my $node = shift;# shift get @_ as the d

Re: Passing "class" objects to a function

2008-09-30 Thread Mr. Shawn H. Corey
On Tue, 2008-09-30 at 23:17 +0800, Sandy lone wrote: > 2008/9/30 Vyacheslav Karamov <[EMAIL PROTECTED]>: > > > > > > I've made a mistake. Correct code: > > > > sub SomeFunc > > { > > my $node = shift @_; > > > or: > my $node = shift;# shift get @_ as the default arguments No. Inside a s

Re: Passing "class" objects to a function

2008-09-30 Thread Sandy lone
2008/9/30 Vyacheslav Karamov <[EMAIL PROTECTED]>: > > I've made a mistake. Correct code: > > sub SomeFunc > { > my $node = shift @_; or: my $node = shift;# shift get @_ as the default arguments my ($node) = @_; # in list context, $node will get the first element of @_ -- Sandy -- To

Re: Passing "class" objects to a function

2008-09-30 Thread Vyacheslav Karamov
Mr. Shawn H. Corey пишет: On Tue, 2008-09-30 at 17:30 +0300, Vyacheslav Karamov wrote: Hi All! I need to pass object to a function. How can I do it? How to make this code work? use Tree::Simple; sub SomeFunc { my $node = @_; foreach my $child ($node->getAllChildren() ) {

Re: Passing "class" objects to a function

2008-09-30 Thread Mr. Shawn H. Corey
On Tue, 2008-09-30 at 17:30 +0300, Vyacheslav Karamov wrote: > Hi All! > > I need to pass object to a function. How can I do it? > > How to make this code work? > > use Tree::Simple; > > > sub SomeFunc > { > my $node = @_; > foreach my $child ($node->getAllChildren() ) > { >

Passing "class" objects to a function

2008-09-30 Thread Vyacheslav Karamov
Hi All! I need to pass object to a function. How can I do it? How to make this code work? use Tree::Simple; sub SomeFunc { my $node = @_; foreach my $child ($node->getAllChildren() ) { ... } } my $tree = Tree::Simple->new("tree", Tree::Simple->ROOT); SomeFunc( $tree ); -