in reply to Legacy code question
Is there any advantage to using an array over a string here?
I guess it depends on how the variable is used afterwards - if there are additional values being pushed onto the array, it might make sense. It's just assigning a single value to the array; personally I would have written my @sqltt = (<<EOF); to make it explicit that yes, I meant to assign a single value to this array. But if the code then goes on to use $sqltt[0] everywhere, and especially if it doesn't add elements to the array, then it would definitely have been better to just use a plain scalar in the first place.
use warnings; use strict; use Data::Dump; my @sqltt = <<EOF; Hello, World! EOF dd @sqltt; __END__ "Hello,\nWorld!\n"
Minor update to wording.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Legacy code question
by Zenzizenzizenzic (Pilgrim) on May 13, 2019 at 14:23 UTC | |
by haukex (Archbishop) on May 13, 2019 at 14:30 UTC |