Chris Devers wrote:
On Mon, 28 Nov 2005, Andrej Kastrin wrote:
Hi, I am totally NOOB in Perl and here is my first problem, which I
couldn't solve...
I have column data in file xy.txt, which looks like:
AAAAA
BBBBB
CCCCC
ABCDD
..
.
Now I have to transform this to row data file in the following way:
"AAAAA","BBBBB","CCCCC","ABCDD"
Is that possible?
Yes, it's possible.
However, your description of the result you want doesn't seem to match
with the subject line you used -- I was expecting that you want output
like "ABCA", "ABCB..", "ABCD.", "ABCD", "ABCD". Which is it?
Regardless, either way is possible.
What have you tried so far?
Anything?
We can only help critique code you've attempted yourself.
This is not a free script writing service.
I suppose that above example is not good one; here is the real one:
Mark
Francesco
Ann
Robert
transform to: "Mark","Francesco","Ann","Robert"
and here is my code:
$source_file = "input.txt";
$result_file = "output.txt";
open (SOURCE, $source_file) || die "cannot open $source_file: $!";
open (RESULT, ">$result_file") || die "cannot open $result_file: $!";
while (<SOURCE>)
{
my($line) = $_;
if ($line =~ $) #match to end of line
{
print "$line"; #how to make e.g. "Mark",
}
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>