in reply to Re^4: To read files from two dir
in thread To read files from two dir
Naturally, when I ran "perl -cw" on the script, it still gave up, because the stuff you posted ends in the middle of an "if" block, and before giving up, it reported dozens of "'my' variable ... masks ..." warnings.
But this time it also reported a bunch of "Global symbol '$SRC_DIR' requires explicit package name...", between lines 255 and 354. This is because two different lines above (123 and 128, near that f***ed up "foreach" line), which declare / assign to $SRC_DIR, are both commented out, so $SRC_DIR is never declared.
(Presumably, you should uncomment just one of those lines, and maybe change what's being assigned to it, in order to avoid the compile-time errors. As for what needs to be done to make this rats-nest do anything properly, I have no idea.)
UPDATED TO ADD: By the way, one more thing you need to know about that f***ed up "foreach" line:
When you use "my" to declare the looping variable in a foreach loop, that declaration is only valid inside the scope of that loop. That would explain why any use of $SRC_DIR later in the script would be an error. Consider the following:foreach my $SRC_DIR (@dir) {{
use strict; use warnings; for my $foo (1,2,3) { print $foo; } # The next line is a compile-time error: $foo is not declared here: print "Scalar variable foo now contains: $foo";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: To read files from two dir
by GrandFather (Saint) on Apr 14, 2022 at 02:12 UTC | |
|
Re^6: To read files from two dir
by pragovnj (Acolyte) on Apr 22, 2022 at 20:33 UTC | |
by graff (Chancellor) on Apr 23, 2022 at 01:06 UTC | |
by graff (Chancellor) on Apr 23, 2022 at 00:37 UTC | |
by pragovnj (Acolyte) on Apr 25, 2022 at 20:38 UTC | |
by hippo (Archbishop) on Apr 25, 2022 at 22:31 UTC | |
by pragovnj (Acolyte) on Apr 26, 2022 at 15:05 UTC | |
|