in reply to how to convert new line to ","
#!/usr/bin/perl use warnings; use strict; my(@accumulate) = (); while (<DATA>){ chomp; if (/^\s*$/) { print join(',', @accumulate), "\n"; @accumulate = (); } else {push(@accumulate, $_)} } if (@accumulate) {print join(',', @accumulate), "\n"} __DATA__ 1111 2222 3333 4444 5555 6666
|
|---|