Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: File::Find in a loop

by NetWallah (Abbot)
on Apr 28, 2013 at 16:07 UTC ( #1031093=note: print w/ replies, xml ) Need Help??


in reply to File::Find in a loop

The "wanted" sub uses a GLOBAL $dir in your code. (Before I get flamed - what I mean is GLOBAL to the sub. The example below uses a lexical variable that is global to the sub)

In the "for my $dir" loop, $dir is LOCAL to the block enclosed by the "for" loop, so the "wanted" sub cannot see it.

To fix, keep $dir global:

my $dir; for $dir (@...)...

             "I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
        -- Dr. Cox, Scrubs


Comment on Re: File::Find in a loop
Download Code
Replies are listed 'Best First'.
Re^2: File::Find in a loop
by Anonymous Monk on Apr 29, 2013 at 09:05 UTC

    Before I get flamed

    You're not using that word correctly :)

      From The Urban Dictionary:
      flamed
      being attacked online/on a forum.

      I think it is appropriate. Do you have an alternative suggestion ?

                   "I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
              -- Dr. Cox, Scrubs

        flamed being attacked online/on a forum. I think it is appropriate. Do you have an alternative suggestion ?

        A punch in the face is an attack :)

        Calling someone online in a forum a you so-and-so-name-name-insult-insult for saying such-and-such is an attack, a flame.

        Someone saying "sorry , but that is not a global..." is not an attack, is not a flame. Even if the monks get a tad pedantic at times, turning typos into "teaching moments", this isn't a flame attack.

        I'm not sure, but I think you might be thinking of "nitpicking" (not nitpicking or nitpicking or pedant/pedantic)

        Flames aren't nice, I think PerlMonks is nice :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2015-07-29 12:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls