in reply to iterating through scalar

Let me try to explain things a bit . . .

As the name sort-of implies, a “scalar” is:   “one thing.”1   However, in Perl, one of the “one things” that it can also be is “a reference.” (See the perldocs, e.g. perldsc, perllol, perlref ...)

It is very common in Perl to store references to things in scalar variables ... ordinarily, references to things that are referred-to nowhere else.   Hence the common Perl slang terms, “arrayref,” “hashref,” and so on.   You see idioms like (emphasis added ...)

    foreach @{$somescalar}

... all the time, which is iterating over the probably-anonymous thing (an array, in this case) that $somescalar refers to.   The perldsc perldoc topic is a great place to start reading.

HTH ...

- - - - - - - - - -

1   For my purposes here, a string is also “one” thing, in order to say that I’m not [necessarily ...] talking about strings.

Replies are listed 'Best First'.
Re^2: iterating through scalar
by Anonymous Monk on Feb 06, 2015 at 21:07 UTC
    You see idioms like foreach @{$somescalar} all the time

    If you see code like that all the time, how come you got the syntax wrong?