in reply to Re^3: Data structure / hash reference question
in thread Data structure / hash reference question

I love learning new things :)

If I recall correctly, I found the basis for this trick years ago after figuring there must be a simpler way to do this:

# want fourth word my $str = "one two three four five"; my @array = split / /, $str; my $word = $array[3];

I monkeyed about and accidentally came up with this:

my $str = "one two three four five"; my $word = ( split / /, $str )[3];

Combined with my current knowledge of refs and anonymous data and where they are handy, I revisited the parens and came to the conclusion that the value after the expression is evaluated within the parens can be operated on directly.