"be consistent" | |
PerlMonks |
Re: Is this code correctby davido (Cardinal) |
on Mar 22, 2021 at 19:30 UTC ( [id://11130152]=note: print w/replies, xml ) | Need Help?? |
It's incorrect because $sixth has never been initialized, so will always be undefined at the point you're attempting to assign its value to $a. Did you mean this instead?
That would make more sense. And if it's what you actually intended to type into your question, yes it is correct. The choice of $a as a variable name is terrible though, because it is the same name used in Perl's sort routine, and is exempt from strictures. Choose any name that isn't $a or $b. Even $c would be ok. So while my rewrite of your code is correct (assuming it was your original intent and you just wrote it wrong for your question), it's not the most Perlish. In Perl we would do something like this:
Dave
In Section
Seekers of Perl Wisdom
|
|