$ cat 2.pl
while(<DATA>) {
print $_;
}
__DATA__
JOHN DOE
SUSAN ZHANG
TINA WILSON
WESLEY STONEMAN
SARAH HOCKS
$ perl 2.pl
JOHN DOE
SUSAN ZHANG
TINA WILSON
WESLEY STONEMAN
SARAH HOCKS
I have a big data section, where should I put in scala program?
That depends on the type of the data – there’s no one-size-fits-all answer, because there are many forms of data. The Perl version is implicitly assuming that the data is a gigantic string; if that’s what you want, just do that – define it as a big triple-quoted string block:
val data = """
JOHN DOE
SUSAN ZHANG
TINA WILSON
WESLEY STONEMAN
SARAH HOCKS
"""
You can have global constants inside an object
You may have some kind of text file in the src/main/resource
You may rather let the user give you the path of the file to read