in reply to putting commas separated values into a new file line by line

To create a new file, use open.
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.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

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

    i don't understood completely, i just want to have those command line passed values that are further stored under $runTest in a new file as line by line

    got below error while running the script

    Bareword found where operator expected at ./fileTest.pl line 10, near "tr/,/\n/r"

    syntax error at ./fileTest.pl line 10, near "tr/,/\n/r"

      What Perl version are you using?

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
        perl v5.10.1