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

Re: File::Find in a loop

by NetWallah (Canon)
on Apr 28, 2013 at 16:07 UTC ( [id://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

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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1031093]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found