Perl: the Markov chain saw | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Simplest I think is to just post the canonical example that I run across again and again... I would dearly like this to be all on one line for concision and clarity: This gives:
It's the scoping of the parentheses around the my assignment that causes the problem. If I leave out @v from the error message, the logic is correct and everything works: @v, if assigned to successfully, is correctly set and visible for the print statement. I'm trying to avoid doing work twice (repeating the call to keys in the error message). The ugly alternative is to move my @v outside the comparison, but it just looks clunky and messes up a nice column of assignments. It's not just hash checking, it could be anything:
This has been bugging me for years, and I'm resigned to it, just wondering if there was a clever way around it. Thanks!In reply to Declaring with my, assigning, and testing in same line by mordibity
|
|