in reply to Why is @array so slow?

I'd never seen the angle operator used on an array before, but it seems to do the right thing, just really slowly.

You're stepped into a subtle one.   while (<@job_logs>) might do what you expect it to, but not for the reasons you think. Consult perlop, and read up on file globs.

Replies are listed 'Best First'.
Re: Re: Why is @array so slow?
by thor (Priest) on Feb 28, 2002 at 23:05 UTC
    I've been a bit busy the last couple of days, so I apologize for the late response. I just read perlop, and, if I may, I'd like to bounce my understanding of what is happening off of those more knowledgable.

    When I pass anything beside a file handle or a simple scalar to the <> operator, it passes the stuff inside the operator to the glob function. I'd imagine globbing 6000+ elements is a bit slow.

    What I don't understand is why japhy's example works. I would expect that it would try to glob (john jacob jingleheimer schmidt), not see anything like that in the directory, and evaluate to nothing. Oh well.<
      What I don't understand is why japhy's example works. I would expect that it would try to glob (john jacob jingleheimer schmidt), not see anything like that in the directory, and evaluate to nothing.

      glob() either mimics the shell or delegates to it for pattern expansion. Consider the difference between

      % echo foo foo %
      and
      % echo foo* echo: No match. %
      when there are no files begining with "foo" in the current directory.