Home Technical Talk

MEL - getting values from array returns without using variables

polycount lvl 666
Offline / Send Message
PolyHertz polycount lvl 666
Is there a way to get a certain value from an array retun without first assigning the return to a variable? For instance, I'd like to use something like:

`ls -sl -fl`[0];

instead of:

$val = `ls -sl -fl`;
$val[0];

Just seems like a waste to be creating variables for one time uses.

Replies

  • Chai
    Options
    Offline / Send Message
    Chai polycounter lvl 17
    I think JsTools or such, made an extra procedure to return the first element for example, to save code and such.
    I wonder if the variables get cleared from memory at the end of procedure codes, or at the end of entire script call ...

    But well, I usually just used $tmp or such, It's really insignificant.
Sign In or Register to comment.