Wiggins D Anconia wrote:
>
> > I think I am picking up some bad habits so maybe you guys can help.
> >
> > I currently use this notation @{$hash{key}} to access an array stored in
> > a hash.
> > I keep seeing posts that it is better to use an object like notation.
> > Can I see some examples on how you would access the array or an element
> > of an array.
> >
> > Also is there a way to access slices in a foreach something like
> >
> > Foreach ((@arrar)[1,3..6]){
> > code
> > }
> >
>
> I wouldn't necessarily call it a bad habit as it does execute properly,
> it just doesn't produce as readable of code... Rob already covered ->
> well so I will just point you to some "light" reading if you thirst for
> more...

Yes. The only thing I'd add is that the brackets around '@arrar' aren't
necessary to build the slice.

  foreach ( @array[1,3..6] ) {
    :
  }

is fine.

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to