in reply to putting commas separated values into a new file line by line
open my $out, '>', 'new_file' or die $!;
If you just need to output the string, you can replace commas by newlines:
my $runTest = 'sydney,delhi,NY,Russia'; print {$out} $runTest =~ tr/,/\n/r;
Use say instead of print if you want a newline after Russia.
If you want to store the lines in an array, use split:
my @lines = split /,/, $runTest;
BTW, Sydney, Delhi, and NY are cities, while Russia is a country.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: putting commas separated values into a new file line by line
by Anonymous Monk on Aug 11, 2020 at 16:58 UTC | |
by choroba (Cardinal) on Aug 11, 2020 at 17:03 UTC | |
by Anonymous Monk on Aug 11, 2020 at 17:06 UTC | |
by choroba (Cardinal) on Aug 11, 2020 at 17:15 UTC |