Why doesn't Perl file glob() work outside of a loop in scalar context?

后端 未结 4 1071
被撕碎了的回忆
被撕碎了的回忆 2021-02-14 15:49

According to the Perl documentation on file globbing, the <*> operator or glob() function, when used in a scalar context, should iterate through the list of files matching

4条回答
  •  我在风中等你
    2021-02-14 16:15

    Also from perlop:

    A (file)glob evaluates its (embedded) argument only when it is starting a new list.

    Calling glob creates a list, which is either returned whole (in list context) or retrieved one element at a time (in scalar context). But each call to glob creates a separate list.

提交回复
热议问题