Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

what is this ?
normal array slice
@array[0,1,23,100]

what is this ?
@array["hello1","hello2", ...];



Report this thread to moderator Post Follow-up to this message
Old Post
George Bouras
07-29-04 08:55 AM


Re: what is this ?
George Bouras wrote:

> normal array slice
> @array[0,1,23,100]
>
> what is this ?
> @array["hello1","hello2", ...];

Since "hello1" is zero when evaluated in numeric context, it is the same as
@array[0,0] which is ($array[0],$array[0]).

Now, if you were using braces {} instead of brackets [], the answer would
be different.
-Joe

Report this thread to moderator Post Follow-up to this message
Old Post
Joe Smith
07-29-04 08:55 AM


Re: what is this ?
"George Bouras" <gravitalsun.ANTISPAM@yahoo.com> wrote in message
news:ce50mn$2b2k$1@ulysses.noc.ntua.gr...
> normal array slice
> @array[0,1,23,100]
>
> what is this ?
> @array["hello1","hello2", ...];

you probably mean this:
@array{"hello1","hello2", ...};

in that case, it is a hash slice, equivalent to:
($array{'hello1'},$array{'hello2'},...);

gnari





Report this thread to moderator Post Follow-up to this message
Old Post
gnari
07-29-04 08:55 AM


Re: what is this ?
I read it at POE Perl module documentation.

sub handler_start
{
my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION];
...
}



I think it must be something similar to

use constant A=>1;
use constant B=>7;
use constant C=>9;

f1( qw/a b c d e f g h i j k l m n o p q/ );

sub f1
{
my ($a,$b,$c) = @_[A,B,C];
print "$a $b $c\n";
}






Report this thread to moderator Post Follow-up to this message
Old Post
George Bouras
07-29-04 08:55 AM


Re: what is this ?
I read it at POE samples and documentation.

sub handler_start
{
my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION];
...
}



I think it must be something similar to

use constant A=>1;
use constant B=>7;
use constant C=>9;

f1( qw/a b c d e f g h i j k l m n o p q/ );

sub f1
{
my ($a,$b,$c) = @_[A,B,C];
print "$a $b $c\n";
}





Report this thread to moderator Post Follow-up to this message
Old Post
George Bouras
07-29-04 08:55 AM


Re: what is this ?
"George Bouras" <gravitalsun.ANTISPAM@yahoo.com> wrote in message
news:ce56dv$2nft$1@ulysses.noc.ntua.gr...
> I read it at POE Perl module documentation.
>
> sub handler_start
> {
> my ($kernel, $heap, $session) = @_[KERNEL, HEAP, SESSION];
> ...
> }
>
>
>
> I think it must be something similar to
>
> use constant A=>1;
> use constant B=>7;
> use constant C=>9;
>
> f1( qw/a b c d e f g h i j k l m n o p q/ );
>
> sub f1
> {
> my ($a,$b,$c) = @_[A,B,C];
> print "$a $b $c\n";
> }
>

See POE::Session for more information. In essence you are correct about them
being constants:

Each session maintains its unique runtime context. Sessions pass their
contexts on to their states through a series of standard parameters. These
parameters tell each state about its Kernel, its Session, itself, and the
events that invoke it.

State parameters' offsets into @_ are never used directly. Instead they're
referenced by symbolic constant. This lets POE to change their order without
breaking programs, since the constants will always be correct.

Matt



Report this thread to moderator Post Follow-up to this message
Old Post
Matt Garrish
07-29-04 08:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:31 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.