All variables are package variables by default, unless stated otherwise. You'll have to declare them.
You should know that 'local' in Perl means something different to what people often expect. You're more than likely looking for a lexical variable, which are declared using "my".
Perl is not DCL so IMO there's no valid reason to want them to act the same. Do you feel the same way with bash scripts?
Declaring all of your vars with local means that you're not running under strictures, which is bad, and you may not even have warnings enabled. The combination of the strict and warnings pragmas will point out lots of mistakes/bugs.
Do yourself (and us) a favor and use the pragmas and declare your vars with my instead of local.
I have to agree with Ron here. It's usually a big mistake to try to compile one language in another or to "migrate" code from one language to another line by line.
Your best bet is to understand what the original code was trying to do and to replicate that functionality but using the tools and strengths of the new language you are trying to migrate to.
There are plenty of really clever people here that can help you to do that.
"local" in perl is used for very specific things (e.g. managing perl "special" variables). For pure scope limiting, "my" is generally the tool of choice.
Ok ok...I understand how to write Perl the "right" way. I am writing a DCL to Perl converter...so, I don't have the luxury of doing MOST things the right way...I'm stuck with what I can do with a converter. And, hopefully, this is just going to be a stop-gap solution simply to get on a different platform.
Trojan & Ron, although I totally agree with you...there is WAY too much code to do a re-write. If I had an unlimited time and resources, OF COURSE I would to it the way that you suggested!
ok CJason,
I think we get where you're coming from now.
We all have to make compromises in life and obviously you're stuck in a hole with this one.
Writing a converter like this is going to be a big task and very difficult to get right.
Well feel free to drop back again with more questions.
The guys (and girls?) here are trying to give you the best advice they can but obviously that is limited by our understanding of your situation.
Now that we know you're trying to write a converter I'm sure you'll find subsequent advice more tailored to your situation.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.