This seems fairly obvious, but somehow, even after fifteen years of Perl exposure, I've only just cottoned on to it now, so presumably this might be of assistance to other people.
Recently, I needed to read data line by line from a string (rather than from a file). You'd think that this would be a fairly common requirement, but evidently I've managed to either avoid it or fudge it up until now.
Anyway, there was no getting around it this time, but it turns out to be rather simple - just pass a reference to the variable when calling open():
my $text = "Some long text";
open(TEXT,"<", \$text);
while(<TEXT>) {
# do whatever
}
close(TEXT);
That's all there is to it!