Code Comments
Programming Forum and web based access to our favorite programming groups.normal array slice @array[0,1,23,100] what is this ? @array["hello1","hello2", ...];
Post Follow-up to this messageGeorge 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
Post Follow-up to this message"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
Post Follow-up to this messageI 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";
}
Post Follow-up to this messageI 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";
}
Post Follow-up to this message
"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
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.