Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: push foreach glob - bug?

by shmem (Chancellor)
on Jan 13, 2010 at 22:54 UTC ( [id://817299]=note: print w/replies, xml ) Need Help??


in reply to push foreach glob - bug?

Hm. Modifying an array whilst iterating over it? Maybe you should rather say

perl -le '@l = glob("*.mp3"); push @{$f[/ad/]}, $_ foreach @l;

(update) since @l[0,1] contain file names, not array references.

Replies are listed 'Best First'.
Re^2: push foreach glob - bug?
by ikegami (Patriarch) on Jan 13, 2010 at 22:58 UTC
    Modifying elements of an array over which one is iterating doesn't cause problems. It's done all the time:
    s/^\s+//, s/\s+$// for @array;

      Right. But modifying values that way doesn't involve coercion of a string into an array reference... (I have just been giving a hint to puzzle further ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://817299]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2024-04-23 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found