Hmmm. Didn't think about that.  That would be a nice way, that way you can
manipulate it's behaviour depending with how many aliases you provide.  

for my $el1, $el2 ( (@foo, @bar) ) {
    print "$el\n"
 }

$el1 and $el2 would of course be aliases, right?

But one though might be, what happens if this is written...

for my $el1, $el2 ( (@foo, @bar, @arr) ) {
    print "$el\n"
 }

Does this bahave in the same way as the first one, but we just don't set
@arr elements, since the user forgot to provide a third alias, or should
this croak at compile time?

Ilya


-----Original Message-----
From: raptor
To: [EMAIL PROTECTED]
Sent: 07/20/2001 3:37 AM
Subject: Re: array/hash manipulation [was :what's with 'with'?]



> So my initial code (which I modified a little...)
>
> for ( @foo, @bar ) {
>   print "$_[0] : $_[1]\n";
> }
>
> for would set each element of the @_ array to correspond to the
arguments
in
> for() , therfore $_[0] will equal to the current element of @foo and
$_[1]
> will equal to the corresponding element of @bar.  As I mentioned
before
this
> can very easily be accomplished through 0..$#foo loop, but people
disagreed
> based on that it would be a nice option, in my opinion it's useless,
but
if
> was implemented this could be a way:)

]- Yes ... and one more option :

 for my $el1, $el2 ( @foo, @bar ) {
    print "$el1 : $el2\n"
 }

$el1 will get values from @foo and $el2 from @bar, but the following :

 for my $el ( @foo, @bar ) {
    print "$el\n"
 }

will print :
$foo[0]
$bar[0]
$foo[1]
$bar[1]

if people like the other way they can write :

 for my $el ( (@foo, @bar) ) {
    print "$el\n"
 }

will print :
$foo[0]
$foo[1]
...$foo[x]
$bar[0]
$bar[1]
....

is this correct , but now I'm looking at these too...
http://dev.perl.org/rfc/90.pod
http://dev.perl.org/rfc/91.pod
http://dev.perl.org/rfc/148.pod

so may be what must be the order of passing the arguments and other
stuff
should be done via these proposed functions.

PS. I was thinking of that before, what if we have something let's call
it
'transform' for transformation of any structure to other structure.. but
as
i thought it should combine in some way the features of
switch,if-else,for/foeach, do, while, array/hash-slices, assignment
....etc.... .... oooops I'm talking about DWIM operator..... anyway...
is it
possible to really add such "dwim" function/operator that can be
modified on
the fly so that it suit all programmers tastes and don't make real
mess...")
... ok i say it :")))
=====
iVAN
[EMAIL PROTECTED]
=====

Reply via email to