You threw in 'use strict' and tried it, now you're complaining. Sounds like you don't understand what 'use strict' is meant to do or why it complains about what it complains.
I would strongly urge you to read a book on Perl, preferably one published by O'Reilly, that will give you a firm grounding in good programming practices, especially as they apply to Perl. Then, you will have a firmer grasp on what you would need to do to make your script run under 'use strict'.
After that, try 'use warnings' and work through those issues, as well. Then, if you're brave, add taint-checking. :-)
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
I shouldn't have to say this, but any code, unless otherwise stated, is untested
| [reply] |
I would strongly urge you to read a book on Perl
Good advice for new in perl...
| [reply] |
You can say,
use vars qw/@ll %those $variables/;
at the top and your script will be just as it was.
The better solution is to tighten up scopes and declare variables with my in the scopes where they are used.
Btw, perl beats js like a red-headed stepson for text editing.
| [reply] [d/l] |
this is a perl place...so don't ask for a javascript answer. when perl is in strict mode it requires that all variable declerations either have explicit package names added OR they be prefixed with "my" keyword. Hence, adding "my " in front of all the first instances of those variable names will fix it. | [reply] |
foreach $thingy ( @lots_of_thingies ) {
$all_of_them .= $thingy;
}
print "$all_of_them\n";
In that example, if $all_of_them is declared with my in the lexical scope bounded by the foreach loop's code block, you won't be able to print it after the loop runs out.
strict enforces not just the use of variable declaraction, but it requires that additional thought be paid to design of lexical scopes. The OP would be wise to read perlintro, perlsub, perlsyn and my for starters. Sometimes a script is just beyond converting to compliance with strictures unless one is willing to take the time for a major rewrite.
| [reply] [d/l] [select] |
could you show exact sample wherer should be added "my"?
| [reply] |
Here is a simple brief example, but like dragonchild says, to get the complete picture you should really get a Perl book. Personally I would recommend you borrow, steal or buy the "Camel" book from O'Reilly. It will fill you in on all the stuff necessary to get you going.
use strict;
#declare the variable $foo before using
my $foo;
$foo = 'hello world';
print $foo;
| [reply] [d/l] |
my @lots_of_thingies;
[...]
my $all_of_them;
foreach my $thingy ( @lots_of_thingies ) {
$all_of_them .= $thingy;
}
print "$all_of_them\n";
By side, this code cries for join... | [reply] [d/l] |